From patchwork Tue Mar 28 06:28:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9648191 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 E209C601D7 for ; Tue, 28 Mar 2017 06:29:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3DAC20008 for ; Tue, 28 Mar 2017 06:29:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8838283E8; Tue, 28 Mar 2017 06:29:54 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 3EB6320008 for ; Tue, 28 Mar 2017 06:29:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754214AbdC1G3y (ORCPT ); Tue, 28 Mar 2017 02:29:54 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:34937 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753925AbdC1G3x (ORCPT ); Tue, 28 Mar 2017 02:29:53 -0400 Received: by mail-pg0-f52.google.com with SMTP id 81so48594290pgh.2 for ; Mon, 27 Mar 2017 23:29:52 -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=xe5lTFNBSzjNsce2GdKCCskG4Bm0KGo221bCuDBKv2s=; b=y1BSMooi/MxA04oSZsA7mB+kAsfZoJysbt2+igtDeBIZS/l+h2VgAoh8XcnbwXB56L oMS+kDCziaC/IepknZpaOclx/A9ud5bMi8M7I31P/R7rp3LEDAYf2dFhayJLKD0nlWrU dIW4rWaTjPicO1evucgqhUsL4rWCj/HoCEcKs94luY9zDG+A+cYY6gBYrflJSqEs86fZ cfJj9YiAd3CUsQKgH6MGxBd+ZjkddotzoBdWGI6xqt+7OGYLGmr3rWfJudEAehnJk0ZP /9dfOWSFVveP0+lxumbaguTIksugfBzxAEs6G5U2fjpJNXBZou0d7ySpPKeFlG2rKw/P e1nA== 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=xe5lTFNBSzjNsce2GdKCCskG4Bm0KGo221bCuDBKv2s=; b=UrdwD7mngcxuoHJ0a6dN3g/Bm8ksD+6dD/d1+l3nk+TnjhAfZfq80WAo61SnLG2i4s qq4KFgJRRV5/7vvHVfhdUU548AVx+qCcbGLvtFWJFBtOc4OtLkkWq1t2HRSaom7QMRcX GJhM4tiyNuQvSvbvDHIh8wfdi07IIdUkxo11SKfvHRjMQaElXfzGp15gBflXXYymwTeU +THdPWXS+3jPfVYUo9Pre6jlWdlxy43RPRMGSX0ZL5drNxZoVn+MeYeooxBQ2/DBD1GW Ame+s9o3WQgELImqm+4NT0p5cfo3abyYP1B543xYeNjrBrsDR0Jakve8AUQvbuvRFmk3 65vA== X-Gm-Message-State: AFeK/H3utw+wHGb/aftoIRUfFV3tqyftdaRjnD2DstXxghQz+rPczYt7TNKXFcuP7CocWOJI X-Received: by 10.84.197.1 with SMTP id m1mr2771215pld.183.1490682592398; Mon, 27 Mar 2017 23:29:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 23:29:51 -0700 (PDT) From: Omar Sandoval To: Jens Axboe , Vivek Goyal , linux-block@vger.kernel.org Cc: kernel-team@fb.com, "David S . Miller" Subject: [PATCH 6/6] jsflash: stop sharing request queue across multiple gendisks Date: Mon, 27 Mar 2017 23:28:47 -0700 Message-Id: <177c67289c6878fa56c273a92f9c0069ee0f113f.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 (by hacking it to compile on x86). Cc: David S. Miller Signed-off-by: Omar Sandoval --- drivers/sbus/char/jsflash.c | 50 ++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index 6ff61dad5e21..62fed9dc893e 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c @@ -183,11 +183,33 @@ static void jsfd_read(char *buf, unsigned long p, size_t togo) { } } -static void jsfd_do_request(struct request_queue *q) +static int jsfd_queue; + +static struct request *jsfd_next_request(void) +{ + struct request_queue *q; + struct request *rq; + int old_pos = jsfd_queue; + + do { + q = jsfd_disk[jsfd_queue]->queue; + if (++jsfd_queue == JSF_MAX) + jsfd_queue = 0; + if (q) { + rq = blk_fetch_request(q); + if (rq) + return rq; + } + } while (jsfd_queue != old_pos); + + return NULL; +} + +static void jsfd_request(void) { struct request *req; - req = blk_fetch_request(q); + req = jsfd_next_request(); while (req) { struct jsfd_part *jdp = req->rq_disk->private_data; unsigned long offset = blk_rq_pos(req) << 9; @@ -211,10 +233,15 @@ static void jsfd_do_request(struct request_queue *q) err = 0; end: if (!__blk_end_request_cur(req, err)) - req = blk_fetch_request(q); + req = jsfd_next_request(); } } +static void jsfd_do_request(struct request_queue *q) +{ + jsfd_request(); +} + /* * The memory devices use the full 32/64 bits of the offset, and so we cannot * check against negative addresses: they are ok. The return value is weird, @@ -544,8 +571,6 @@ static int jsflash_init(void) return 0; } -static struct request_queue *jsf_queue; - static int jsfd_init(void) { static DEFINE_SPINLOCK(lock); @@ -562,6 +587,11 @@ static int jsfd_init(void) struct gendisk *disk = alloc_disk(1); if (!disk) goto out; + disk->queue = blk_init_queue(jsfd_do_request, &lock); + if (!disk->queue) { + put_disk(disk); + goto out; + } jsfd_disk[i] = disk; } @@ -570,13 +600,6 @@ static int jsfd_init(void) goto out; } - jsf_queue = blk_init_queue(jsfd_do_request, &lock); - if (!jsf_queue) { - err = -ENOMEM; - unregister_blkdev(JSFD_MAJOR, "jsfd"); - goto out; - } - for (i = 0; i < JSF_MAX; i++) { struct gendisk *disk = jsfd_disk[i]; if ((i & JSF_PART_MASK) >= JSF_NPART) continue; @@ -589,7 +612,6 @@ static int jsfd_init(void) disk->fops = &jsfd_fops; set_capacity(disk, jdp->dsize >> 9); disk->private_data = jdp; - disk->queue = jsf_queue; add_disk(disk); set_disk_ro(disk, 1); } @@ -619,6 +641,7 @@ static void __exit jsflash_cleanup_module(void) for (i = 0; i < JSF_MAX; i++) { if ((i & JSF_PART_MASK) >= JSF_NPART) continue; del_gendisk(jsfd_disk[i]); + blk_cleanup_queue(jsfd_disk[i]->queue); put_disk(jsfd_disk[i]); } if (jsf0.busy) @@ -628,7 +651,6 @@ static void __exit jsflash_cleanup_module(void) misc_deregister(&jsf_dev); unregister_blkdev(JSFD_MAJOR, "jsfd"); - blk_cleanup_queue(jsf_queue); } module_init(jsflash_init_module);