* [PATCH] null_blk: reset cache state before device setup
@ 2026-10-25 16:11 Baek Kyu, Kim
0 siblings, 0 replies; only message in thread
From: Baek Kyu, Kim @ 2026-10-25 16:11 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, linux-kernel, Baek Kyu, Kim
The CACHE flag belongs to nullb_device, which outlives each powered-on
nullb instance. Power-off discards the runtime cache but leaves the flag
set. If cache_size changes from 1 to 0 before the next power-on, the
queue advertises write-through while new page writes still go into the
cache tree. A completed write can then disappear at the next power-off.
Clear CACHE before creating the new instance. The existing cache_size
setup sets it again when the new instance needs a cache.
Signed-off-by: Baek Kyu, Kim <pocj8ur4in@gmail.com>
---
Tested under ARM64 QEMU/KVM through configfs and the null_blk block device.
After changing cache_size from 1 to 0, a 4 KiB direct write to a new page
read back immediately on both kernels. After a power cycle, the baseline
lost the pattern while the kernel with this CACHE change retained all 4 KiB.
Both queues advertised write-through.
drivers/block/null_blk/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 6beb1f5b71ac..ec0d7ba4d938 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1976,6 +1976,7 @@ static int null_add_dev(struct nullb_device *dev)
rv = null_validate_conf(dev);
if (rv)
return rv;
+ clear_bit(NULLB_DEV_FL_CACHE, &dev->flags);
nullb = kzalloc_node(sizeof(*nullb), GFP_KERNEL, dev->home_node);
if (!nullb) {
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-25 16:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25 16:11 [PATCH] null_blk: reset cache state before device setup Baek Kyu, Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®