From: "Baek Kyu, Kim" <pocj8ur4in@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
"Baek Kyu, Kim" <pocj8ur4in@gmail.com>
Subject: [PATCH] null_blk: reset cache state before device setup
Date: Mon, 26 Oct 2026 01:11:33 +0900 [thread overview]
Message-ID: <20261025161133.59344-1-pocj8ur4in@gmail.com> (raw)
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) {
reply other threads:[~2026-10-25 16:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261025161133.59344-1-pocj8ur4in@gmail.com \
--to=pocj8ur4in@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®