]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - mm/backing-dev.c
writeback: synchronize sync(2) against cgroup writeback membership switches
authorTejun Heo <tj@kernel.org>
Tue, 12 Dec 2017 16:38:30 +0000 (08:38 -0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit6a83923f0ed9f1d562de978ed8324f439957f1e6
tree8563ad8224bbdba5f78aafcc147dc62f548bba3c
parent282187e6b98e983b2ec8512795d6c702f34adb13
writeback: synchronize sync(2) against cgroup writeback membership switches

BugLink: https://bugs.launchpad.net/bugs/1837813
[ Upstream commit 7fc5854f8c6efae9e7624970ab49a1eac2faefb1 ]

sync_inodes_sb() can race against cgwb (cgroup writeback) membership
switches and fail to writeback some inodes.  For example, if an inode
switches to another wb while sync_inodes_sb() is in progress, the new
wb might not be visible to bdi_split_work_to_wbs() at all or the inode
might jump from a wb which hasn't issued writebacks yet to one which
already has.

This patch adds backing_dev_info->wb_switch_rwsem to synchronize cgwb
switch path against sync_inodes_sb() so that sync_inodes_sb() is
guaranteed to see all the target wbs and inodes can't jump wbs to
escape syncing.

v2: Fixed misplaced rwsem init.  Spotted by Jiufei.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Jiufei Xue <xuejiufei@gmail.com>
Link: http://lkml.kernel.org/r/dc694ae2-f07f-61e1-7097-7c8411cee12d@gmail.com
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/fs-writeback.c
include/linux/backing-dev-defs.h
mm/backing-dev.c