From patchwork Tue Mar 28 06:28:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9648189 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 6E3D3601D7 for ; Tue, 28 Mar 2017 06:29:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 600DB20008 for ; Tue, 28 Mar 2017 06:29:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54C3D283E8; Tue, 28 Mar 2017 06:29:53 +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 9D00B20008 for ; Tue, 28 Mar 2017 06:29:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754211AbdC1G3w (ORCPT ); Tue, 28 Mar 2017 02:29:52 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:35956 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753925AbdC1G3w (ORCPT ); Tue, 28 Mar 2017 02:29:52 -0400 Received: by mail-pg0-f45.google.com with SMTP id g2so62646692pge.3 for ; Mon, 27 Mar 2017 23:29:51 -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=GKdtWR7LeXDGaG4oXLhUKl0cH2TnpQO3fzFIuYT/0ek=; b=Xlqzux2lOa6Vz69x33AX68m/YcBwHei4Uv1Hj8vbypz21Xr2sKxuJ7jDEoESflRnAK vFTP/qpHrGQeuqzHT9aTfn2mkw8M3A7W6S1nC85M5De62siqg727ecx1IYQk/0/YbB8y nvocQ1DkH9X9Vpmi3uGBDAnLh/LzYAb4Fpra5Ptw9L4zij/5b7pTaHTGow+m1ihRXD0O TOLOKOwVMn/lXPH3BAUs9mZpACm97y9BLPuntuYuAJm0KqcZJ2Txyvw/eAYGZ1dYIC9J ZCJlF6SIkJLVd0YFOTe7lUOPmw5u7bh3SpMw3skuYu1ZciSH/g9tg+pFfs/PoA6zY13J M2CA== 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=GKdtWR7LeXDGaG4oXLhUKl0cH2TnpQO3fzFIuYT/0ek=; b=DjC/WQe5LbDhk2Rf/6nrO54NVhjAOnArsu8t16tX8d5HElunz7ifyH3TfRPWjGg67y Ck3gs/d7rtes5nQN0LIKhN9XNfaPrX3s2ANWznzJpr/236rbuGsUvS75wLMjJRDKQgjz kDz41kVXKpX0gqyICahkvEx0coybtOD/Qk6VbJMxynVmcn2YE9PsZR0yaMZxbyS8/HKJ vmF9haQrepuuL331c227OYQ2x5NIDTwN63t3JkfomWmTxECl6BIEwsP69DBmz5/thaCq mhlB3sXvqveP5IJBeXjBMJVR5ToxZjUftn/5wkADcgb8ikET5xDPap4/Y9V6Met8mXT0 3+Rw== X-Gm-Message-State: AFeK/H2KlUOWkQwuKzHzC6qeEkvOJYHpGsDMeZHT5jG0JcDCZHfhxOFUw+wG/9djHfBJW3GL X-Received: by 10.84.217.2 with SMTP id o2mr34461086pli.51.1490682590714; Mon, 27 Mar 2017 23:29:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 23:29:50 -0700 (PDT) From: Omar Sandoval To: Jens Axboe , Vivek Goyal , linux-block@vger.kernel.org Cc: kernel-team@fb.com, Tim Waugh Subject: [PATCH 4/6] parport/pf: stop sharing request queue across multiple gendisks Date: Mon, 27 Mar 2017 23:28:45 -0700 Message-Id: <627567bd2a1a08ca9f8e625c8ac451e023dc2d7f.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/pf.c | 57 +++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index 14c5d32f5d8b..f24ca7315ddc 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -287,6 +287,12 @@ static void __init pf_init_units(void) struct gendisk *disk = alloc_disk(1); if (!disk) continue; + disk->queue = blk_init_queue(do_pf_request, &pf_spin_lock); + if (!disk->queue) { + put_disk(disk); + return; + } + blk_queue_max_segments(disk->queue, cluster); pf->disk = disk; pf->pi = &pf->pia; pf->media_status = PF_NM; @@ -772,7 +778,28 @@ static int pf_ready(void) return (((status_reg(pf_current) & (STAT_BUSY | pf_mask)) == pf_mask)); } -static struct request_queue *pf_queue; +static int pf_queue; + +static int set_next_request(void) +{ + struct pf_unit *pf; + struct request_queue *q; + int old_pos = pf_queue; + + do { + pf = &units[pf_queue]; + q = pf->present ? pf->disk->queue : NULL; + if (++pf_queue == PF_UNITS) + pf_queue = 0; + if (q) { + pf_req = blk_fetch_request(q); + if (pf_req) + break; + } + } while (pf_queue != old_pos); + + return pf_req != NULL; +} static void pf_end_request(int err) { @@ -780,16 +807,13 @@ static void pf_end_request(int err) pf_req = NULL; } -static void do_pf_request(struct request_queue * q) +static void pf_request(void) { if (pf_busy) return; repeat: - if (!pf_req) { - pf_req = blk_fetch_request(q); - if (!pf_req) - return; - } + if (!pf_req && !set_next_request()) + return; pf_current = pf_req->rq_disk->private_data; pf_block = blk_rq_pos(pf_req); @@ -817,6 +841,11 @@ static void do_pf_request(struct request_queue * q) } } +static void do_pf_request(struct request_queue *q) +{ + pf_request(); +} + static int pf_next_buf(void) { unsigned long saved_flags; @@ -846,7 +875,7 @@ static inline void next_request(int err) spin_lock_irqsave(&pf_spin_lock, saved_flags); pf_end_request(err); pf_busy = 0; - do_pf_request(pf_queue); + pf_request(); spin_unlock_irqrestore(&pf_spin_lock, saved_flags); } @@ -972,15 +1001,6 @@ static int __init pf_init(void) put_disk(pf->disk); return -EBUSY; } - pf_queue = blk_init_queue(do_pf_request, &pf_spin_lock); - if (!pf_queue) { - unregister_blkdev(major, name); - for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) - put_disk(pf->disk); - return -ENOMEM; - } - - blk_queue_max_segments(pf_queue, cluster); for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) { struct gendisk *disk = pf->disk; @@ -988,7 +1008,6 @@ static int __init pf_init(void) if (!pf->present) continue; disk->private_data = pf; - disk->queue = pf_queue; add_disk(disk); } return 0; @@ -1003,10 +1022,10 @@ static void __exit pf_exit(void) if (!pf->present) continue; del_gendisk(pf->disk); + blk_cleanup_queue(pf->disk->queue); put_disk(pf->disk); pi_release(pf->pi); } - blk_cleanup_queue(pf_queue); } MODULE_LICENSE("GPL");