On Wed, Nov 07, 2018 at 05:01:19PM +0100, David Sterba wrote: > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > > From: Omar Sandoval <osan...@fb.com> > > > > There's a race between close_ctree() and cleaner_kthread(). > > close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it > > sees it set, but this is racy; the cleaner might have already checked > > the bit and could be cleaning stuff. In particular, if it deletes unused > > block groups, it will create delayed iputs for the free space cache > > inodes. As of "btrfs: don't run delayed_iputs in commit", we're no > > longer running delayed iputs after a commit. Therefore, if the cleaner > > creates more delayed iputs after delayed iputs are run in > > btrfs_commit_super(), we will leak inodes on unmount and get a busy > > inode crash from the VFS. > > > > Fix it by parking the cleaner before we actually close anything. Then, > > any remaining delayed iputs will always be handled in > > btrfs_commit_super(). This also ensures that the commit in close_ctree() > > is really the last commit, so we can get rid of the commit in > > cleaner_kthread(). > > > > Fixes: 30928e9baac2 ("btrfs: don't run delayed_iputs in commit") > > Signed-off-by: Omar Sandoval <osan...@fb.com> > > I'll queue this patch for rc2 as it fixes crashes I see during testing. > My version does more changes and would be more suitable for a series, > that could actually document the shutdown sequence and add a few > assertions on top.
Thanks, Dave! I'll keep an eye out for the further cleanups. > Reviewed-by: David Sterba <dste...@suse.com>