From patchwork Wed Sep 11 14:46:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 11141253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1EE791395 for ; Wed, 11 Sep 2019 14:47:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 065C020644 for ; Wed, 11 Sep 2019 14:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727581AbfIKOrr (ORCPT ); Wed, 11 Sep 2019 10:47:47 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56894 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbfIKOrr (ORCPT ); Wed, 11 Sep 2019 10:47:47 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id 467DE260785 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: linux-block@vger.kernel.org, linux-doc@vger.kernel.org Cc: corbet@lwn.net, axboe@kernel.dk, m@bjorling.me, kernel@collabora.com, krisman@collabora.com, =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH 1/3] docs: block: null_blk: enhance document style Date: Wed, 11 Sep 2019 11:46:34 -0300 Message-Id: <20190911144636.226945-1-andrealmeid@collabora.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use proper ReST syntax for chapters. Add more information to enhance standardization in the file and to make the rendering more homogeneous. Add a SPDX identifier. Mark single-queue mode as deprecated. Signed-off-by: André Almeida --- I've asked the file creator (Matias Bjørling ), and he confirmed that I could use GPL-2.0 for this file. Documentation/block/null_blk.rst | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Documentation/block/null_blk.rst b/Documentation/block/null_blk.rst index 31451d80783c..edbbab2f12f8 100644 --- a/Documentation/block/null_blk.rst +++ b/Documentation/block/null_blk.rst @@ -1,19 +1,16 @@ +.. SPDX-License-Identifier: GPL-2.0 + ======================== Null block device driver ======================== -1. Overview -=========== +Overview +======== -The null block device (/dev/nullb*) is used for benchmarking the various +The null block device (``/dev/nullb*``) is used for benchmarking the various block-layer implementations. It emulates a block device of X gigabytes in size. -The following instances are possible: - - Single-queue block-layer - - - Request-based. - - Single submission queue per device. - - Implements IO scheduling algorithms (CFQ, Deadline, noop). +It does not execute any read/write operation, just mark them as complete in +the request queue. The following instances are possible: Multi-queue block-layer @@ -27,15 +24,15 @@ The following instances are possible: All of them have a completion queue for each core in the system. -2. Module parameters applicable for all instances -================================================= +Module parameters +================= queue_mode=[0-2]: Default: 2-Multi-queue Selects which block-layer the module should instantiate with. = ============ 0 Bio-based - 1 Single-queue + 1 Single-queue (deprecated) 2 Multi-queue = ============ @@ -67,7 +64,7 @@ irqmode=[0-2]: Default: 1-Soft-irq completion_nsec=[ns]: Default: 10,000ns Combined with irqmode=2 (timer). The time each completion event must wait. -submit_queues=[1..nr_cpus]: +submit_queues=[1..nr_cpus]: Default: 1 The number of submission queues attached to the device driver. If unset, it defaults to 1. For multi-queue, it is ignored when use_per_node_hctx module parameter is 1. @@ -75,9 +72,11 @@ submit_queues=[1..nr_cpus]: hw_queue_depth=[0..qdepth]: Default: 64 The hardware queue depth of the device. -III: Multi-queue specific parameters +Multi-queue specific parameters +------------------------------- use_per_node_hctx=[0/1]: Default: 0 + Number of hardware context queues. = ===================================================================== 0 The number of submit queues are set to the value of the submit_queues @@ -87,6 +86,7 @@ use_per_node_hctx=[0/1]: Default: 0 = ===================================================================== no_sched=[0/1]: Default: 0 + Enable/disable the io scheduler. = ====================================== 0 nullb* use default blk-mq io scheduler @@ -94,6 +94,7 @@ no_sched=[0/1]: Default: 0 = ====================================== blocking=[0/1]: Default: 0 + Blocking behavior of the request queue. = =============================================================== 0 Register as a non-blocking blk-mq driver device. @@ -103,6 +104,7 @@ blocking=[0/1]: Default: 0 = =============================================================== shared_tags=[0/1]: Default: 0 + Sharing tags between devices. = ================================================================ 0 Tag set is not shared. @@ -111,6 +113,7 @@ shared_tags=[0/1]: Default: 0 = ================================================================ zoned=[0/1]: Default: 0 + Device is a random-access or a zoned block device. = ====================================================================== 0 Block device is exposed as a random-access block device. From patchwork Wed Sep 11 14:46:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 11141255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBFDD1395 for ; Wed, 11 Sep 2019 14:47:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D198D20838 for ; Wed, 11 Sep 2019 14:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728032AbfIKOrw (ORCPT ); Wed, 11 Sep 2019 10:47:52 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56902 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbfIKOrw (ORCPT ); Wed, 11 Sep 2019 10:47:52 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id D8DA2260B29 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: linux-block@vger.kernel.org, linux-doc@vger.kernel.org Cc: corbet@lwn.net, axboe@kernel.dk, m@bjorling.me, kernel@collabora.com, krisman@collabora.com, =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH 2/3] null_blk: fix module name at log message Date: Wed, 11 Sep 2019 11:46:35 -0300 Message-Id: <20190911144636.226945-2-andrealmeid@collabora.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190911144636.226945-1-andrealmeid@collabora.com> References: <20190911144636.226945-1-andrealmeid@collabora.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The name of the module is "null_blk", not "null". Make `pr_info()` follow the pattern of `pr_err()` log messages. Signed-off-by: André Almeida --- drivers/block/null_blk_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 99328ded60d1..7bc553ff7407 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1311,7 +1311,7 @@ static bool should_requeue_request(struct request *rq) static enum blk_eh_timer_return null_timeout_rq(struct request *rq, bool res) { - pr_info("null: rq %p timed out\n", rq); + pr_info("null_blk: rq %p timed out\n", rq); blk_mq_complete_request(rq); return BLK_EH_DONE; } @@ -1803,7 +1803,7 @@ static int __init null_init(void) } } - pr_info("null: module loaded\n"); + pr_info("null_blk: module loaded\n"); return 0; err_dev: From patchwork Wed Sep 11 14:46:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 11141257 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5870B1395 for ; Wed, 11 Sep 2019 14:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 370B52081B for ; Wed, 11 Sep 2019 14:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbfIKOr4 (ORCPT ); Wed, 11 Sep 2019 10:47:56 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56910 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728181AbfIKOr4 (ORCPT ); Wed, 11 Sep 2019 10:47:56 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id A9A02260785 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: linux-block@vger.kernel.org, linux-doc@vger.kernel.org Cc: corbet@lwn.net, axboe@kernel.dk, m@bjorling.me, kernel@collabora.com, krisman@collabora.com, =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH 3/3] null_blk: validated the number of devices Date: Wed, 11 Sep 2019 11:46:36 -0300 Message-Id: <20190911144636.226945-3-andrealmeid@collabora.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190911144636.226945-1-andrealmeid@collabora.com> References: <20190911144636.226945-1-andrealmeid@collabora.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org There is no sense defining a negative number of devices, so change the type to unsigned. If the number of devices is 0, it is impossible to the userspace interact with the module, so there is no reasoning in loading it. Signed-off-by: André Almeida --- drivers/block/null_blk_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 7bc553ff7407..ab4b87677139 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -141,7 +141,7 @@ static int g_bs = 512; module_param_named(bs, g_bs, int, 0444); MODULE_PARM_DESC(bs, "Block size (in bytes)"); -static int nr_devices = 1; +static unsigned int nr_devices = 1; module_param(nr_devices, int, 0444); MODULE_PARM_DESC(nr_devices, "Number of devices to register"); @@ -1758,6 +1758,10 @@ static int __init null_init(void) pr_err("null_blk: legacy IO path no longer available\n"); return -EINVAL; } + if (!nr_devices) { + pr_err("null_blk: invalid number of devices\n"); + return -EINVAL; + } if (g_queue_mode == NULL_Q_MQ && g_use_per_node_hctx) { if (g_submit_queues != nr_online_nodes) { pr_warn("null_blk: submit_queues param is set to %u.\n",