Skip to content

Commit

Permalink
null_blk: add configfs variable shared_tags
Browse files Browse the repository at this point in the history
Allow setting shared_tags through configfs, which could only be set as a
module parameter. For that purpose, delay tag_set initialization from
null_init() to null_add_dev(). Refer tag_set.ops as the flag to check if
tag_set is initialized or not.

The following parameters can not be set through configfs yet:

    timeout
    requeue
    init_hctx

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20240130042134.2463659-1-shinichiro.kawasaki@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Shin'ichiro Kawasaki authored and Jens Axboe committed Feb 8, 2024
1 parent 48ff13a commit 14509b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
38 changes: 20 additions & 18 deletions drivers/block/null_blk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ static bool g_blocking;
module_param_named(blocking, g_blocking, bool, 0444);
MODULE_PARM_DESC(blocking, "Register as a blocking blk-mq driver device");

static bool shared_tags;
module_param(shared_tags, bool, 0444);
static bool g_shared_tags;
module_param_named(shared_tags, g_shared_tags, bool, 0444);
MODULE_PARM_DESC(shared_tags, "Share tag set between devices for blk-mq");

static bool g_shared_tag_bitmap;
Expand Down Expand Up @@ -426,6 +426,7 @@ NULLB_DEVICE_ATTR(zone_max_open, uint, NULL);
NULLB_DEVICE_ATTR(zone_max_active, uint, NULL);
NULLB_DEVICE_ATTR(virt_boundary, bool, NULL);
NULLB_DEVICE_ATTR(no_sched, bool, NULL);
NULLB_DEVICE_ATTR(shared_tags, bool, NULL);
NULLB_DEVICE_ATTR(shared_tag_bitmap, bool, NULL);

static ssize_t nullb_device_power_show(struct config_item *item, char *page)
Expand Down Expand Up @@ -571,6 +572,7 @@ static struct configfs_attribute *nullb_device_attrs[] = {
&nullb_device_attr_zone_offline,
&nullb_device_attr_virt_boundary,
&nullb_device_attr_no_sched,
&nullb_device_attr_shared_tags,
&nullb_device_attr_shared_tag_bitmap,
NULL,
};
Expand Down Expand Up @@ -653,10 +655,11 @@ static ssize_t memb_group_features_show(struct config_item *item, char *page)
"badblocks,blocking,blocksize,cache_size,"
"completion_nsec,discard,home_node,hw_queue_depth,"
"irqmode,max_sectors,mbps,memory_backed,no_sched,"
"poll_queues,power,queue_mode,shared_tag_bitmap,size,"
"submit_queues,use_per_node_hctx,virt_boundary,zoned,"
"zone_capacity,zone_max_active,zone_max_open,"
"zone_nr_conv,zone_offline,zone_readonly,zone_size\n");
"poll_queues,power,queue_mode,shared_tag_bitmap,"
"shared_tags,size,submit_queues,use_per_node_hctx,"
"virt_boundary,zoned,zone_capacity,zone_max_active,"
"zone_max_open,zone_nr_conv,zone_offline,zone_readonly,"
"zone_size\n");
}

CONFIGFS_ATTR_RO(memb_group_, features);
Expand Down Expand Up @@ -738,6 +741,7 @@ static struct nullb_device *null_alloc_dev(void)
dev->zone_max_active = g_zone_max_active;
dev->virt_boundary = g_virt_boundary;
dev->no_sched = g_no_sched;
dev->shared_tags = g_shared_tags;
dev->shared_tag_bitmap = g_shared_tag_bitmap;
return dev;
}
Expand Down Expand Up @@ -2124,7 +2128,14 @@ static int null_add_dev(struct nullb_device *dev)
goto out_free_nullb;

if (dev->queue_mode == NULL_Q_MQ) {
if (shared_tags) {
if (dev->shared_tags) {
if (!tag_set.ops) {
rv = null_init_tag_set(NULL, &tag_set);
if (rv) {
tag_set.ops = NULL;
goto out_cleanup_queues;
}
}
nullb->tag_set = &tag_set;
rv = 0;
} else {
Expand Down Expand Up @@ -2311,18 +2322,12 @@ static int __init null_init(void)
g_submit_queues = 1;
}

if (g_queue_mode == NULL_Q_MQ && shared_tags) {
ret = null_init_tag_set(NULL, &tag_set);
if (ret)
return ret;
}

config_group_init(&nullb_subsys.su_group);
mutex_init(&nullb_subsys.su_mutex);

ret = configfs_register_subsystem(&nullb_subsys);
if (ret)
goto err_tagset;
return ret;

mutex_init(&lock);

Expand All @@ -2349,9 +2354,6 @@ static int __init null_init(void)
unregister_blkdev(null_major, "nullb");
err_conf:
configfs_unregister_subsystem(&nullb_subsys);
err_tagset:
if (g_queue_mode == NULL_Q_MQ && shared_tags)
blk_mq_free_tag_set(&tag_set);
return ret;
}

Expand All @@ -2370,7 +2372,7 @@ static void __exit null_exit(void)
}
mutex_unlock(&lock);

if (g_queue_mode == NULL_Q_MQ && shared_tags)
if (tag_set.ops)
blk_mq_free_tag_set(&tag_set);
}

Expand Down
1 change: 1 addition & 0 deletions drivers/block/null_blk/null_blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ struct nullb_device {
bool zoned; /* if device is zoned */
bool virt_boundary; /* virtual boundary on/off for the device */
bool no_sched; /* no IO scheduler for the device */
bool shared_tags; /* share tag set between devices for blk-mq */
bool shared_tag_bitmap; /* use hostwide shared tags */
};

Expand Down

0 comments on commit 14509b7

Please sign in to comment.