From patchwork Tue Mar 28 06:28:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9648197 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 72012601D7 for ; Tue, 28 Mar 2017 06:30:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 611BD20008 for ; Tue, 28 Mar 2017 06:30:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53CC8283E8; Tue, 28 Mar 2017 06:30:07 +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 E539320008 for ; Tue, 28 Mar 2017 06:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754345AbdC1GaH (ORCPT ); Tue, 28 Mar 2017 02:30:07 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:34917 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754313AbdC1GaG (ORCPT ); Tue, 28 Mar 2017 02:30:06 -0400 Received: by mail-pg0-f46.google.com with SMTP id 81so48593237pgh.2 for ; Mon, 27 Mar 2017 23:30:05 -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=fkwhlvzCk6QqUhR6iuDyXk7h1b3qsy2ewyUyykkPhRQ=; b=ShkDkVbocVT0f+VnvtuAse36Ni3ceDE2C+csbx7vDYBwTsLBIWi87SU+DpthtufaB9 2kbn2PmHafZq3liApQ+OP3U7J8FcRzsd3R+fG9SfGmeo+AYIyXLV6WRonyth3LgTJFMX OCxqcB/Ixu7wGHjLY4q1KqwdaCfQq0yk4ocxrFRl+govNtJ/c3RJ/XNFJvQTdGVZTdCx zRFYPLjayG6X6q+Oeg0y20ilS9iU+ErXA9M4wNkqOOUHmTDCWfxV0UQVXfANjJk5kfDV 9GTmERgtmj4rd6rwyY3Mqta1NavoW4WmmfPfCb7d7ZkmczX/Fx3k1GiGyxS8CCnxDysu onnQ== 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=fkwhlvzCk6QqUhR6iuDyXk7h1b3qsy2ewyUyykkPhRQ=; b=lPAcf7LDqasVY6MF36EzNdlIB0R6pqKDhMOhQf4iJtugKmS+PAWRVGgQWnb5ZjPB4g 7Vu87Gbw7E9eqRNAhEN1eo1VmzQ95cTE3HtEBD40C8jYMCtWmF9KDeWn99O1PyByJ5fd OymtVHrjxi3guW5eZycMhPFiwT7qs2YdTltsOZHVaTE6ofUyZocXM4SmsfAazVvtWnpX tgBvYla8glr1v194ELcFQnEkuWqyQdU0VDbNJArkPsO5TojSQIXyT2TosDJvxHJUc1R9 ZuCE6XvmUFPD1s7lcWyu22IUu3oGJYf1QxF35YC51q8BNL1NfBuxu/lG9l7UI6tXp41E HgMA== X-Gm-Message-State: AFeK/H1fPIVEUWgSvE0xeb67SMFsIGsk+HoBLUkmhOwjm2sI9NzSoBSvYk8LW4HaoVa7gDnN X-Received: by 10.84.231.193 with SMTP id g1mr33767361pln.59.1490682589705; Mon, 27 Mar 2017 23:29:49 -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:49 -0700 (PDT) From: Omar Sandoval To: Jens Axboe , Vivek Goyal , linux-block@vger.kernel.org Cc: kernel-team@fb.com, Tim Waugh Subject: [PATCH 3/6] parport/pcd: stop sharing request queue across multiple gendisks Date: Mon, 27 Mar 2017 23:28:44 -0700 Message-Id: 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/pcd.c | 57 ++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index 939641d6e262..b1267ef34d5a 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c @@ -300,6 +300,11 @@ static void pcd_init_units(void) struct gendisk *disk = alloc_disk(1); if (!disk) continue; + disk->queue = blk_init_queue(do_pcd_request, &pcd_lock); + if (!disk->queue) { + put_disk(disk); + continue; + } cd->disk = disk; cd->pi = &cd->pia; cd->present = 0; @@ -735,18 +740,36 @@ static int pcd_detect(void) } /* I/O request processing */ -static struct request_queue *pcd_queue; +static int pcd_queue; + +static int set_next_request(void) +{ + struct pcd_unit *cd; + struct request_queue *q; + int old_pos = pcd_queue; + + do { + cd = &pcd[pcd_queue]; + q = cd->present ? cd->disk->queue : NULL; + if (++pcd_queue == PCD_UNITS) + pcd_queue = 0; + if (q) { + pcd_req = blk_fetch_request(q); + if (pcd_req) + break; + } + } while (pcd_queue != old_pos); + + return pcd_req != NULL; +} -static void do_pcd_request(struct request_queue * q) +static void pcd_request(void) { if (pcd_busy) return; while (1) { - if (!pcd_req) { - pcd_req = blk_fetch_request(q); - if (!pcd_req) - return; - } + if (!pcd_req && !set_next_request()) + return; if (rq_data_dir(pcd_req) == READ) { struct pcd_unit *cd = pcd_req->rq_disk->private_data; @@ -766,6 +789,11 @@ static void do_pcd_request(struct request_queue * q) } } +static void do_pcd_request(struct request_queue *q) +{ + pcd_request(); +} + static inline void next_request(int err) { unsigned long saved_flags; @@ -774,7 +802,7 @@ static inline void next_request(int err) if (!__blk_end_request_cur(pcd_req, err)) pcd_req = NULL; pcd_busy = 0; - do_pcd_request(pcd_queue); + pcd_request(); spin_unlock_irqrestore(&pcd_lock, saved_flags); } @@ -849,7 +877,7 @@ static void do_pcd_read_drq(void) do_pcd_read(); spin_lock_irqsave(&pcd_lock, saved_flags); - do_pcd_request(pcd_queue); + pcd_request(); spin_unlock_irqrestore(&pcd_lock, saved_flags); } @@ -957,19 +985,10 @@ static int __init pcd_init(void) return -EBUSY; } - pcd_queue = blk_init_queue(do_pcd_request, &pcd_lock); - if (!pcd_queue) { - unregister_blkdev(major, name); - for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) - put_disk(cd->disk); - return -ENOMEM; - } - for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) { if (cd->present) { register_cdrom(&cd->info); cd->disk->private_data = cd; - cd->disk->queue = pcd_queue; add_disk(cd->disk); } } @@ -988,9 +1007,9 @@ static void __exit pcd_exit(void) pi_release(cd->pi); unregister_cdrom(&cd->info); } + blk_cleanup_queue(cd->disk->queue); put_disk(cd->disk); } - blk_cleanup_queue(pcd_queue); unregister_blkdev(major, name); pi_unregister_driver(par_drv); }