diff mbox

[1/1] null_blk: fix error flow for shared tags during module_init

Message ID 1499347489-10863-1-git-send-email-maxg@mellanox.com (mailing list archive)
State New, archived
Headers show

Commit Message

Max Gurtovoy July 6, 2017, 1:24 p.m. UTC
In case we use shared tags feature, blk_mq_alloc_tag_set might fail
during module initialization. Check the return value and default to run
without shared tag set before continuing. Also move the tagset
initialization process after defining the amount of submition queues.

Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
---
 drivers/block/null_blk.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

Comments

Jens Axboe July 6, 2017, 2:02 p.m. UTC | #1
On 07/06/2017 07:24 AM, Max Gurtovoy wrote:
> In case we use shared tags feature, blk_mq_alloc_tag_set might fail
> during module initialization. Check the return value and default to run
> without shared tag set before continuing. Also move the tagset
> initialization process after defining the amount of submition queues.

Fail the load instead. For two reasons:

1) We could be loading to test this explicitly. null_blk isn't a regular
   driver, it's not like we're bringing up the system on this thing.
   Hence I feel it's more important that it loads with what we asked for,
   or not load at all.

2) If initializing one tag set fails, the unshared case will surely
   fail too.
Max Gurtovoy July 6, 2017, 2:32 p.m. UTC | #2
On 7/6/2017 5:02 PM, Jens Axboe wrote:
> On 07/06/2017 07:24 AM, Max Gurtovoy wrote:
>> In case we use shared tags feature, blk_mq_alloc_tag_set might fail
>> during module initialization. Check the return value and default to run
>> without shared tag set before continuing. Also move the tagset
>> initialization process after defining the amount of submition queues.
>
> Fail the load instead. For two reasons:
>
> 1) We could be loading to test this explicitly. null_blk isn't a regular
>    driver, it's not like we're bringing up the system on this thing.
>    Hence I feel it's more important that it loads with what we asked for,
>    or not load at all.
>
> 2) If initializing one tag set fails, the unshared case will surely
>    fail too.
>

Ok. I'll send V2 version soon.
diff mbox

Patch

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 71f4422..0b7e7e1 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -844,9 +844,6 @@  static int __init null_init(void)
 		queue_mode = NULL_Q_MQ;
 	}
 
-	if (queue_mode == NULL_Q_MQ && shared_tags)
-		null_init_tag_set(&tag_set);
-
 	if (queue_mode == NULL_Q_MQ && use_per_node_hctx) {
 		if (submit_queues < nr_online_nodes) {
 			pr_warn("null_blk: submit_queues param is set to %u.",
@@ -858,6 +855,15 @@  static int __init null_init(void)
 	else if (!submit_queues)
 		submit_queues = 1;
 
+	if (queue_mode == NULL_Q_MQ && shared_tags) {
+		ret = null_init_tag_set(&tag_set);
+		if (ret) {
+			pr_warn("null_blk: Can't use shared tags %d\n", ret);
+			pr_warn("null_blk: defaults to non shared tags\n");
+			shared_tags = false;
+		}
+	}
+
 	mutex_init(&lock);
 
 	null_major = register_blkdev(0, "nullb");