From patchwork Wed Apr 20 00:57:15 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: 12819551 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 377D0C433EF for ; Wed, 20 Apr 2022 00:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348110AbiDTBAM (ORCPT ); Tue, 19 Apr 2022 21:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348108AbiDTBAI (ORCPT ); Tue, 19 Apr 2022 21:00:08 -0400 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A02EB13CEA for ; Tue, 19 Apr 2022 17:57:24 -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=1650416244; x=1681952244; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nuvLET3FkxQ2IhEHfvY2HsBqxfN20BNRsXCgeBTTX/g=; b=cVpbD6YH7G6cB7WHlLAxyQj+c04cDbsiVmjVsBXW/OjoiSgOo70bFB/x XSGn/P8w55H395I/BoVvIyh1G9zQoSy1BSB6Q9kUBZjg/7HOdU5lOQSRe wpDRY3isliwhLWmZ5Hvtal43xEGfEyQInhmpcl3Yp3RG5xdh0HL1s19Hj Xayd3xE26Fulw1jK9NWzc9Oxm7KRQBQwSK0oELDX3p10k/VeOX1FzKpfy NPZ6memS/LGrBmweDNNMVUQ/hpC774B13/d6gf63nY0yVBGtHUxUuRQfp ljrYfy8Xo7GDWtPZRschrBZLEdRMymGvgHAx4y2snGjM7wjyGgTin4FlZ Q==; X-IronPort-AV: E=Sophos;i="5.90,274,1643644800"; d="scan'208";a="302507267" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Apr 2022 08:57:23 +0800 IronPort-SDR: PNkcZfHOurDGJko3a4Y2jy/MRjKt2YjVnpASFYrzOA9vK+zaB8mxOyoiYfw+UI1j4MhW9OyTLj UhlIhyrxzeY4BNnZ6D+9Y6SSt1M5rgDeZ7lfppdUehjTxB58x9XeZWSZuTT8lMoGj4eL21fxR3 kUknLT7WKhCGl+VDxizul1zUkn/a800naFjdIuRNRtp1dPBUFkUNEBxKiJ+9ZCv/eEjhTswZVW GisszcWGqD41NIAO2PPIl21aRytertV5pm+NU2Bw8zIZgvGlK5I6ELECstNjgLrmGaynjfA5Hc 1xfpCa+Qfip5SNK7gQMFbNoo Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 17:27:41 -0700 IronPort-SDR: DiESS+jYYJ0JeYzKhs91GfD4Jh2xhVuWGahpkv3FMKycP/gsri3HqQwH8aq1uCfqvSZ1aTW9bg 5mP9ymbFFI4PE4cSBKcceU6t33F4LEwGIzI/uM+OzeS1cppYuW+GJvm0T6TlfJhmjTxMedWSNI IONMjhaW0Vt2Fj7YrVgdK2C6+Whm/M4COziwFTKnlqXZqS70CagPxseugezReV6HOGHBMrXcgX IgiXX5/pRmSnIahiAEiXYOnkD0CAB1khuR3W4FVhbGRYNjJ+hJ5Lohw6adAWnLR9S+pnlO4qDo Td4= 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 17:57:23 -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 4Kjj1t0yxQz1SHwl for ; Tue, 19 Apr 2022 17:57:22 -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=1650416241; x=1653008242; bh=nuvLET3FkxQ2IhEHfv Y2HsBqxfN20BNRsXCgeBTTX/g=; b=Mi3xm1m1+XNlMT/kpVJM8REw6hKfkGZ+TS kn4cvYXN9IwQKibxrEHatuid7kl4VjVHeeDqXbxmgtnAisxbrgkO8w67l0VxnAcI qvlHVuQZ2+FuJ7XO1aMLM5ZyxKsJF81gOPu+Ly9x05dEnOjwpB71hN2nldKFsrMi y/xjiNi9GeaSBb9Mgtzn7upPSx1BSo6pj1fkjrAFAa6hZpSzp7jHl5mGqEpO01na fbTmV3JB17pDRMub/GMnUnZLKL747gnJqIh/KmtHPNentAHHSkLNVlMU2G/ac6UF XW5RD4F4efH70EqLUhIQcIqXkO/4J/9xURiNzZ7wc5dykmnZ2nRw== 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 VmSHTHYxf6Hx for ; Tue, 19 Apr 2022 17:57:21 -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 4Kjj1s1YtCz1Rwrw; Tue, 19 Apr 2022 17:57:21 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Josef Bacik Subject: [PATCH v2 1/4] block: null_blk: Fix code style issues Date: Wed, 20 Apr 2022 09:57:15 +0900 Message-Id: <20220420005718.3780004-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220420005718.3780004-1-damien.lemoal@opensource.wdc.com> References: <20220420005718.3780004-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 Reviewed-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- 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 Wed Apr 20 00:57:16 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: 12819548 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 E7C74C433FE for ; Wed, 20 Apr 2022 00:57:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233996AbiDTBAJ (ORCPT ); Tue, 19 Apr 2022 21:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343765AbiDTBAH (ORCPT ); Tue, 19 Apr 2022 21:00:07 -0400 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D98E13D01 for ; Tue, 19 Apr 2022 17:57:23 -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=1650416242; x=1681952242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RZlj07dLeyil7KbTI710dFh/tAqPF60wAmdflvFXwJw=; b=Y9gl06TVmZK2uLq51NoA31ofWfemHTNV1Bc0rUzNsBpHKX42kM8JKITZ RjItLtxw3ni/VgGsUUlrsowxQIXQtCIFY3Wmhyyag35fL7KLwhD62q4qn ZIBMyBtg2YgqEOGs1J+aVRQDupHbMEOdPu/jsQ6lHsuJld7opTX+C/AXb 9lqe49eOMowWxE1wx5Q6NqEKFqjwyIdrbqmxKmYwsqxjIMTMbF2YymM6n gprGZ4ZXBvE3qSGUfnl8GZWmQllT2m4YJ7vU1bfAo4/zubcF/87oWU/GO vkeIk5h8joip8xLxrcshOAzUXoIfqzC4gRdzqKQBVguEGIO2A6FQMUWch w==; X-IronPort-AV: E=Sophos;i="5.90,274,1643644800"; d="scan'208";a="198310332" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Apr 2022 08:57:22 +0800 IronPort-SDR: 37TSn9WA9A+dQf3rgvndPZbs4FDgV2POp7yULELoYnGpGy2L/7SMoctpd8wdhemyvxHnBULHuA 0TV0ld894BBxfrONAuQ96VpOe2mM63scAPdwzVLrDTtH9T9F6k53OaLnTNw2/Iiibc8ranh60K 2x+eeKP/ejIkV+z0REaZJaFoEbQbTIEjccjjtQd0f8g8ALYm081/YuS+rWpZ0rmGga0AQgwUFv xyUMLTZWTxwaiGKzZvOJ9UsUU4NxOu742m5i/u7IebB/F4eLqlwacTu7iQiGW1zpFZ9mmn8JLJ BI3eMlMXGdOr3bsuU1nJT4sr Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 19 Apr 2022 17:27:41 -0700 IronPort-SDR: 25JjB3Z4Nbb+N1dCACgeWIcSW9jm4GW/Tp5kiL5COsVOREjv+B1bTKwrCqq2K1Or8oBWDk++qm wto/wtkdzIjk+qZN/WZj9Gq/JdzEC6vOCP3crMfN/9veRZrS8OynErxBZmnT799LW5QlBkARjT B06j0xcdKp/xaeGx/1A6ZLWrGXPnkcXDDOm+DDYrF5IDew6v//KXwR5ZhyM/5GYXHajM16vXhd Cx5l/VHu+XknKqEbnWiVdTqszp3wQVPmRnGASyLCdR7mAiRKIId03yVPMfYtaJk/fRwa2PXqxQ HVM= 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 17:57:24 -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 4Kjj1v03lzz1SHwl for ; Tue, 19 Apr 2022 17:57:23 -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=1650416242; x=1653008243; bh=RZlj07dLeyil7KbTI7 10dFh/tAqPF60wAmdflvFXwJw=; b=HgixLoIMszocxMU6LJ+RIe7PqOC3kwCzF/ WrgKTBFPxzNBv3VroLlOoeySthk2QkrtDwzHHH4TohfckBcOz/fhwzGlaGndbGBk IQKO0UTiRBl2Tv5yVK51v+Iger2iK5QcuiWbyIRQEDbJXQE49IXYAb/kbFzclMIP nxCknW/Ku9uczk0ePD9+/SukQ9iuqTrBLCDE305YP92pJx89AkZhz779u8o+sykM wjc3W0Gi6TwqTq+BmdflEPDQyxCrEY2Q995fmT6oM9jrOe3J0cguqjx8g+ypdLLP vNBWa5jKsDCYTbZPMHINH0JI0agqaQsYVkIQIBMKdJLbTc3zA7Vw== 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 CFa0vhDLkebR for ; Tue, 19 Apr 2022 17:57:22 -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 4Kjj1t0j3Jz1Rvlx; Tue, 19 Apr 2022 17:57:21 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Josef Bacik Subject: [PATCH v2 2/4] block: null_blk: Cleanup device creation and deletion Date: Wed, 20 Apr 2022 09:57:16 +0900 Message-Id: <20220420005718.3780004-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220420005718.3780004-1-damien.lemoal@opensource.wdc.com> References: <20220420005718.3780004-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 Reviewed-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- 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 Wed Apr 20 00:57:17 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: 12819549 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 385ADC433EF for ; Wed, 20 Apr 2022 00:57:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343765AbiDTBAK (ORCPT ); Tue, 19 Apr 2022 21:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347146AbiDTBAI (ORCPT ); Tue, 19 Apr 2022 21:00:08 -0400 Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A04B513DEA for ; Tue, 19 Apr 2022 17:57:24 -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=1650416244; x=1681952244; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uwyOan50nBaMbvW8rMFHvv/sLCGtm5g93jcRVvpeF6A=; b=IPZm1WnFt5ew3Dsz8yf3+/mAXBBvpXRYSThSbc8jjMSWw2+VooqKLvGL l05MyhCKb3u4pLlclLkW0wdc8MzwjD+RrdGSkURErjFCOJKzj07u6U5hx HNmIMon+sWx/2exaDsCietLF9gGbrp2hIwswQT4ebOLUx6Lw9H3dQYD4L qAALiyC5IDKUGKxv+xGvWxG3y+up7+a12u0rsEnxiPdvOD4L9HlE9kuci W4gM+afvnyXS7RBub4x8nzmCBwazsmpSWhdrCQJprF4g9MceztkX8JbUn VwgzsMtE4fQNNFnzERU8/h7irxUcHeph3/d9Z1wX9ZzSfO+fqIoZeE5Pb g==; X-IronPort-AV: E=Sophos;i="5.90,274,1643644800"; d="scan'208";a="310283702" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 20 Apr 2022 08:57:24 +0800 IronPort-SDR: 6/BqO76KR3v9HP6BauTfMDegvI1N9yr9u+Rq7M7LGesI26vB8UIekPp1Y8p/zxLRMQLvkO7pOS MZHyvh0ykuDF5sZitbzNU21aM/GDLDpu7wbIMojtzGaxcsibtyRZc7iH7fM7UjZofllOboc2V/ 8sHWXsnfCJBq4q25Wdf1bX0eqTzKIv0o9vU1ncGqXM9AJNIZ2fzPqCSxoPAWyYRIn3yWc9ojgI J9a+oFMcJocuEJzUaF3fQeLhka7BhD4u5AoARL8hN+EsbKEEZ7alyB/v2Bbff0YuScy3N0E7WZ OZGSMKTC93/WgX+95LomnFf8 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 17:28:28 -0700 IronPort-SDR: BjL9WQ41mFuD7b/lp39JatWHqJ5RZ3nH/t1KZKTZm/D+l5/DDSWvr8DJF91ltgkzacrnOvC1d7 Iua7SheqOmfMJqX+eHe48JGgR6ahmVW+yuYgflS3JsmUI9hXSwKmr8CSUEcPTk7Zo22drFIDJN FWr38SIhflrJAp28v2MHZf/myDkBIpeTAMSuXSS37ENGz6llc+/yL7TVAOLcY2Q2t9ExbgwS+/ RSr8344axDc1dLiDK+5VUhppPCcbcD9h8NHn2ClDOV+IYIiRRNxfyf0mgK3JJ0pJCSmK0hGUNv 94E= 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 17:57:25 -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 4Kjj1v6fRQz1SVp0 for ; Tue, 19 Apr 2022 17:57:23 -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=1650416243; x=1653008244; bh=uwyOan50nBaMbvW8rM FHvv/sLCGtm5g93jcRVvpeF6A=; b=VHUew2JZgR1P9oXo0taJPxAsADA8JDOetw 0ZRG5WeVBuMB28orDp5d2L6mIlXCz80Tj/CZKdISpr3LVzF00pdoebBjHzXbUyXD O6SqDxTXqf8O3bpxTEmZ5c+XSosYAGB7FKrQxEDuybvdyxmAMJ+GklwBe+jSJ+A1 WKRk6j9KQBPAAo+WKwFkFx0AvXGKinGq+4E+MuVHFDmVBcB7qBbV4vPHTg8dzDYt I7HL1vzDUPlQ3U4qrI+WnRt2SaxMWVLn7kZiCN1xf7oIYt9W3r4U7MaimnEj+i63 smU67mLQfHvLb49vlhFKKnbX1P4p8XlQymlmSvpXYbdCFI8X+a1g== 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 VSn79JLUTH4l for ; Tue, 19 Apr 2022 17:57:23 -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 4Kjj1t6cThz1Rwrw; Tue, 19 Apr 2022 17:57:22 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Josef Bacik Subject: [PATCH v2 3/4] block: null_blk: Cleanup messages Date: Wed, 20 Apr 2022 09:57:17 +0900 Message-Id: <20220420005718.3780004-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220420005718.3780004-1-damien.lemoal@opensource.wdc.com> References: <20220420005718.3780004-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use the pr_fmt() macro to 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 Reviewed-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 5 +++++ drivers/block/null_blk/zoned.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 4d6bc94086da..7bc36d5114a9 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -11,6 +11,9 @@ #include #include "null_blk.h" +#undef pr_fmt +#define pr_fmt(fmt) "null_blk: " fmt + #define FREE_BATCH 16 #define TICKS_PER_SEC 50ULL @@ -2071,6 +2074,8 @@ static int null_add_dev(struct nullb_device *dev) list_add_tail(&nullb->list, &nullb_list); mutex_unlock(&lock); + pr_info("disk %s created\n", nullb->disk_name); + return 0; out_cleanup_zone: null_free_zoned_dev(dev); diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index dae54dd1aeac..ed158ea4fdd1 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -6,6 +6,9 @@ #define CREATE_TRACE_POINTS #include "trace.h" +#undef pr_fmt +#define pr_fmt(fmt) "null_blk: " fmt + static inline sector_t mb_to_sects(unsigned long mb) { return ((sector_t)mb * SZ_1M) >> SECTOR_SHIFT; @@ -75,8 +78,8 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) dev->zone_capacity = dev->zone_size; 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); + pr_err("zone capacity (%lu MB) larger than zone size (%lu MB)\n", + dev->zone_capacity, dev->zone_size); return -EINVAL; } From patchwork Wed Apr 20 00:57:18 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: 12819550 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 DCACEC433F5 for ; Wed, 20 Apr 2022 00:57:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347146AbiDTBAL (ORCPT ); Tue, 19 Apr 2022 21:00:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348110AbiDTBAJ (ORCPT ); Tue, 19 Apr 2022 21:00:09 -0400 Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FDB713E0C for ; Tue, 19 Apr 2022 17:57:25 -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=1650416245; x=1681952245; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gG8cNEjHHGS7EhNii3fkPIs1UZgkdOiV/85oPTNQSnA=; b=LfEL0bnJQil7kl9QbH47mxQCx/VBEqtM7lWb82Rfy02TudZuFcTLI1eM aail+NXik2Tc7a1ZQPuL2Xv6XA9Bi5kkmwGdSMqOII+p0NGliTNc3lDjS 3jUcrtKY3QKHqKkwtBKnv6jHulABYPFTselvFYDD1nasAAm1cMPcc6Jb1 Kgx9cFXRj0X0+H11m6dxtfLdM/8/7FveYrvs8421Ii1q1+qqyNbQ0lPF2 bP/zrG35aCQ79JrtBdv7QacnjTd7l42US6Txgi5jB04VfmRD7xsk7BZGH 5j0OoVYDEsqscj/OMgeEFeBz9MZCyLU5KQL5GmdaKjnPhcNzLv1ck4IwL A==; X-IronPort-AV: E=Sophos;i="5.90,274,1643644800"; d="scan'208";a="310283703" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 20 Apr 2022 08:57:24 +0800 IronPort-SDR: +2sXqO0oZQU2vN4+ayAB7qY0CR31mXnD0zODWkauMHiDJUWvPUQbzSSohcNAU2K1hkQKQlaJeo tCudKapyOnIr0EOpFV2Uvm2WOi1z3VPnrY6w8pKB0RqWMLRZKf0Rh3StXuBe2vBDcq9YUYwV2u mLAD0dmc3A8c7q1iaW0Cm9MAjwEezLfLiTmr8cg9nAdjPoiKpq1A+RiDW6lVc3ZWl0sbT91srd auYQB8qnf/857Kms0eohb2Ml45L1Zp/QzOz2IbFsXEJJf05+pY3DSCbFKS0/DLFQGny36xQX+U CNipSfZ74aIM8yTZ5r0yYZUq 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 17:28:29 -0700 IronPort-SDR: tpa8/rRTrb9o00A5aci2bTyRYS+UYqU6BhuS62uonk5tfqUQ0AfS+gufi0LFo/IIbYDuf4mx/G EB4YOw4ed+ke/RMG+vDPyxyfVw7X51AwSdpDjHanIk9lJVLCRGIpeuDdFO9WxpktH9anV7sjdD IjAAny+dkz+Fsb6dIHS0tIn9n3MLBZzieALk9S7gq+w6ihQmrySYVgIEKIsrHjIuhu3plkltYe TyfYcA0+A2u99AVzSDvPfk4fecxgHRVoNPssTCpVnKJlz47o4WCmHiJRBB1OHx8ucFHkX7+C+7 h2M= 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 17:57:25 -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 4Kjj1w5dYQz1SVnx for ; Tue, 19 Apr 2022 17:57:24 -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=1650416244; x=1653008245; bh=gG8cNEjHHGS7EhNii3 fkPIs1UZgkdOiV/85oPTNQSnA=; b=JuIMGY93wTZ8zxFDowLVJ3SWn1bak+T8Gn E94UBtQIQl+Pe4ZKzPdoHINqHAqPr/keTt0WPX+mquE8djnwt1sGsBF9uKhXox+m j/0n9Dnc8Qv7b0H4bzcurqdHSMl/l/yCDJz6gQ18xiUgQNWtqmi2p4yVcucRD8d7 DTvr6dXj8MQpJf83C9LqZXxgCroexBvq7pF3PnJFNcb7+fpTTzGuA+r8yAP/K5Uc 5MtPphr59rvwcTafc0ZVslw98ATo7UPG79x24nNBL3I/dDRssLqip8+5ajwY7I/o PQP2ge1AkLb2m3CsTtpyYrLrzQj4jQFZTNbe95k/oy1csVJIsKAQ== 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 G8AVTSKSg_9S for ; Tue, 19 Apr 2022 17:57:24 -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 4Kjj1v5LKMz1Rvlx; Tue, 19 Apr 2022 17:57:23 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Josef Bacik Subject: [PATCH v2 4/4] block: null_blk: Improve device creation with configfs Date: Wed, 20 Apr 2022 09:57:18 +0900 Message-Id: <20220420005718.3780004-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220420005718.3780004-1-damien.lemoal@opensource.wdc.com> References: <20220420005718.3780004-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 even though /dev/nullb0 was already created by 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 the 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 a new nullb device 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 named "null" but this block device will however not appear under /dev/ since /dev/null already exists. Suggested-by: Joseph Bacik Signed-off-by: Damien Le Moal Reviewed-by: Johannes Thumshirn --- 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 7bc36d5114a9..9ee72f484fc6 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -235,6 +235,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) @@ -563,6 +564,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); @@ -2064,7 +2068,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) @@ -2093,6 +2103,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;