summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2015-06-15 09:41:18 -0400
committerChris Mason <clm@fb.com>2015-07-29 11:15:27 -0400
commite44163e177960ee60e32a73bffdd53c3a5827406 (patch)
treeffc55e93df052f4077f70ca996f2147dbb940237 /fs/btrfs/disk-io.c
parent499f377f49f085ee4aa214c738e948e88626f39b (diff)
btrfs: explictly delete unused block groups in close_ctree and ro-remount
The cleaner thread may already be sleeping by the time we enter close_ctree. If that's the case, we'll skip removing any unused block groups queued for removal, even during a normal umount. They'll be cleaned up automatically at next mount, but users expect a umount to be a clean synchronization point, especially when used on thin-provisioned storage with -odiscard. We also explicitly remove unused block groups in the ro-remount path for the same reason. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Tested-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 84cbbb2d562e..053109ba26b7 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3767,6 +3767,15 @@ void close_ctree(struct btrfs_root *root)
3767 cancel_work_sync(&fs_info->async_reclaim_work); 3767 cancel_work_sync(&fs_info->async_reclaim_work);
3768 3768
3769 if (!(fs_info->sb->s_flags & MS_RDONLY)) { 3769 if (!(fs_info->sb->s_flags & MS_RDONLY)) {
3770 /*
3771 * If the cleaner thread is stopped and there are
3772 * block groups queued for removal, the deletion will be
3773 * skipped when we quit the cleaner thread.
3774 */
3775 mutex_lock(&root->fs_info->cleaner_mutex);
3776 btrfs_delete_unused_bgs(root->fs_info);
3777 mutex_unlock(&root->fs_info->cleaner_mutex);
3778
3770 ret = btrfs_commit_super(root); 3779 ret = btrfs_commit_super(root);
3771 if (ret) 3780 if (ret)
3772 btrfs_err(fs_info, "commit super ret %d", ret); 3781 btrfs_err(fs_info, "commit super ret %d", ret);