* [PATCH] null_blk: reset cache state before device setup
@ 2026-10-25 16:11 Baek Kyu, Kim
2026-11-03 10:06 ` Christoph Hellwig
2026-11-03 14:31 ` Jens Axboe
0 siblings, 2 replies; 3+ messages 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] 3+ messages in thread* Re: [PATCH] null_blk: reset cache state before device setup
2026-10-25 16:11 [PATCH] null_blk: reset cache state before device setup Baek Kyu, Kim
@ 2026-11-03 10:06 ` Christoph Hellwig
2026-11-03 14:31 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-11-03 10:06 UTC (permalink / raw)
To: Baek Kyu, Kim; +Cc: Jens Axboe, linux-block, linux-kernel
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] null_blk: reset cache state before device setup
2026-10-25 16:11 [PATCH] null_blk: reset cache state before device setup Baek Kyu, Kim
2026-11-03 10:06 ` Christoph Hellwig
@ 2026-11-03 14:31 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2026-11-03 14:31 UTC (permalink / raw)
To: Baek Kyu, Kim; +Cc: linux-block, linux-kernel
On Mon, 26 Oct 2026 01:11:33 +0900, Baek Kyu, Kim wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] null_blk: reset cache state before device setup
commit: 5a4236bf22622c291a96c139bfe54117f4cf1af6
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-03 14:31 UTC | newest]
Thread overview: 3+ messages (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
2026-11-03 10:06 ` Christoph Hellwig
2026-11-03 14:31 ` Jens Axboe
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®