From patchwork Tue Apr 19 11:00:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12817799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F97CC433EF for ; Tue, 19 Apr 2022 11:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350818AbiDSLD0 (ORCPT ); Tue, 19 Apr 2022 07:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349185AbiDSLDZ (ORCPT ); Tue, 19 Apr 2022 07:03:25 -0400 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C57451FA4E for ; Tue, 19 Apr 2022 04:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1650366041; x=1681902041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nuvLET3FkxQ2IhEHfvY2HsBqxfN20BNRsXCgeBTTX/g=; b=QhgF0RB3ZEMtUl447eYnWIOWItiICz4wa1wBXOF8Daa1a9Z8duoXLQNv 8FKut47jTs9i2cOKmb6PFSNPw2E6yIdBceIHakyBmZvAaFiCr2scD7rXK QsWpK//Fppcq/sfMzvG5Qt96WSDxN1eXvJyy78ZhvoNVHkNbJHf9cLc4G l3fa8TpNBLeJK6/l/cOM2XxLzepWdecl1nGGnq4T1IEEtmaFyJBZqwlI5 sKQldAdlwqjy9YFOlygCofkVvMnyn4RybPYfv7Y8Hq7V/OjQ6SW8J8vXW 95KtsXtozlm1kOpsH6NXHcl3t2wP7bvhbD+MXkUKH3T/FAlK5F8ORYcgP Q==; X-IronPort-AV: E=Sophos;i="5.90,272,1643644800"; d="scan'208";a="198252952" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Apr 2022 19:00:41 +0800 IronPort-SDR: 7mPXfHE/dPx+vw1HO4+q3rx/1X6hH2iAsv3HrIFQ6X6WcC6p84WvzaYlUW4ihnoTHxpm5/mVz+ ANJvnI+DeJvRvT0qvgNnch8GXMEEWp2GnSYU/rBwS/HBY0pybHCFGdh+ykBiW75VECaWp0MBDY wbQM7OSbehIz1zNGmq031IKRirOL/JfL07LVTwovsztjQNmJ4JY4he6MYHd1n1ETO+yW94e9qT R/7ck0bi8xPzbMEKKUhItGxtIKLI1LsqtFL8ys/a+uCwt1U3cogQXFbM9ShcNgXcgzg+qnbTNi WNWEclUJbxdI+jCBcv0OpNJP Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 03:31:47 -0700 IronPort-SDR: Xo9D5E5Wy6g0OI5mQ5xcLa3HYsrk4d7ekGNsAUnyKZ6ZEAo/XrrqX1BHwUT0/mNxn5LSNUN6Ws RxRf6JlR6ncp1k2sdfFMkDEn7mFDhrhpckdEz5uLQ6sU1hdL43xQjXQojGZZMJrt6hvMI7OhfU QOSMl7ADoyuh+hRBww22QhpVS6CC+gjRK4bNn96FoEloilon+esgI98kgJgKJ+zJL4T2qx4CYu yhcMnDpn1kRCRtELRXYjjMz9TnRtNOPVjgmNU4NBchgVDuVKjZB4xKQR+Usw1XsoLpOnwP6d9e lvU= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 04:00:43 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4KjLST6fGFz1SHwl for ; Tue, 19 Apr 2022 04:00:41 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1650366041; x=1652958042; bh=nuvLET3FkxQ2IhEHfv Y2HsBqxfN20BNRsXCgeBTTX/g=; b=R/im/0bZoTufQPi2wYWuv6X1CyQzRiKBNR HcWSJdWI/DGnInSMbxvojCE++MtqeyWf8pBZA0D5InNbdD2NMl6UGnwKybkcvKol Ar7WbQFB+8YISYLHWS9ZiiqSjLc9h/JQwhzzzOiRGGjlNlAy/ph2EALc8xtpjElF F9atDve6gcZh9Wod6fcgi/D2zQVQ+ES1kqAGR0U/V3eXM7yNtC0txwDczJdK94iW 6c3DDKAHLh5gkR9OP7u4K8fw/L7t4sBMH6qEJAxTo58sLbFsIGlpqpyrRl4adh3y SWBJ2eDZfsXlYKSQJq1nKKjvr9w5FuohjsbEhFchLbCq7zu3EmYA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Gmp0GxyN6oUy for ; Tue, 19 Apr 2022 04:00:41 -0700 (PDT) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4KjLSS6zTsz1Rwrw; Tue, 19 Apr 2022 04:00:40 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 1/4] block: null_blk: Fix code style issues Date: Tue, 19 Apr 2022 20:00:35 +0900 Message-Id: <20220419110038.3728406-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419110038.3728406-1-damien.lemoal@opensource.wdc.com> References: <20220419110038.3728406-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Fix message grammar and code style issues (brackets and indentation) in null_init(). Signed-off-by: Damien Le Moal --- drivers/block/null_blk/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index c441a4972064..1aa4897685f6 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -2113,19 +2113,21 @@ static int __init null_init(void) } if (g_queue_mode == NULL_Q_RQ) { - pr_err("legacy IO path no longer available\n"); + pr_err("legacy IO path is no longer available\n"); return -EINVAL; } + if (g_queue_mode == NULL_Q_MQ && g_use_per_node_hctx) { if (g_submit_queues != nr_online_nodes) { pr_warn("submit_queues param is set to %u.\n", - nr_online_nodes); + nr_online_nodes); g_submit_queues = nr_online_nodes; } - } else if (g_submit_queues > nr_cpu_ids) + } else if (g_submit_queues > nr_cpu_ids) { g_submit_queues = nr_cpu_ids; - else if (g_submit_queues <= 0) + } else if (g_submit_queues <= 0) { g_submit_queues = 1; + } if (g_queue_mode == NULL_Q_MQ && shared_tags) { ret = null_init_tag_set(NULL, &tag_set); From patchwork Tue Apr 19 11:00:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12817800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1D7BC4332F for ; Tue, 19 Apr 2022 11:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349185AbiDSLD0 (ORCPT ); Tue, 19 Apr 2022 07:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350816AbiDSLDZ (ORCPT ); Tue, 19 Apr 2022 07:03:25 -0400 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 843141BE91 for ; Tue, 19 Apr 2022 04:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1650366042; x=1681902042; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RZlj07dLeyil7KbTI710dFh/tAqPF60wAmdflvFXwJw=; b=oC3CT6CvVVMJPEV+MpLdCrZTJQBpY/1erWt/Zchh4sjw6pMjKBcD1IOG VtFrveCAZgnFQ+/LCfaMZt/IyyuHOFMGFTKPGSZzHgHwxXYOe+eBB5AZW uYReHsMXBFb2aSZk7CTRWcOxwLW9h2kfqFhmtUeFkQJ58WlKQGuAUwyHn WrS7GaL0kz8Pk0BxMFlq6cRXU0kiizol8o7qw+GZ86SGrm6VrN4OrhQkr 0IzClTQg/nmfos2vgWmA0D7h/ENHz8LQ18uGypbDf214TmfKXLeKStYnO mLIwg+klDPWnXeu0JPDIC1kqf75/tT05VnT8oehTQiqDI6ljk3Qc6HshN w==; X-IronPort-AV: E=Sophos;i="5.90,272,1643644800"; d="scan'208";a="198252954" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Apr 2022 19:00:41 +0800 IronPort-SDR: 1GZt4T8mBEzhXfwsfKiDre1Lw0O3UTFjgvBbMjyvCfp59jwxKJ99yqrI6yCXpNmh6cfmCB32Ci CcPI01epmpTkokov8+HH3t6sUjtgMMxv8bhxQSa1/WSgaNLfUJ57gkWjoJHq/fT12fnL4EarZj 1qyqGwoI28eipfFlHPE4gv1GVvUlk+GaI/fnIrxB82JQYEbNl28bm0NH5ObzQdVsdE/z6i7INs wuRxb4TmYXApaNLs8/4kntNqzCvKGf4ACAtK+RjN32BHnrS4bxu1i5hsK34qBCanBJ5cKlLDFG gNwt/6y9QNpSY1Sfm1t0nVkd Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 03:31:48 -0700 IronPort-SDR: JpHc2VBjagl6vmJBbSlh2ozzF2lfkxYwwTiflGZVJz/vrBb7eLy5tdHNA+ZUQ3zC6QvBHV14Dp 4gMrdi3KT1malZiaQJTcLmYRotKeMKWUIGkJso4irt4m9cBba28YlnpgUhNkzS2dKHcdEcmeRC DHGCeS38w4Px9xU0C26g9Y73QEVTyPhU524Xv9KkUAzlTHK0iQNNTkH1sV6Cxg74s8gxIFKUtf R3QuLr26PW7E+JO7oTxVeKahkownCRNERGxaNFQygQEFgtlvp+mThqaNQiLRoDP+d1UmmkswYO mmo= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 04:00:44 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4KjLSV66Z2z1SVp0 for ; Tue, 19 Apr 2022 04:00:42 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1650366042; x=1652958043; bh=RZlj07dLeyil7KbTI7 10dFh/tAqPF60wAmdflvFXwJw=; b=D/g5ffs7os6/YV7Csk6BB7iXVPXfk3zexI y0CWKn8L9cEFKPBzWPlNkCqQuA9zfiefjZrPFcaw+1xHnFON9/UfCmQwKPK0YTTx xQGWvobZOdR80bD9ZlfRkXvG5dbr4swGZKRiBuJ5R7KVRfYpvwjhLYFu9Mqsq512 4gcgCEUBUDLQ/z3tbdpCnnSQgTch+mJCMjFwa6QIpee6I2eZNteESsoBuagPj9UY GS7w3P5M1i5nY7CdSkkTx2y/4ZOJxUYJaTzS3uGEhN/finFM31V7+57HEeGGiCSQ g/Ymfwx2w5g1z63LsmEpcmv45P0H17oAJuMbVCNZTPwNR88GBDgA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id oAYuX52K1H3g for ; Tue, 19 Apr 2022 04:00:42 -0700 (PDT) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4KjLST5wVsz1Rvlx; Tue, 19 Apr 2022 04:00:41 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 2/4] block: null_blk: Cleanup device creation and deletion Date: Tue, 19 Apr 2022 20:00:36 +0900 Message-Id: <20220419110038.3728406-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419110038.3728406-1-damien.lemoal@opensource.wdc.com> References: <20220419110038.3728406-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Introduce the null_create_dev() and null_destroy_dev() helper functions to respectivel create nullb devices on modprobe and destroy them on rmmod. The null_destroy_dev() helper avoids duplicated code in the null_init() and null_exit() functions for deleting devices. Signed-off-by: Damien Le Moal --- drivers/block/null_blk/main.c | 48 ++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 1aa4897685f6..4d6bc94086da 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -2088,12 +2088,37 @@ static int null_add_dev(struct nullb_device *dev) return rv; } +static int null_create_dev(void) +{ + struct nullb_device *dev; + int ret; + + dev = null_alloc_dev(); + if (!dev) + return -ENOMEM; + + ret = null_add_dev(dev); + if (ret) { + null_free_dev(dev); + return ret; + } + + return 0; +} + +static void null_destroy_dev(struct nullb *nullb) +{ + struct nullb_device *dev = nullb->dev; + + null_del_dev(nullb); + null_free_dev(dev); +} + static int __init null_init(void) { int ret = 0; unsigned int i; struct nullb *nullb; - struct nullb_device *dev; if (g_bs > PAGE_SIZE) { pr_warn("invalid block size\n"); @@ -2151,16 +2176,9 @@ static int __init null_init(void) } for (i = 0; i < nr_devices; i++) { - dev = null_alloc_dev(); - if (!dev) { - ret = -ENOMEM; - goto err_dev; - } - ret = null_add_dev(dev); - if (ret) { - null_free_dev(dev); + ret = null_create_dev(); + if (ret) goto err_dev; - } } pr_info("module loaded\n"); @@ -2169,9 +2187,7 @@ static int __init null_init(void) err_dev: while (!list_empty(&nullb_list)) { nullb = list_entry(nullb_list.next, struct nullb, list); - dev = nullb->dev; - null_del_dev(nullb); - null_free_dev(dev); + null_destroy_dev(nullb); } unregister_blkdev(null_major, "nullb"); err_conf: @@ -2192,12 +2208,8 @@ static void __exit null_exit(void) mutex_lock(&lock); while (!list_empty(&nullb_list)) { - struct nullb_device *dev; - nullb = list_entry(nullb_list.next, struct nullb, list); - dev = nullb->dev; - null_del_dev(nullb); - null_free_dev(dev); + null_destroy_dev(nullb); } mutex_unlock(&lock); From patchwork Tue Apr 19 11:00:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12817801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C486BC43217 for ; Tue, 19 Apr 2022 11:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350816AbiDSLD1 (ORCPT ); Tue, 19 Apr 2022 07:03:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242912AbiDSLD0 (ORCPT ); Tue, 19 Apr 2022 07:03:26 -0400 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FE4C1BE91 for ; Tue, 19 Apr 2022 04:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1650366043; x=1681902043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+oJaf88d92qpqzFJriWCkzPVYda+45p1JlUw5So5umk=; b=WkAUo3tDmS54QELhEFXhpz37tsFvFYOCLs3xgb6veWEBaD5ovlFTQ78c CLi+5E4LXAiFq3JnmKaDpXIkF3rkcksRunGe1y89ZXe37sFar/LqoCnHe 7epGK9O7TG152+h9m5DoUvJ3SGuy+TVxs8N7I3oiOd6CM8KRZv7chIWE7 rXci2WSzk7IL/v+nihxygIrJBxLvx9AkGlo0YxcJWifc+G5T49AcziJSW 3TQKT+DQtIX95smEwLO4ybKVYHdmIe+XoH+KemRZUMxlvR/tECpAL9zYs GynTUkoflJ1PZ+nN7VBnn5Z5eVP74s4+fb+RnmvemnPJrKYgnNqnFcerw w==; X-IronPort-AV: E=Sophos;i="5.90,272,1643644800"; d="scan'208";a="198252960" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Apr 2022 19:00:42 +0800 IronPort-SDR: uDkDOkSRvzuSfbfSQCylHSfQ0rzv/3mtMiUH043KsnryWG7ZUNT1sAMVWmjkdRkcb+ocH/loFU IlzVY2o5MGIpy8IJ5z0D3vL1+13kwB9g/lPxb+eIZgAA5v1ROQABWq2VT3879j4AU/k78NXkol +kiVFAU/jg5tbjDre3/w+/ML6GPfUOUMurOp8a+rn1i6kzrDXT51dcYo1n35A+ksZemQx+0Ohu l5ePjoHWonmNXt7FbK05zEV5/Fl5Xh7UN7kN5Q0TbqW7Mr98HwpE+p3GYXj3u45bpgrLNeiCkO a8HRES7kpEAbLVsyhqpfFtqs Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 03:31:49 -0700 IronPort-SDR: k9cPENHuPp19VTHpholr6/e/GInt0lpq/vs4sGOFEozZ6DEeTwIYxEQyLwuYVwZyIrJ3r6eEO8 tkc5D5p1b956Dfl7jzlnNcVhC7DJBUNfb30r19o4vSb57ou6jNnW2Kclx6B/BMVVcbzG25u5wA GJEIF24cDymwwR+xvJCzi8EqtQ5CtUFRzh8Wd5d5P/rB5RsC1VAnznKaw7vhUl1le7ar9EGIoq s+eFG9j4Pm7QK5yRIvCFQUVK9Q42WLlyenR298L63D9QUirKG4bVoJHlh0HFRyxKHE93z3J8bk AQ0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 04:00:45 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4KjLSW6Vgwz1SVp0 for ; Tue, 19 Apr 2022 04:00:43 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1650366043; x=1652958044; bh=+oJaf88d92qpqzFJri WCkzPVYda+45p1JlUw5So5umk=; b=d0jDMqvzd0kQnOCPtF9qSPpnoPtGuiN8k0 pZ21Qr4IjdI+I9S1Ft1zp1tS/cx13JcSGif0ne7a8/xY997yjQgW2mzghu2KjMUK AWS0NLQX1tsvj0QR1LpgLu0FHgvW9VSHwRsJZBy7a2HSxLjwimKq247OR3BJ14QM FWGHsda2Fi2qIKZJSVhdrJohoxgssoAnFi7/EbyDDTiENFtojvyMnTtItmWsvOey KIZXiMf07w82mCq0WPMLwF3VKK0dNOqOzKzEt2XrD2Ce7y5dURBwmkwbQ2uOMsFA ImeAmZFtLdclAUH6ssHF7qWEwyqkWAVezTMcxE0iAVrrnNZGoNIg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id nLe6i39wIwwI for ; Tue, 19 Apr 2022 04:00:43 -0700 (PDT) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4KjLSV4y0bz1Rwrw; Tue, 19 Apr 2022 04:00:42 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 3/4] block: null_blk: Cleanup messages Date: Tue, 19 Apr 2022 20:00:37 +0900 Message-Id: <20220419110038.3728406-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419110038.3728406-1-damien.lemoal@opensource.wdc.com> References: <20220419110038.3728406-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Prefix all null_blk pr_xxx() messages with "null_blk:" to clarify which module is printing the messages. Also add a pr_info() message in null_add_dev() to print the name of a newly created disk. Signed-off-by: Damien Le Moal --- drivers/block/null_blk/main.c | 29 ++++++++++++++++------------- drivers/block/null_blk/zoned.c | 14 +++++++------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 4d6bc94086da..96b6eb4ca60a 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1521,7 +1521,7 @@ static int null_map_queues(struct blk_mq_tag_set *set) submit_queues = dev->prev_submit_queues; poll_queues = dev->prev_poll_queues; } else { - pr_warn("tag set has unexpected nr_hw_queues: %d\n", + pr_warn("null_blk: tag set has unexpected nr_hw_queues: %d\n", set->nr_hw_queues); return -EINVAL; } @@ -1582,7 +1582,7 @@ static enum blk_eh_timer_return null_timeout_rq(struct request *rq, bool res) struct blk_mq_hw_ctx *hctx = rq->mq_hctx; struct nullb_cmd *cmd = blk_mq_rq_to_pdu(rq); - pr_info("rq %p timed out\n", rq); + pr_info("null_blk: rq %p timed out\n", rq); if (hctx->type == HCTX_TYPE_POLL) { struct nullb_queue *nq = hctx->driver_data; @@ -1754,13 +1754,13 @@ static void null_config_discard(struct nullb *nullb) if (!nullb->dev->memory_backed) { nullb->dev->discard = false; - pr_info("discard option is ignored without memory backing\n"); + pr_info("null_blk: discard option is ignored without memory backing\n"); return; } if (nullb->dev->zoned) { nullb->dev->discard = false; - pr_info("discard option is ignored in zoned mode\n"); + pr_info("null_blk: discard option is ignored in zoned mode\n"); return; } @@ -1932,7 +1932,7 @@ static int null_validate_conf(struct nullb_device *dev) if (dev->zoned && (!dev->zone_size || !is_power_of_2(dev->zone_size))) { - pr_err("zone_size must be power-of-two\n"); + pr_err("null_blk: zone_size must be power-of-two\n"); return -EINVAL; } @@ -2071,6 +2071,8 @@ static int null_add_dev(struct nullb_device *dev) list_add_tail(&nullb->list, &nullb_list); mutex_unlock(&lock); + pr_info("null_blk: disk %s created\n", nullb->disk_name); + return 0; out_cleanup_zone: null_free_zoned_dev(dev); @@ -2121,30 +2123,31 @@ static int __init null_init(void) struct nullb *nullb; if (g_bs > PAGE_SIZE) { - pr_warn("invalid block size\n"); - pr_warn("defaults block size to %lu\n", PAGE_SIZE); + pr_warn("null_blk: invalid block size\n"); + pr_warn("null_blk: defaults block size to %lu\n", PAGE_SIZE); g_bs = PAGE_SIZE; } if (g_max_sectors > BLK_DEF_MAX_SECTORS) { - pr_warn("invalid max sectors\n"); - pr_warn("defaults max sectors to %u\n", BLK_DEF_MAX_SECTORS); + pr_warn("null_blk: invalid max sectors\n"); + pr_warn("null_blk: defaults max sectors to %u\n", + BLK_DEF_MAX_SECTORS); g_max_sectors = BLK_DEF_MAX_SECTORS; } if (g_home_node != NUMA_NO_NODE && g_home_node >= nr_online_nodes) { - pr_err("invalid home_node value\n"); + pr_err("null_blk: invalid home_node value\n"); g_home_node = NUMA_NO_NODE; } if (g_queue_mode == NULL_Q_RQ) { - pr_err("legacy IO path is no longer available\n"); + pr_err("null_blk: legacy IO path is no longer available\n"); return -EINVAL; } if (g_queue_mode == NULL_Q_MQ && g_use_per_node_hctx) { if (g_submit_queues != nr_online_nodes) { - pr_warn("submit_queues param is set to %u.\n", + pr_warn("null_blk: submit_queues param is set to %u.\n", nr_online_nodes); g_submit_queues = nr_online_nodes; } @@ -2181,7 +2184,7 @@ static int __init null_init(void) goto err_dev; } - pr_info("module loaded\n"); + pr_info("null_blk: module loaded\n"); return 0; err_dev: diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index dae54dd1aeac..f7114a16a342 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -63,11 +63,11 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) unsigned int i; if (!is_power_of_2(dev->zone_size)) { - pr_err("zone_size must be power-of-two\n"); + pr_err("null_blk: zone_size must be power-of-two\n"); return -EINVAL; } if (dev->zone_size > dev->size) { - pr_err("Zone size larger than device capacity\n"); + pr_err("null_blk: Zone size larger than device capacity\n"); return -EINVAL; } @@ -76,7 +76,7 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) if (dev->zone_capacity > dev->zone_size) { pr_err("null_blk: zone capacity (%lu MB) larger than zone size (%lu MB)\n", - dev->zone_capacity, dev->zone_size); + dev->zone_capacity, dev->zone_size); return -EINVAL; } @@ -95,24 +95,24 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) if (dev->zone_nr_conv >= dev->nr_zones) { dev->zone_nr_conv = dev->nr_zones - 1; - pr_info("changed the number of conventional zones to %u", + pr_info("null_blk: changed the number of conventional zones to %u", dev->zone_nr_conv); } /* Max active zones has to be < nbr of seq zones in order to be enforceable */ if (dev->zone_max_active >= dev->nr_zones - dev->zone_nr_conv) { dev->zone_max_active = 0; - pr_info("zone_max_active limit disabled, limit >= zone count\n"); + pr_info("null_blk: zone_max_active limit disabled, limit >= zone count\n"); } /* Max open zones has to be <= max active zones */ if (dev->zone_max_active && dev->zone_max_open > dev->zone_max_active) { dev->zone_max_open = dev->zone_max_active; - pr_info("changed the maximum number of open zones to %u\n", + pr_info("null_blk: changed the maximum number of open zones to %u\n", dev->nr_zones); } else if (dev->zone_max_open >= dev->nr_zones - dev->zone_nr_conv) { dev->zone_max_open = 0; - pr_info("zone_max_open limit disabled, limit >= zone count\n"); + pr_info("null_blk: zone_max_open limit disabled, limit >= zone count\n"); } dev->need_zone_res_mgmt = dev->zone_max_active || dev->zone_max_open; dev->imp_close_zone_no = dev->zone_nr_conv; From patchwork Tue Apr 19 11:00:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12817802 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7058CC433F5 for ; Tue, 19 Apr 2022 11:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242912AbiDSLD2 (ORCPT ); Tue, 19 Apr 2022 07:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350821AbiDSLD1 (ORCPT ); Tue, 19 Apr 2022 07:03:27 -0400 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AADC1FA4E for ; Tue, 19 Apr 2022 04:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1650366043; x=1681902043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AO7XZBEhi1By4NanAu/ixvqdG8OOolfgUjOvr2Ll2gE=; b=pD/E0n4ZnnVigxRHACbV48Pa5fpu6m29lqQAivI6gXpaShDmNx3ZQtwK EuBOEbQus7gDrooCJmaLDje1/Piq+QYuBzMKjLBF/xU2YTJhEDb0mdUT8 ytdROIROFOZBwvdFn+06dXR2vBCsGy83ZWmRlop19gJrZ0AUV+59qAhRl RjaruaeC9nyt8oP049WASc/+DZaABGx0/6k6+eDEHv94QdmczqqPReq23 56m+LNqPIlWkKGB+HeLRR79P0ODmoxHx6J1jDFD8ybT+qapPLTZg1tgHi /MZWVxZpxoj1ieO/tX3fyBaTcLXRlkEZoECVuNU39tWZTFnZVkS+cBJTn g==; X-IronPort-AV: E=Sophos;i="5.90,272,1643644800"; d="scan'208";a="198252961" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Apr 2022 19:00:43 +0800 IronPort-SDR: lii3IllGKbnl4DEr7GN7QKcUZTnvzlZWKxczOs1ctoUdU3r+t1onX5wrRDf1oJGZHGwu0QZG9m FcqqKyZZpogymRPaIS+/u5T60NKOtt9PXkNI/2baQ15Ij4oGjju7zsz4J2xbqwsmoPtFOpAAk5 amgB8uEh1UH4ehO9UMiqOvtv1T97vBmYM+MGvQRhRe3jRsOuiBxKqos0mxbaeIuFo+LimGXSik l4B2czLVsLcN3fVnjhSxs/rJeSzyW/3tuvqL0LtKYd7sn2wvo4I5IyvyAGsMNiLSbD1Jqpj7c0 BHK7m+75EsbprLxcn5c2yTok Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 03:31:50 -0700 IronPort-SDR: sHAFCa4Z2VXgltVU3RcrkPtY1lzI4m1MWT4lY3bUBjnBhYmi5JVp/yoGn3xoRl0PFMU+0Qtfer aJN7rf7zkU4MTb2yzhw+2tuD/QX1wSCjpdvkuzH5e9Lc4McRN4Sq9F4U2I1qHCE51cvi7SB/kV S/Yx4q6CDCFe6Mdx9NcxRDcR/hMKZYyCduDGiT3gsrBlwZyQdCsnacVqQNdji8CJq6YkQPV2M6 RO1lG/YAi22UWOuTQkcKkTUJ6p7TbZpYZh5Nefz/x/NB7X67iJshuoWCLPKkfVeuBeCIQguVqO DJ0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 04:00:45 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4KjLSX3tT7z1Rwrw for ; Tue, 19 Apr 2022 04:00:44 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1650366044; x=1652958045; bh=AO7XZBEhi1By4NanAu /ixvqdG8OOolfgUjOvr2Ll2gE=; b=BfDhITdlCIK/EQoRlrpSo2oPfQfxIU2w8q KcWKLuTSzszt9Cw2hk3Kx1Y59QHAf0BIvEXRBtmD3jUlIl6cZRXXesmjbApPLVdt rd+BEpcy9c1udY/yNB/VQd8ztNckzxhScBBr4CHTlqQgbJyGsfwPI8xPL+fHABfL Xc+crn6hS5/hh5p9TzesPEHcXB/0HlhR+ZpMoBpwX2dOiKE4h682H48sr7R5Y/ZK NpoJHWsWP+4Ziy303/9YWS18N60icHFqD1WuXzm8397lF/rlJ3xhbTPn68sYJNu+ 1R/8qkFU3AjMPKvzqviAYLgE4NZvyNkVMmjZrHKTI1WS0nhdCi4g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6XVBuiwTdvll for ; Tue, 19 Apr 2022 04:00:44 -0700 (PDT) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4KjLSW42n1z1Rvlx; Tue, 19 Apr 2022 04:00:43 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 4/4] block: null_blk: Improve device creation with configfs Date: Tue, 19 Apr 2022 20:00:38 +0900 Message-Id: <20220419110038.3728406-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419110038.3728406-1-damien.lemoal@opensource.wdc.com> References: <20220419110038.3728406-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Currently, the directory name used to create a nullb device through sysfs is not used as the device name, potentially causing headaches for users if devices are already created through the modprobe operation withe the nr_device module parameter not set to 0. E.g. a user can do "mkdir /sys/kernel/config/nullb/nullb0" to create a nullb device while /dev/nullb0 wasalready created from modprobe. In this case, the configfs nullb device will be named nullb1, causing confusion for the user. Simplify this by using the configfs directory name as the nullb device name, always, unless another nullb device is already using the same name. E.g. if modprobe created nullb0, then: $ mkdir /sys/kernel/config/nullb/nullb0 mkdir: cannot create directory '/sys/kernel/config/nullb/nullb0': File exists will be reported to th user. To implement this, the function null_find_dev_by_name() is added to check for the existence of a nullb device with the name used for a new configfs device directory. nullb_group_make_item() uses this new function to check if the directory name can be used as the disk name. Finally, null_add_dev() is modified to use the device config item name as the disk name for new nullb device, for devices created using configfs. The naming of devices created though modprobe remains unchanged. Of note is that it is possible for a user to create through configfs a nullb device with the same name as an existing device. E.g. $ mkdir /sys/kernel/config/nullb/null will successfully create the nullb device "null" but this device will however not appear under /dev/ since /dev/null already exists. Suggested-by: Joseph Bacik Signed-off-by: Damien Le Moal --- drivers/block/null_blk/main.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 96b6eb4ca60a..49d89ae013de 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -232,6 +232,7 @@ static struct nullb_device *null_alloc_dev(void); static void null_free_dev(struct nullb_device *dev); static void null_del_dev(struct nullb *nullb); static int null_add_dev(struct nullb_device *dev); +static struct nullb *null_find_dev_by_name(const char *name); static void null_free_device_storage(struct nullb_device *dev, bool is_cache); static inline struct nullb_device *to_nullb_device(struct config_item *item) @@ -560,6 +561,9 @@ config_item *nullb_group_make_item(struct config_group *group, const char *name) { struct nullb_device *dev; + if (null_find_dev_by_name(name)) + return ERR_PTR(-EEXIST); + dev = null_alloc_dev(); if (!dev) return ERR_PTR(-ENOMEM); @@ -2061,7 +2065,13 @@ static int null_add_dev(struct nullb_device *dev) null_config_discard(nullb); - sprintf(nullb->disk_name, "nullb%d", nullb->index); + if (config_item_name(&dev->item)) { + /* Use configfs dir name as the device name */ + snprintf(nullb->disk_name, sizeof(nullb->disk_name), + "%s", config_item_name(&dev->item)); + } else { + sprintf(nullb->disk_name, "nullb%d", nullb->index); + } rv = null_gendisk_register(nullb); if (rv) @@ -2090,6 +2100,22 @@ static int null_add_dev(struct nullb_device *dev) return rv; } +static struct nullb *null_find_dev_by_name(const char *name) +{ + struct nullb *nullb = NULL, *nb; + + mutex_lock(&lock); + list_for_each_entry(nb, &nullb_list, list) { + if (strcmp(nb->disk_name, name) == 0) { + nullb = nb; + break; + } + } + mutex_unlock(&lock); + + return nullb; +} + static int null_create_dev(void) { struct nullb_device *dev;