Re: [PATCH] writeback: fix race between cgroup_writeback_umount() and inode_switch_wbs()
From: Tejun Heo
Date: Wed May 13 2026 - 16:39:12 EST
Hello,
Resending - earlier send dropped the Cc list. Sorry for the noise.
How rcu_barrier() got out of sync, as best I can reconstruct:
- ec084de929e4 ("fs/writeback.c: use rcu_barrier() to wait for inflight
wb switches going into workqueue when umount", 2019) put the inc
after call_rcu(); rcu_barrier() worked from then.
- 8826ee4fe750 ("writeback, cgroup: increment isw_nr_in_flight before
grabbing an inode", 2021) moved the inc back ahead to cover the prep
window, apparently reopening this gap.
- e1b849cfa6b6 ("writeback: Avoid contention on wb->list_lock when
switching inodes", 2025) replaced call_rcu() with llist_add() +
queue_work(); rcu_barrier() looks like a no-op for this path since.
Could SRCU work instead? srcu_read_lock around the publish (atomic_inc
through wb_queue_isw), with cgroup_writeback_umount() keeping the
counter gate but swapping rcu_barrier() for synchronize_srcu():
if (atomic_read(&isw_nr_in_flight)) {
synchronize_srcu(&isw_srcu);
flush_workqueue(isw_wq);
}
Thoughts?
Thanks.
--
tejun