>> when you load module with default module parameter it will create a >> default device with no memory backed mode, that will not be visible in >> the configfs. >> >> So you need to load the module with nr_devices=0 that will prevent the >> null_blk to create the default device which is not memory backed and not >> present in the configfs:- >> > > Yup I know what it's doing, I'm raising this as it's weird and took me > a bit to work out what was happening, and it annoyed me. It's not > anything I can't work around, but the UX kinda sucks. Thanks, > > Josef hmmm, how about a following patch, this will create memory backed default devices at the time of loading the module ? # git diff diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index c441a4972064..d45c2f3f5692 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -148,7 +148,7 @@ static const struct kernel_param_ops null_queue_mode_param_ops = { device_param_cb(queue_mode, &null_queue_mode_param_ops, &g_queue_mode, 0444); MODULE_PARM_DESC(queue_mode, "Block interface to use (0=bio,1=rq,2=multiqueue)"); -static int g_gb = 250; +static int g_gb = 1; module_param_named(gb, g_gb, int, 0444); MODULE_PARM_DESC(gb, "Size in GB"); @@ -168,6 +168,10 @@ 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 g_memory_backed; +module_param_named(memory_backed, g_memory_backed, bool, 0444); +MODULE_PARM_DESC(memory_backed, "memory backed device, default:false"); + static bool shared_tags; module_param(shared_tags, bool, 0444); MODULE_PARM_DESC(shared_tags, "Share tag set between devices for blk-mq"); @@ -657,6 +661,8 @@ static struct nullb_device *null_alloc_dev(void) dev->zone_max_open = g_zone_max_open; dev->zone_max_active = g_zone_max_active; dev->virt_boundary = g_virt_boundary; + dev->memory_backed = g_memory_backed; + return dev; } This passed the fio verification test when loaded with newly added module parameter memory_backed=1:- + modprobe -r null_blk + modprobe null_blk + tree config/ config/ └── nullb └── features 1 directory, 1 file + lsblk + grep null nullb0 250:0 0 1G 0 disk + fio fio/verify.fio --filename=/dev/nullb0 --output=/tmp/fio.log verify: bad header offset 668917760, wanted 0 at file /dev/nullb0 offset 0, length 4096 (requested block: offset=0, length=4096) verify: bad header offset 746139648, wanted 4096 at file /dev/nullb0 offset 4096, length 4096 (requested block: offset=4096, length=4096) verify: bad header offset 705691648, wanted 8192 at file /dev/nullb0 offset 8192, length 4096 (requested block: offset=8192, length=4096) verify: bad header offset 363917312, wanted 12288 at file /dev/nullb0 offset 12288, length 4096 (requested block: offset=12288, length=4096) + grep err= /tmp/fio.log write-and-verify: (groupid=0, jobs=1): err=84 (file:io_u.c:2141, func=io_u_queued_complete, error=Invalid or incomplete multibyte or wide character): pid=21015: Mon Apr 18 15:14:36 2022 + modprobe -r null_blk + modprobe -r null_blk + modprobe null_blk memory_backed=1 + tree config/ config/ └── nullb └── features 1 directory, 1 file + lsblk + grep null nullb0 250:0 0 1G 0 disk + fio fio/verify.fio --filename=/dev/nullb0 --output=/tmp/fio.log + grep err= /tmp/fio.log write-and-verify: (groupid=0, jobs=1): err= 0: pid=21025: Mon Apr 18 15:14:38 2022 + modprobe -r null_blk -ck