Unverified Commit 22311063 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12427 btrfs: wait for fixup workers before stopping cleaner kthread during umount

parents 45ac4c65 daf72f8d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -4313,6 +4313,17 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
	/* clear out the rbtree of defraggable inodes */
	btrfs_cleanup_defrag_inodes(fs_info);

	/*
	 * Wait for any fixup workers to complete.
	 * If we don't wait for them here and they are still running by the time
	 * we call kthread_stop() against the cleaner kthread further below, we
	 * get an use-after-free on the cleaner because the fixup worker adds an
	 * inode to the list of delayed iputs and then attempts to wakeup the
	 * cleaner kthread, which was already stopped and destroyed. We parked
	 * already the cleaner, but below we run all pending delayed iputs.
	 */
	btrfs_flush_workqueue(fs_info->fixup_workers);

	/*
	 * After we parked the cleaner kthread, ordered extents may have
	 * completed and created new delayed iputs. If one of the async reclaim