Hi, The drivers in this patch-series tries to clear the QUEUE_FLAG_ADD_RANDOM that is not set at all in the queue allocation and initialization path in :- drivers/block/mtip32xx/mtip32xx.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, dd->queue); drivers/block/null_blk/main.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, nullb->q); drivers/block/rbd.c: /* QUEUE_FLAG_ADD_RANDOM is off by default for blk-mq */ drivers/block/zram/zram_drv.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, zram->disk->queue); drivers/block/nbd.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue); drivers/block/brd.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue); drivers/md/bcache/super.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, d->disk->queue); drivers/md/dm-table.c: * Clear QUEUE_FLAG_ADD_RANDOM if any underlying device does not drivers/md/dm-table.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q); drivers/mmc/core/queue.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, mq->queue); drivers/mtd/mtd_blkdevs.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, new->rq); drivers/s390/block/scm_blk.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, rq); drivers/scsi/sd.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q); drivers/scsi/sd.c: blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q); include/linux/blkdev.h:#define QUEUE_FLAG_ADD_RANDOM 10 /* Contributes to random pool */ include/linux/blkdev.h:#define blk_queue_add_random(q) test_bit(QUEUE_FLAG_ADD_RANDOM, &(q)->queue_flags) Since sd is the only driver that sets this flag:- drivers/scsi/sd.c: blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q); drivers/scsi/sd.c: blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q); it is unclear how it will be set for null_blk, brd. nbd, zram, and bcache in the allocation path so we have to clear it explicitly. Remove the call to clear QUEUE_FLAG_ADD_RANDOM. Below is testlog for :- null_blk brd nbd zram bcache Below is the test log. -ck Chaitanya Kulkarni (5): null_blk: don't clear the flag that is not set brd: don't clear the flag that is not set nbd: don't clear the flag that is not set zram: don't clear the flag that is not set bcache: don't clear the flag that is not set drivers/block/brd.c | 1 - drivers/block/nbd.c | 1 - drivers/block/null_blk/main.c | 1 - drivers/block/zram/zram_drv.c | 1 - drivers/md/bcache/super.c | 1 - 5 files changed, 5 deletions(-) * NULL_BLK:- ----------------------------------------------------------------------- With this debug patch :- @@ -2128,7 +2128,11 @@ static int null_add_dev(struct nullb_device *dev) nullb->q->queuedata = nullb; blk_queue_flag_set(QUEUE_FLAG_NONROT, nullb->q); + pr_info("%s %d BEFORE ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(nullb->q) ? "TRUE" : "FALSE" ); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, nullb->q); + pr_info("%s %d AFTER ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(nullb->q) ? "TRUE" : "FALSE" ); mutex_lock(&lock); rv = ida_simple_get(&nullb_indexes, 0, 0, GFP_KERNEL); + modprobe -r null_blk + lsmod + grep null_blk ++ nproc + make -j 48 M=drivers/block modules + HOST=drivers/block/null_blk/ ++ uname -r + HOST_DEST=/lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/null_blk/ + cp drivers/block/null_blk//null_blk.ko /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/null_blk// + ls -lrth /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/null_blk//null_blk.ko -rw-r--r--. 2 root root 1.2M Apr 23 13:00 /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/null_blk//null_blk.ko + sleep 1 + dmesg -c + modprobe null_blk queue_mode=0 + dmesg -c [33316.880281] null_blk: null_add_dev 2147 BEFORE ADD RANDOM = FALSE [33316.880288] null_blk: null_add_dev 2150 AFTER ADD RANDOM = FALSE [33316.880705] null_blk: disk nullb0 created [33316.880707] null_blk: module loaded + modprobe -r null_blk + modprobe null_blk queue_mode=2 + dmesg -c [33316.920977] null_blk: null_add_dev 2147 BEFORE ADD RANDOM = FALSE [33316.920981] null_blk: null_add_dev 2150 AFTER ADD RANDOM = FALSE [33316.922640] null_blk: disk nullb0 created [33316.922643] null_blk: module loaded + modprobe -r null_blk + modprobe -r null_blk + lsmod + grep null_blk ++ nproc + make -j 48 M=drivers/block modules + HOST=drivers/block/null_blk/ ++ uname -r + HOST_DEST=/lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/null_blk/ + cp drivers/block/null_blk//null_blk.ko /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/null_blk// + ls -lrth /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/null_blk//null_blk.ko -rw-r--r--. 2 root root 1.2M Apr 23 13:00 /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/null_blk//null_blk.ko + sleep 1 + dmesg -c + modprobe null_blk queue_mode=0 + dmesg -c [33316.880281] null_blk: null_add_dev 2147 BEFORE ADD RANDOM = FALSE [33316.880288] null_blk: null_add_dev 2150 AFTER ADD RANDOM = FALSE [33316.880705] null_blk: disk nullb0 created [33316.880707] null_blk: module loaded + modprobe -r null_blk + modprobe null_blk queue_mode=2 + dmesg -c [33316.920977] null_blk: null_add_dev 2147 BEFORE ADD RANDOM = FALSE [33316.920981] null_blk: null_add_dev 2150 AFTER ADD RANDOM = FALSE [33316.922640] null_blk: disk nullb0 created [33316.922643] null_blk: module loaded + modprobe -r null_blk * BRD:- ----------------------------------------------------------------------- With this debug patch :- @@ -404,7 +404,11 @@ static int brd_alloc(int i) /* Tell the block layer that this is not a rotational device */ blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue); blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, disk->queue); + pr_info("%s %d BEFORE ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(disk->queue) ? "TRUE" : "FALSE" ); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue); + pr_info("%s %d AFTER ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(disk->queue) ? "TRUE" : "FALSE" ); blk_queue_flag_set(QUEUE_FLAG_NOWAIT, disk->queue); err = add_disk(disk); if (err) + modprobe -r brd + lsmod + grep brd ++ nproc + make -j 48 M=drivers/block modules + HOST=drivers/block/brd.ko ++ uname -r + HOST_DEST=/lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/ + cp drivers/block/brd.ko /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block// + ls -lrth /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block//brd.ko -rw-r--r--. 1 root root 381K Apr 23 14:09 /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block//brd.ko + dmesg -c + lsmod + grep brd + modprobe brd + dmesg -c [ 3785.884916] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.884921] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.885320] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.885322] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.885662] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.885664] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.886270] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.886272] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.886451] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.886452] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.886621] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.886622] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.886831] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.886833] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.886990] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.886991] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.887176] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.887177] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.887368] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.887369] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.888011] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.888013] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.888212] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.888214] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.888687] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.888689] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.888911] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.888913] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.889390] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.889392] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.889585] brd_alloc 407 BEFORE ADD RANDOM = FALSE [ 3785.889586] brd_alloc 410 AFTER ADD RANDOM = FALSE [ 3785.890099] brd: module loaded + modprobe -r brd * NBD :- ----------------------------------------------------------------------- With this debug patch :- @@ -1805,7 +1805,11 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) * Tell the block layer that we are not a rotational device */ blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue); + pr_info("%s %d BEFORE ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(disk->queue) ? "TRUE" : "FALSE" ); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue); + pr_info("%s %d AFTER ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(disk->queue) ? "TRUE" : "FALSE" ); disk->queue->limits.discard_granularity = 0; blk_queue_max_discard_sectors(disk->queue, 0); blk_queue_max_segment_size(disk->queue, UINT_MAX); + modprobe -r nbd + lsmod + grep nbd ++ nproc + make -j 48 M=drivers/block modules + HOST=drivers/block/nbd.ko ++ uname -r + HOST_DEST=/lib/modules/6.3.0-rc7lblk+/kernel/drivers/block/ + cp drivers/block/nbd.ko /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block// + ls -lrth /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block//nbd.ko -rw-r--r--. 1 root root 998K Apr 23 14:09 /lib/modules/6.3.0-rc7lblk+/kernel/drivers/block//nbd.ko + dmesg -c + lsmod + grep nbd + modprobe nbd + dmesg -c [ 3786.953726] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.953731] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.954877] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.954880] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.956753] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.956759] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.958118] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.958121] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.959372] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.959374] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.960139] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.960141] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.960878] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.960880] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.961558] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.961560] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.962303] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.962305] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.963063] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.963065] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.963821] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.963824] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.964573] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.964575] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.965282] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.965284] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.966067] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.966069] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.966851] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.966854] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE [ 3786.967544] nbd: nbd_dev_add 1808 BEFORE ADD RANDOM = FALSE [ 3786.967545] nbd: nbd_dev_add 1811 AFTER ADD RANDOM = FALSE + modprobe -r nbd * ZRAM:- ----------------------------------------------------------------------- With this debug patch :- @@ -2323,7 +2323,11 @@ static int zram_add(void) /* zram devices sort of resembles non-rotational disks */ blk_queue_flag_set(QUEUE_FLAG_NONROT, zram->disk->queue); blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, zram->disk->queue); + pr_info("%s %d BEFORE ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(zram->disk->queue) ? "TRUE" : "FALSE" ); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, zram->disk->queue); + pr_info("%s %d AFTER ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(zram->disk->queue) ? "TRUE" : "FALSE" ); /* * To ensure that we always get PAGE_SIZE aligned [ 9.020829] zram: loading out-of-tree module taints kernel. [ 9.030043] zram: zram_add 2326 BEFORE ADD RANDOM = FALSE [ 9.030047] zram: zram_add 2329 AFTER ADD RANDOM = FALSE [ 9.030579] zram: Added device: zram0 [ 9.168858] systemd[1]: Created slice system-systemd\x2dzram\x2dsetup.slice. [ 9.544414] zram0: detected capacity change from 0 to 16777216 [ 9.600893] Adding 8388604k swap on /dev/zram0. Priority:100 extents:1 across:8388604k SSFS * BCACHE:- ----------------------------------------------------------------------- With this debug patch :- @@ -971,7 +971,11 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size, } blk_queue_flag_set(QUEUE_FLAG_NONROT, d->disk->queue); + pr_info("%s %d BEFORE ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(d->disk->queue) ? "TRUE" : "FALSE" ); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, d->disk->queue); + pr_info("%s %d AFTER ADD RANDOM = %s\n", __func__, __LINE__, + blk_queue_add_random(d->disk->queue) ? "TRUE" : "FALSE" ); blk_queue_write_cache(q, true, true); + makej M=drivers/md/bcache + modprobe null_blk queue_mode=2 nr_devices=2 memory_backed=1 gb=1 + insmod drivers/md/bcache/bcache.ko + bcache make -B /dev/nullb0 -C /dev/nullb1 Name /dev/nullb1 Label Type cache UUID: 0694b66e-970e-49e2-ab2c-791f84a53b8e Set UUID: e8be54f6-18c9-4965-b406-63e602201395 version: 0 nbuckets: 2048 block_size_in_sectors: 1 bucket_size_in_sectors: 1024 nr_in_set: 1 nr_this_dev: 0 first_bucket: 1 ... Name /dev/nullb0 Label Type data UUID: 8a64d20c-12ce-4ca5-a9fb-f978bfba52df Set UUID: e8be54f6-18c9-4965-b406-63e602201395 version: 1 block_size_in_sectors: 1 data_offset_in_sectors: 16 + echo /dev/nullb0 + echo /dev/nullb1 + dmesg -c [ 3788.828220] null_blk: null_add_dev 2147 BEFORE ADD RANDOM = FALSE [ 3788.828227] null_blk: null_add_dev 2150 AFTER ADD RANDOM = FALSE [ 3788.829617] null_blk: disk nullb0 created [ 3788.829699] null_blk: null_add_dev 2147 BEFORE ADD RANDOM = FALSE [ 3788.829701] null_blk: null_add_dev 2150 AFTER ADD RANDOM = FALSE [ 3788.830484] null_blk: disk nullb1 created [ 3788.830485] null_blk: module loaded [ 3788.863458] bcache: bcache_device_init() bcache_device_init 974 BEFORE ADD RANDOM = FALSE [ 3788.863462] bcache: bcache_device_init() bcache_device_init 977 AFTER ADD RANDOM = FALSE [ 3788.863491] bcache: register_bdev() registered backing device nullb0 [ 3788.864156] bcache: run_cache_set() invalidating existing data [ 3788.866970] bcache: bch_cached_dev_run() cached dev nullb0 is running already [ 3788.866976] bcache: bch_cached_dev_attach() Caching nullb0 as bcache0 on set e8be54f6-18c9-4965-b406-63e602201395 [ 3788.866990] bcache: register_cache() registered cache device nullb1 + sleep 1 + bcache unregister /dev/nullb0 + bcache unregister /dev/nullb1 + sleep 1 + modprobe -r bcache + modprobe -r null_blk -- 2.40.0