diff options
author | Wang Shilong <wangsl.fnst@cn.fujitsu.com> | 2014-06-26 07:08:16 +0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-07-03 18:04:04 +0400 |
commit | 5f3164813b90f7dbcb5c3ab9006906222ce471b7 (patch) | |
tree | b176f089dda953a935d4987c6d02ea3783cb56d7 /fs/btrfs/disk-io.c | |
parent | 3cc79392558f1789e5e1d2fce44b681980f403c3 (diff) | |
download | linux-5f3164813b90f7dbcb5c3ab9006906222ce471b7.tar.xz |
Btrfs: fix race between balance recovery and root deletion
Balance recovery is called when RW mounting or remounting from
RO to RW, it is called to finish roots merging.
When doing balance recovery, relocation root's corresponding
fs root(whose root refs is 0) might be destroyed by cleaner
thread, this will make btrfs fail to mount.
Fix this problem by holding @cleaner_mutex when doing balance
recovery.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index f00165de6fbf..08e65e9cf2aa 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2905,7 +2905,9 @@ retry_root_backup: if (ret) goto fail_qgroup; + mutex_lock(&fs_info->cleaner_mutex); ret = btrfs_recover_relocation(tree_root); + mutex_unlock(&fs_info->cleaner_mutex); if (ret < 0) { printk(KERN_WARNING "BTRFS: failed to recover relocation\n"); |