From patchwork Tue Mar 28 06:28:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9648195 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 00EB0601D7 for ; Tue, 28 Mar 2017 06:29:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E631B20008 for ; Tue, 28 Mar 2017 06:29:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D97A3283E8; Tue, 28 Mar 2017 06:29:58 +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 5FDE820008 for ; Tue, 28 Mar 2017 06:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754315AbdC1G36 (ORCPT ); Tue, 28 Mar 2017 02:29:58 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:33367 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754306AbdC1G36 (ORCPT ); Tue, 28 Mar 2017 02:29:58 -0400 Received: by mail-pg0-f53.google.com with SMTP id n5so55447567pgh.0 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=2eiasSUAZxIBAsCKJNNmVvc6e78MDfnmVL3Oj1vpE4I=; b=wwz6yiaYB2of5/ATpKNNjbxdqpHjy2NG6rTc7hO/q1A25+wAGl83S59Qhh4kMNjE3g S34cZA8ylsrmiY3mlU0G7xGOsHB2eGcFisu0cAJX/I/fIwmxxt59lwvvVEX2EriJ0Wfq lik4Pn4pB++jbHWGUXblSi/rqyO9K9ygh9zB14U+wnm+9XDsPDZhty8JCe8fKJ8a3thC +4DZkTevB4y0rhWPJ1A69+/5bs5EWxPtvtHKSVoN+4q6W/l0xN4VOOyuqi+tTlSweVK2 xYkhXrWOJ2sgoi7KlR5Io3mu4/QAaIoyL4lmmmXz1nm+LYoxE8wcJM2cKkjkIDgGsHq5 UdAw== 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=2eiasSUAZxIBAsCKJNNmVvc6e78MDfnmVL3Oj1vpE4I=; b=DTJUzLDYc+UYvcPPu+DYkSca+qtvo9FCOg6NzysyWI8kuO8sYttTpylZu8Oe5c8dld Bz7iWZqccH16ZKWl7NVuFSqMLf0W6hRiz32WNJK63aCRmdUlCbZhkh2G9HIiZKo51ZwY To3GQ4IUfl7tvQSevlmfLOY3G4pnOkNvb/GhEpbpy8iC4gV7eIr4lde3XbGQBE5TGMje k5XMpVRSHZLac2APruiQv0ZOILQMH4ULWFMsLHCRNBc68pCIGYvldx5A/4MzuxqbQY1V LmnStCh2L6NgbRGEW8Ewi6P9k+IueL1w6MnMBr+CpUycJ/eq1P6HUkkZ5DSXfA0yhy/L W/iA== X-Gm-Message-State: AFeK/H3+t9+MyK32ZBQAaZeQDjPfUNTTRAb5ziRtxbJSzf/1T603Ul3qjzA4p0x5gqZbM4fw X-Received: by 10.99.39.71 with SMTP id n68mr28770671pgn.85.1490682591531; Mon, 27 Mar 2017 23:29:51 -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.50 (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 Subject: [PATCH 5/6] swim: stop sharing request queue across multiple gendisks Date: Mon, 27 Mar 2017 23:28:46 -0700 Message-Id: <6edfbcdd4cdc1e1225819b2412eff15c9074df45.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). Signed-off-by: Omar Sandoval --- drivers/block/swim.c | 55 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index b5afd495d482..3064be6cf375 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -211,7 +211,7 @@ enum head { struct swim_priv { struct swim __iomem *base; spinlock_t lock; - struct request_queue *queue; + int fdc_queue; int floppy_count; struct floppy_state unit[FD_MAX_UNIT]; }; @@ -525,12 +525,33 @@ static int floppy_read_sectors(struct floppy_state *fs, return 0; } -static void redo_fd_request(struct request_queue *q) +static struct request *swim_next_request(struct swim_priv *swd) { + struct request_queue *q; + struct request *rq; + int old_pos = swd->fdc_queue; + + do { + q = swd->unit[swd->fdc_queue].disk->queue; + if (++swd->fdc_queue == swd->floppy_count) + swd->fdc_queue = 0; + if (q) { + rq = blk_fetch_request(q); + if (rq) + return rq; + } + } while (swd->fdc_queue != old_pos); + + return NULL; +} + +static void do_fd_request(struct request_queue *q) +{ + struct swim_priv *swd = q->queuedata; struct request *req; struct floppy_state *fs; - req = blk_fetch_request(q); + req = swim_next_request(swd); while (req) { int err = -EIO; @@ -554,15 +575,10 @@ static void redo_fd_request(struct request_queue *q) } done: if (!__blk_end_request_cur(req, err)) - req = blk_fetch_request(q); + req = swim_next_request(swd); } } -static void do_fd_request(struct request_queue *q) -{ - redo_fd_request(q); -} - static struct floppy_struct floppy_type[4] = { { 0, 0, 0, 0, 0, 0x00, 0x00, 0x00, 0x00, NULL }, /* no testing */ { 720, 9, 1, 80, 0, 0x2A, 0x02, 0xDF, 0x50, NULL }, /* 360KB SS 3.5"*/ @@ -833,22 +849,25 @@ static int swim_floppy_init(struct swim_priv *swd) return -EBUSY; } + spin_lock_init(&swd->lock); + for (drive = 0; drive < swd->floppy_count; drive++) { swd->unit[drive].disk = alloc_disk(1); if (swd->unit[drive].disk == NULL) { err = -ENOMEM; goto exit_put_disks; } + swd->unit[drive].disk->queue = blk_init_queue(do_fd_request, + &swd->lock); + if (!swd->unit[drive].disk->queue) { + err = -ENOMEM; + put_disk(swd->unit[drive].disk); + goto exit_put_disks; + } + swd->unit[drive].disk->queue->queuedata = swd; swd->unit[drive].swd = swd; } - spin_lock_init(&swd->lock); - swd->queue = blk_init_queue(do_fd_request, &swd->lock); - if (!swd->queue) { - err = -ENOMEM; - goto exit_put_disks; - } - for (drive = 0; drive < swd->floppy_count; drive++) { swd->unit[drive].disk->flags = GENHD_FL_REMOVABLE; swd->unit[drive].disk->major = FLOPPY_MAJOR; @@ -856,7 +875,6 @@ static int swim_floppy_init(struct swim_priv *swd) sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive); swd->unit[drive].disk->fops = &floppy_fops; swd->unit[drive].disk->private_data = &swd->unit[drive]; - swd->unit[drive].disk->queue = swd->queue; set_capacity(swd->unit[drive].disk, 2880); add_disk(swd->unit[drive].disk); } @@ -943,13 +961,12 @@ static int swim_remove(struct platform_device *dev) for (drive = 0; drive < swd->floppy_count; drive++) { del_gendisk(swd->unit[drive].disk); + blk_cleanup_queue(swd->unit[drive].disk->queue); put_disk(swd->unit[drive].disk); } unregister_blkdev(FLOPPY_MAJOR, "fd"); - blk_cleanup_queue(swd->queue); - /* eject floppies */ for (drive = 0; drive < swd->floppy_count; drive++)