FAILED: patch "[PATCH] writeback: keep cleanup_offline_cgwb()'s scan out of syncs" failed to apply to 6.12-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 90c96612460e6accddbda5a195e6ddaa391ecde0
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 90c96612460e6accddbda5a195e6ddaa391ecde0 Mon Sep 17 00:00:00 2001
From: Liz Fong-Jones <[email protected]>
Date: Sat, 17 Oct 2026 04:07:11 +0000
Subject: [PATCH] writeback: keep cleanup_offline_cgwb()'s scan out of syncs
On a filesystem mounted with lazytime, sync() and syncfs() can return without persisting timestamp updates of inodes attached to a dying cgroup wb, so a crash after the sync loses them. File data and sizes are not affected.
Since commit f6988c90671e ("writeback: bound cleanup_offline_cgwb() rescans by rotating scanned inodes"), isw_prepare_wbs_switch() moves the inodes it walks to the newest end of the list. When a pass fills its isw before reaching an inode that got its lazytime update after a sync's cutoff, the walked inodes land past it on b_dirty_time, and the sync's queue_io(), which stops at the first inode dirtied after the cutoff, misses them. The late inode has to be one without a pending lazytime update; one already on b_dirty_time keeps its position.
The window is narrow. cleanup_offline_cgwbs_workfn() skips wbs with anything on b_dirty, b_io or b_more_io, so the scan has to land between wb_writeback() fixing dirtied_before and taking list_lock for its first queue_io(), unless a multi-pass drain started before the wb got dirty IO.
Take wb_switch_rwsem for read across the scan, asprocess_inode_switch_wbs() does for the switches.
--- fs/fs-writeback.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/fs-writeback.c +8 -0
@@ -790,6 +790,13 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb) new_wb = &wb->bdi->wb;/* wb_get() is noop for bdi's wb */ nr =0 ; +/* +* The scan moves walked inodes to the newest end of b_dirty_time, +* past ones it didn't reach. If one of those was dirtied after a +* sync's cutoff, the sync's queue_io() stops there and misses the +* moved ones. Exclude syncs as process_inode_switch_wbs() does. +*/ +down_read (&wb->bdi->wb_switch_rwsem);spin_lock (&wb->list_lock);/* * In addition to the inodes that have completed writeback, also switch
@@ -804,6 +811,7 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb) restart =isw_prepare_wbs_switch (new_wb, isw, &wb->b_dirty_time, &nr);spin_unlock (&wb->list_lock); +up_read (&wb->bdi->wb_switch_rwsem);/* no attached inodes? bail out */ if (nr ==0 ) {
Signature · 1 line
2.53.0
PATCH 1/1 writeback: keep cleanup_offline_cgwb()'s scan out of syncs
[ Upstream commit 90c96612460e6accddbda5a195e6ddaa391ecde0 ]
On a filesystem mounted with lazytime, sync() and syncfs() can return without persisting timestamp updates of inodes attached to a dying cgroup wb, so a crash after the sync loses them. File data and sizes are not affected.
Since commit f6988c90671e ("writeback: bound cleanup_offline_cgwb() rescans by rotating scanned inodes"), isw_prepare_wbs_switch() moves the inodes it walks to the newest end of the list. When a pass fills its isw before reaching an inode that got its lazytime update after a sync's cutoff, the walked inodes land past it on b_dirty_time, and the sync's queue_io(), which stops at the first inode dirtied after the cutoff, misses them. The late inode has to be one without a pending lazytime update; one already on b_dirty_time keeps its position.
The window is narrow. cleanup_offline_cgwbs_workfn() skips wbs with anything on b_dirty, b_io or b_more_io, so the scan has to land between wb_writeback() fixing dirtied_before and taking list_lock for its first queue_io(), unless a multi-pass drain started before the wb got dirty IO.
Take wb_switch_rwsem for read across the scan, asprocess_inode_switch_wbs() does for the switches.
[ Take wb_switch_rwsem before this branch's rcu_read_lock(), as
down_read() can sleep. ]
---
Upstream's first hunk conflicts with this branch's rcu_read_lock() block, so the rwsem is taken before it. Same change as the 6.18.y backport, which was race-tested; compile-tested only here.
fs/fs-writeback.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/fs-writeback.c +8 -0
@@ -756,6 +756,13 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb) new_wb = &wb->bdi->wb;/* wb_get() is noop for bdi's wb */ nr =0 ; +/* +* The scan moves walked inodes to the newest end of b_dirty_time, +* past ones it didn't reach. If one of those was dirtied after a +* sync's cutoff, the sync's queue_io() stops there and misses the +* moved ones. Exclude syncs as process_inode_switch_wbs() does. +*/ +down_read (&wb->bdi->wb_switch_rwsem);/* * Paired with synchronize_rcu() in cgroup_writeback_umount(). * Holding rcu_read_lock across the SB_ACTIVE check, the inode grab
@@ -778,6 +785,7 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb) restart =isw_prepare_wbs_switch (new_wb, isw, &wb->b_dirty_time, &nr);spin_unlock (&wb->list_lock); +up_read (&wb->bdi->wb_switch_rwsem);/* no attached inodes? bail out */ if (nr ==0 ) {
Signature · 1 line
2.53.0