From patchwork Tue Mar 28 06:28:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9648193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 506E4601D7 for ; Tue, 28 Mar 2017 06:29:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4251B20008 for ; Tue, 28 Mar 2017 06:29:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3753E283E8; Tue, 28 Mar 2017 06:29:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C102620008 for ; Tue, 28 Mar 2017 06:29:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754305AbdC1G34 (ORCPT ); Tue, 28 Mar 2017 02:29:56 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:33348 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753925AbdC1G3z (ORCPT ); Tue, 28 Mar 2017 02:29:55 -0400 Received: by mail-pg0-f41.google.com with SMTP id n5so55446574pgh.0 for ; Mon, 27 Mar 2017 23:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=PtDZyB4Hkst2zCt5F+0sSA+qFbMnynoa3b/BefTK8NY=; b=RKQliorsjYtfp9u/Rj5k7rVQaAKWp3+6dbyPgTYlrl1Ew0HGE76pXqQ5yOdsBITTmX llXN9SjU9PkzgFMRKDARgEx667EdkhTo4gQFxw8njY5z++wx0SgWzsbfG5xWuOkH7cbl TjDWdiQTJEUK+uXklLK/E55mD7AN7+exu+UimECfg2E1db4gQn8cy4U+0l4D+v27wtqj N5fRY0xkWcIU5Tm5mRxwGLnC6OXYuNw68Jy2oOH6ceRqQhRlzlOhQI8fBQnEKUkfyjgM 3Bu99B4uW2Tj0VzTGFii2wKpSLsuhIUIBlvFS1Fit0zEYe36CW0dueSNvWGiDf6sLxRl pqFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=PtDZyB4Hkst2zCt5F+0sSA+qFbMnynoa3b/BefTK8NY=; b=WD1WDOwLfD/WeU+36muZcMGiWJOd2vHXmKl0wqCSz7uyjoxk4xjK6cd/mEiMuNh/Wi 1xSOq+0nAdGWBZg+t79ODtzSJFRYk233sCh6QrIQEyIsOpZC7ftKuXZUe4CAf20Fa4WP L5h9Qsd1knTOj+IGXejvkykvu8Vu4Pf0LtcsPDGYjgtFtrAJgpm5P++PUwjtafL3bhRD j/Da3saJ9TU0pGUruG+wGMWUJoBc4HTSnkr7rkAytLSjzGdGq17tptLwGcQv7pzF5YnY yfmjRDJ0qDdGluFMWBpHLy4p2VEthdTAWjOv5k2SmFR8ExLLvBIaLOhYBdHG1eDT6lU6 /DeQ== X-Gm-Message-State: AFeK/H1edCa32fMwQ0XpXgk6ZDW8sEpprCwS7O7CK8A9wP20rgGH/+W8dF7LZUb75f3KwbwU X-Received: by 10.98.156.203 with SMTP id u72mr28825516pfk.127.1490682588882; Mon, 27 Mar 2017 23:29:48 -0700 (PDT) Received: from localhost.localdomain ([2601:602:8801:8110:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id n85sm4774809pfi.101.2017.03.27.23.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 23:29:48 -0700 (PDT) From: Omar Sandoval To: Jens Axboe , Vivek Goyal , linux-block@vger.kernel.org Cc: kernel-team@fb.com, Tim Waugh Subject: [PATCH 2/6] parport/pd: stop sharing request queue across multiple gendisks Date: Mon, 27 Mar 2017 23:28:43 -0700 Message-Id: <70d4d7b67848ee2fdcbfcf6b1accc89ac7a1659c.1490681910.git.osandov@fb.com> X-Mailer: git-send-email 2.12.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval Compile-tested only. Cc: Tim Waugh Signed-off-by: Omar Sandoval --- drivers/block/paride/pd.c | 50 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 9cfd2e06a649..b05e151c9b38 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -381,12 +381,33 @@ static enum action do_pd_write_start(void); static enum action do_pd_read_drq(void); static enum action do_pd_write_done(void); -static struct request_queue *pd_queue; +static int pd_queue; static int pd_claimed; static struct pd_unit *pd_current; /* current request's drive */ static PIA *pi_current; /* current request's PIA */ +static int set_next_request(void) +{ + struct gendisk *disk; + struct request_queue *q; + int old_pos = pd_queue; + + do { + disk = pd[pd_queue].gd; + q = disk ? disk->queue : NULL; + if (++pd_queue == PD_UNITS) + pd_queue = 0; + if (q) { + pd_req = blk_fetch_request(q); + if (pd_req) + break; + } + } while (pd_queue != old_pos); + + return pd_req != NULL; +} + static void run_fsm(void) { while (1) { @@ -418,8 +439,7 @@ static void run_fsm(void) spin_lock_irqsave(&pd_lock, saved_flags); if (!__blk_end_request_cur(pd_req, res == Ok ? 0 : -EIO)) { - pd_req = blk_fetch_request(pd_queue); - if (!pd_req) + if (!set_next_request()) stop = 1; } spin_unlock_irqrestore(&pd_lock, saved_flags); @@ -839,7 +859,13 @@ static void pd_probe_drive(struct pd_unit *disk) p->first_minor = (disk - pd) << PD_BITS; disk->gd = p; p->private_data = disk; - p->queue = pd_queue; + p->queue = blk_init_queue(do_pd_request, &pd_lock); + if (!p->queue) { + disk->gd = NULL; + put_disk(p); + return; + } + blk_queue_max_hw_sectors(p->queue, cluster); if (disk->drive == -1) { for (disk->drive = 0; disk->drive <= 1; disk->drive++) @@ -919,26 +945,18 @@ static int __init pd_init(void) if (disable) goto out1; - pd_queue = blk_init_queue(do_pd_request, &pd_lock); - if (!pd_queue) - goto out1; - - blk_queue_max_hw_sectors(pd_queue, cluster); - if (register_blkdev(major, name)) - goto out2; + goto out1; printk("%s: %s version %s, major %d, cluster %d, nice %d\n", name, name, PD_VERSION, major, cluster, nice); if (!pd_detect()) - goto out3; + goto out2; return 0; -out3: - unregister_blkdev(major, name); out2: - blk_cleanup_queue(pd_queue); + unregister_blkdev(major, name); out1: return -ENODEV; } @@ -953,11 +971,11 @@ static void __exit pd_exit(void) if (p) { disk->gd = NULL; del_gendisk(p); + blk_cleanup_queue(p->queue); put_disk(p); pi_release(disk->pi); } } - blk_cleanup_queue(pd_queue); } MODULE_LICENSE("GPL");