aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-05-16 09:46:23 -0400
committerDavid Sterba <dsterba@suse.com>2016-05-16 09:46:23 -0400
commit73d32ce21e1701eaafcea3cbc2a8f27ab1967abe (patch)
tree136c03e4be575e4466ef9df119b8debdf768a56a /fs/btrfs/disk-io.c
parent02da2d72174c61988eb4456b53f405e3ebdebce4 (diff)
parent4673272f43ae790ab9ec04e38a7542f82bb8f020 (diff)
Merge branch 'misc-4.7' into for-chris-4.7-20160516
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4e47849d7427..070c1dad42bd 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2517,6 +2517,7 @@ int open_ctree(struct super_block *sb,
2517 int num_backups_tried = 0; 2517 int num_backups_tried = 0;
2518 int backup_index = 0; 2518 int backup_index = 0;
2519 int max_active; 2519 int max_active;
2520 bool cleaner_mutex_locked = false;
2520 2521
2521 tree_root = fs_info->tree_root = btrfs_alloc_root(fs_info, GFP_KERNEL); 2522 tree_root = fs_info->tree_root = btrfs_alloc_root(fs_info, GFP_KERNEL);
2522 chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info, GFP_KERNEL); 2523 chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info, GFP_KERNEL);
@@ -2997,6 +2998,13 @@ retry_root_backup:
2997 goto fail_sysfs; 2998 goto fail_sysfs;
2998 } 2999 }
2999 3000
3001 /*
3002 * Hold the cleaner_mutex thread here so that we don't block
3003 * for a long time on btrfs_recover_relocation. cleaner_kthread
3004 * will wait for us to finish mounting the filesystem.
3005 */
3006 mutex_lock(&fs_info->cleaner_mutex);
3007 cleaner_mutex_locked = true;
3000 fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root, 3008 fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root,
3001 "btrfs-cleaner"); 3009 "btrfs-cleaner");
3002 if (IS_ERR(fs_info->cleaner_kthread)) 3010 if (IS_ERR(fs_info->cleaner_kthread))
@@ -3056,10 +3064,8 @@ retry_root_backup:
3056 ret = btrfs_cleanup_fs_roots(fs_info); 3064 ret = btrfs_cleanup_fs_roots(fs_info);
3057 if (ret) 3065 if (ret)
3058 goto fail_qgroup; 3066 goto fail_qgroup;
3059 3067 /* We locked cleaner_mutex before creating cleaner_kthread. */
3060 mutex_lock(&fs_info->cleaner_mutex);
3061 ret = btrfs_recover_relocation(tree_root); 3068 ret = btrfs_recover_relocation(tree_root);
3062 mutex_unlock(&fs_info->cleaner_mutex);
3063 if (ret < 0) { 3069 if (ret < 0) {
3064 printk(KERN_WARNING 3070 printk(KERN_WARNING
3065 "BTRFS: failed to recover relocation\n"); 3071 "BTRFS: failed to recover relocation\n");
@@ -3067,6 +3073,8 @@ retry_root_backup:
3067 goto fail_qgroup; 3073 goto fail_qgroup;
3068 } 3074 }
3069 } 3075 }
3076 mutex_unlock(&fs_info->cleaner_mutex);
3077 cleaner_mutex_locked = false;
3070 3078
3071 location.objectid = BTRFS_FS_TREE_OBJECTID; 3079 location.objectid = BTRFS_FS_TREE_OBJECTID;
3072 location.type = BTRFS_ROOT_ITEM_KEY; 3080 location.type = BTRFS_ROOT_ITEM_KEY;
@@ -3180,6 +3188,10 @@ fail_cleaner:
3180 filemap_write_and_wait(fs_info->btree_inode->i_mapping); 3188 filemap_write_and_wait(fs_info->btree_inode->i_mapping);
3181 3189
3182fail_sysfs: 3190fail_sysfs:
3191 if (cleaner_mutex_locked) {
3192 mutex_unlock(&fs_info->cleaner_mutex);
3193 cleaner_mutex_locked = false;
3194 }
3183 btrfs_sysfs_remove_mounted(fs_info); 3195 btrfs_sysfs_remove_mounted(fs_info);
3184 3196
3185fail_fsdev_sysfs: 3197fail_fsdev_sysfs: