diff mbox series

fs/fs-writeback: wait isw_nr_in_flight to be zero when umount

Message ID 20190412094008.97859-1-jiufei.xue@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series fs/fs-writeback: wait isw_nr_in_flight to be zero when umount | expand

Commit Message

Jiufei Xue April 12, 2019, 9:40 a.m. UTC
synchronize_rcu() didn't wait for call_rcu() callbacks, so inode wb
switch may not go to the workqueue after synchronize_rcu(). Thus
previous scheduled switches was not finished even flushing the
workqueue, which will cause a NULL pointer dereferenced followed below.

VFS: Busy inodes after unmount of vdd. Self-destruct in 5 seconds.
Have a nice day...
BUG: unable to handle kernel NULL pointer dereference at
0000000000000278
[<ffffffff8126a303>] evict+0xb3/0x180
[<ffffffff8126a760>] iput+0x1b0/0x230
[<ffffffff8127c690>] inode_switch_wbs_work_fn+0x3c0/0x6a0
[<ffffffff810a5b2e>] worker_thread+0x4e/0x490
[<ffffffff810a5ae0>] ? process_one_work+0x410/0x410
[<ffffffff810ac056>] kthread+0xe6/0x100
[<ffffffff8173c199>] ret_from_fork+0x39/0x50

Signed-off-by: Jiufei Xue <jiufei.xue@linux.alibaba.com>
Cc: stable@kernel.org
---
 fs/fs-writeback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 36855c1f8daf..6b4136bf1788 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -900,7 +900,7 @@  static void bdi_split_work_to_wbs(struct backing_dev_info *bdi,
  */
 void cgroup_writeback_umount(void)
 {
-	if (atomic_read(&isw_nr_in_flight)) {
+	while (atomic_read(&isw_nr_in_flight)) {
 		synchronize_rcu();
 		flush_workqueue(isw_wq);
 	}