From patchwork Tue Mar 28 23:12:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9650627 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 EF264601D7 for ; Tue, 28 Mar 2017 23:13:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEE1C2844E for ; Tue, 28 Mar 2017 23:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3FAE28451; Tue, 28 Mar 2017 23:13:38 +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 2DDF928452 for ; Tue, 28 Mar 2017 23:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753523AbdC1XNV (ORCPT ); Tue, 28 Mar 2017 19:13:21 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:33770 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753312AbdC1XNU (ORCPT ); Tue, 28 Mar 2017 19:13:20 -0400 Received: by mail-pg0-f54.google.com with SMTP id x125so1240248pgb.0 for ; Tue, 28 Mar 2017 16:13:19 -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; bh=1FdWZXkp46/ajuKyKFjHaTT4t79yEHSEt0O6sr/auuU=; b=nXfahpw5XY6rXffzmnTD3rFaP3R7E+Pcys9+TGDN5ArcKOJ9oHv2vwi5Xv9G+ufem3 NenrEpb0Tx+axHFXL0gDJqT7WMNgz+n0QMFuenFJ118tnBW6gOIzwcml0J3R/FJ1WB3T aU8oDB3p9ypThZVKFWl2goJ9FQgx/Jlfr10nadzCp78wp5S1PFbJERRnlvn1LEpwuJ1Y oLac0Bs5+wi4sE2fSnJkIKIo7LMSsDwn9n5L5+5dYlM6aNrsKpK4Dn89hhpaj4KAnZ+p /nmCOu1ZljjTjw9kEV7xo+nJgtu7VA9y7Or07JGbA+vXZE4mE4SYHMHhYnDWoo7fZrDF IW/Q== 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; bh=1FdWZXkp46/ajuKyKFjHaTT4t79yEHSEt0O6sr/auuU=; b=NGM/2nMtwObquxFZNzAf5baz5W5fbvK2beZABEfnM/XYjhpK3z2qRJ9JNpJjPVWNnl 3ERzG8PyejW/SLbfXBUY4ChpCduChKjrfhAHAcgmW03WrijIS8VwOktDekJwELwfb7Y7 ooZk28UkjmE9IEQ3QaQ/JR7k5OCL6xbcWwGjL9XQrMFRJUrNlXX5i+7HBZwLqsVmJacx qYyC4TvPVcnco1sCKp436Zb2z2nHVDNwdy9jgahM4M0NgBdV+yNY2ioe9qxHmtOp2IRI 1F+XCvo/CFm5z0iEFhBQGX2HCCUt9SmqDfqO90s67Q6dJ4J7VCSgBWgzvtaC2QhKlV+0 U7Jw== X-Gm-Message-State: AFeK/H0MYKYuN1ot4te6lD5VFitDoYiFnl9lHFevDnqwq0MgJ4JNhGLfVpwW9sZjshAN+YRK X-Received: by 10.98.8.74 with SMTP id c71mr34362667pfd.42.1490742794175; Tue, 28 Mar 2017 16:13:14 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::a:d601]) by smtp.gmail.com with ESMTPSA id l9sm9289812pfi.97.2017.03.28.16.13.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 16:13:13 -0700 (PDT) From: Omar Sandoval To: Jens Axboe , linux-block@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH v2 1/3] block: warn if sharing request queue across gendisks Date: Tue, 28 Mar 2017 16:12:15 -0700 Message-Id: <91d938665e5386f10f8756ee8c7ef3e6496ea260.1490742717.git.osandov@fb.com> X-Mailer: git-send-email 2.12.1 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 Now that the remaining drivers have been converted to one request queue per gendisk, let's warn if a request queue gets registered more than once. This will catch future drivers which might do it inadvertently or any old drivers that I may have missed. Signed-off-by: Omar Sandoval --- block/blk-sysfs.c | 7 +++++++ include/linux/blkdev.h | 1 + 2 files changed, 8 insertions(+) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 7f090dd15ca6..833fb7f9ce9d 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -871,6 +871,11 @@ int blk_register_queue(struct gendisk *disk) if (WARN_ON(!q)) return -ENXIO; + WARN_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags), + "%s is registering an already registered queue\n", + kobject_name(&dev->kobj)); + queue_flag_set_unlocked(QUEUE_FLAG_REGISTERED, q); + /* * SCSI probing may synchronously create and destroy a lot of * request_queues for non-existent devices. Shutting down a fully @@ -931,6 +936,8 @@ void blk_unregister_queue(struct gendisk *disk) if (WARN_ON(!q)) return; + queue_flag_clear_unlocked(QUEUE_FLAG_REGISTERED, q); + if (q->mq_ops) blk_mq_unregister_dev(disk_to_dev(disk), q); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1a7dc42a8918..a2dc6b390d48 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -617,6 +617,7 @@ struct request_queue { #define QUEUE_FLAG_STATS 27 /* track rq completion times */ #define QUEUE_FLAG_RESTART 28 /* queue needs restart at completion */ #define QUEUE_FLAG_POLL_STATS 29 /* collecting stats for hybrid polling */ +#define QUEUE_FLAG_REGISTERED 30 /* queue has been registered to a disk */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_STACKABLE) | \