mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 15:22:21 -04:00
md/md-llbitmap: clear flush state after daemon flush
llbitmap_flush() sets LLPageFlush on each bitmap page before it queues the
daemon worker. The flag tells md_llbitmap_daemon_fn() to ignore the normal
barrier_idle expiry check and clean the page immediately.
The daemon only tested LLPageFlush. Once a page had been flushed explicitly,
the flag stayed set, so later dirty bits on that page also bypassed
barrier_idle and were cleaned the next time the daemon ran. That can make a
new write look clean much earlier than the configured idle window.
Consume LLPageFlush in md_llbitmap_daemon_fn() with test_and_clear_bit() and
use the returned value for the current expiry check. The explicit flush still
forces the current daemon pass, while later writes on the same page wait for
barrier_idle again.
This can be reproduced through normal sysfs operations:
1. Create a small RAID1 with --bitmap=lockless and --assume-clean.
2. Set llbitmap/daemon_sleep=1 and llbitmap/barrier_idle=10.
3. Toggle md/array_state from active to readonly and back to active to call
llbitmap_flush() without destroying the in-memory bitmap.
4. Write one sector and read llbitmap/bits immediately, after 2 seconds,
and after 12 seconds.
On the bad kernel the dirty bit is already clean after 2 seconds. With this
change it remains dirty until the barrier_idle window expires.
Tested-by: Mykola Marzhan <mykola@meshstor.io>
Link: https://patch.msgid.link/20260802195038.164272-2-yukuai@kernel.org
Signed-off-by: Yu Kuai <yukuai@fygo.io>
This commit is contained in:
@@ -1066,14 +1066,14 @@ static void md_llbitmap_daemon_fn(struct work_struct *work)
|
||||
|
||||
for (idx = 0; idx < llbitmap->nr_pages; idx++) {
|
||||
struct llbitmap_page_ctl *pctl = llbitmap->pctl[idx];
|
||||
bool flush = test_and_clear_bit(LLPageFlush, &pctl->flags);
|
||||
|
||||
if (idx > 0) {
|
||||
start = end + 1;
|
||||
end = min(end + PAGE_SIZE, llbitmap->chunks - 1);
|
||||
}
|
||||
|
||||
if (!test_bit(LLPageFlush, &pctl->flags) &&
|
||||
time_before(jiffies, pctl->expire)) {
|
||||
if (!flush && time_before(jiffies, pctl->expire)) {
|
||||
restart = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user