diff options
author | Boris Burkov <boris@bur.io> | 2020-11-19 02:06:17 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-12-09 21:16:07 +0300 |
commit | 8f1c21d7490fc1ac5ef364b7085987ca439fb32f (patch) | |
tree | 0e11aad09db6f5400aec20a3ef479cc8e7173697 /fs | |
parent | 44c0ca211a4da92513fffc545b5374b45b0c4fc5 (diff) | |
download | linux-8f1c21d7490fc1ac5ef364b7085987ca439fb32f.tar.xz |
btrfs: start orphan cleanup on ro->rw remount
When we mount a rw filesystem, we start the orphan cleanup process in
tree root and filesystem tree. However, when we remount a ro file system
rw, we only clean the former. Move the calls to btrfs_orphan_cleanup()
on tree_root and fs_root to the shared rw mount routine to effectively
add them on ro->rw remount.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/disk-io.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index c7886584ba7d..0d076437b72e 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2882,6 +2882,14 @@ int btrfs_start_pre_rw_mount(struct btrfs_fs_info *fs_info) if (ret) goto out; + down_read(&fs_info->cleanup_work_sem); + if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) || + (ret = btrfs_orphan_cleanup(fs_info->tree_root))) { + up_read(&fs_info->cleanup_work_sem); + goto out; + } + up_read(&fs_info->cleanup_work_sem); + mutex_lock(&fs_info->cleaner_mutex); ret = btrfs_recover_relocation(fs_info->tree_root); mutex_unlock(&fs_info->cleaner_mutex); @@ -3374,15 +3382,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device } } - down_read(&fs_info->cleanup_work_sem); - if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) || - (ret = btrfs_orphan_cleanup(fs_info->tree_root))) { - up_read(&fs_info->cleanup_work_sem); - close_ctree(fs_info); - return ret; - } - up_read(&fs_info->cleanup_work_sem); - ret = btrfs_start_pre_rw_mount(fs_info); if (ret) { close_ctree(fs_info); |