Skip to content

Commit 65de03e

Browse files
htejunaxboe
authored andcommitted
cgroup,writeback: don't switch wbs immediately on dead wbs if the memcg is dead
cgroup writeback tries to refresh the associated wb immediately if the current wb is dead. This is to avoid keeping issuing IOs on the stale wb after memcg - blkcg association has changed (ie. when blkcg got disabled / enabled higher up in the hierarchy). Unfortunately, the logic gets triggered spuriously on inodes which are associated with dead cgroups. When the logic is triggered on dead cgroups, the attempt fails only after doing quite a bit of work allocating and initializing a new wb. While c3aab9a ("mm/filemap.c: don't initiate writeback if mapping has no dirty pages") alleviated the issue significantly as it now only triggers when the inode has dirty pages. However, the condition can still be triggered before the inode is switched to a different cgroup and the logic simply doesn't make sense. Skip the immediate switching if the associated memcg is dying. This is a simplified version of the following two patches: * https://lore.kernel.org/linux-mm/20190513183053.GA73423@dennisz-mbp/ * http://lkml.kernel.org/r/156355839560.2063.5265687291430814589.stgit@buzz Cc: Konstantin Khlebnikov <[email protected]> Fixes: e8a7abf ("writeback: disassociate inodes from dying bdi_writebacks") Acked-by: Dennis Zhou <[email protected]> Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 8e9c523 commit 65de03e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/fs-writeback.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,13 @@ void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
576576
spin_unlock(&inode->i_lock);
577577

578578
/*
579-
* A dying wb indicates that the memcg-blkcg mapping has changed
580-
* and a new wb is already serving the memcg. Switch immediately.
579+
* A dying wb indicates that either the blkcg associated with the
580+
* memcg changed or the associated memcg is dying. In the first
581+
* case, a replacement wb should already be available and we should
582+
* refresh the wb immediately. In the second case, trying to
583+
* refresh will keep failing.
581584
*/
582-
if (unlikely(wb_dying(wbc->wb)))
585+
if (unlikely(wb_dying(wbc->wb) && !css_is_dying(wbc->wb->memcg_css)))
583586
inode_switch_wbs(inode, wbc->wb_id);
584587
}
585588
EXPORT_SYMBOL_GPL(wbc_attach_and_unlock_inode);

0 commit comments

Comments
 (0)