|
@@ -892,6 +892,8 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
|
|
root->stripesize = stripesize;
|
|
root->stripesize = stripesize;
|
|
root->ref_cows = 0;
|
|
root->ref_cows = 0;
|
|
root->track_dirty = 0;
|
|
root->track_dirty = 0;
|
|
|
|
+ root->in_radix = 0;
|
|
|
|
+ root->clean_orphans = 0;
|
|
|
|
|
|
root->fs_info = fs_info;
|
|
root->fs_info = fs_info;
|
|
root->objectid = objectid;
|
|
root->objectid = objectid;
|
|
@@ -928,7 +930,6 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
|
|
root->defrag_trans_start = fs_info->generation;
|
|
root->defrag_trans_start = fs_info->generation;
|
|
init_completion(&root->kobj_unregister);
|
|
init_completion(&root->kobj_unregister);
|
|
root->defrag_running = 0;
|
|
root->defrag_running = 0;
|
|
- root->defrag_level = 0;
|
|
|
|
root->root_key.objectid = objectid;
|
|
root->root_key.objectid = objectid;
|
|
root->anon_super.s_root = NULL;
|
|
root->anon_super.s_root = NULL;
|
|
root->anon_super.s_dev = 0;
|
|
root->anon_super.s_dev = 0;
|
|
@@ -1210,8 +1211,10 @@ again:
|
|
ret = radix_tree_insert(&fs_info->fs_roots_radix,
|
|
ret = radix_tree_insert(&fs_info->fs_roots_radix,
|
|
(unsigned long)root->root_key.objectid,
|
|
(unsigned long)root->root_key.objectid,
|
|
root);
|
|
root);
|
|
- if (ret == 0)
|
|
|
|
|
|
+ if (ret == 0) {
|
|
root->in_radix = 1;
|
|
root->in_radix = 1;
|
|
|
|
+ root->clean_orphans = 1;
|
|
|
|
+ }
|
|
spin_unlock(&fs_info->fs_roots_radix_lock);
|
|
spin_unlock(&fs_info->fs_roots_radix_lock);
|
|
radix_tree_preload_end();
|
|
radix_tree_preload_end();
|
|
if (ret) {
|
|
if (ret) {
|
|
@@ -1225,10 +1228,6 @@ again:
|
|
ret = btrfs_find_dead_roots(fs_info->tree_root,
|
|
ret = btrfs_find_dead_roots(fs_info->tree_root,
|
|
root->root_key.objectid);
|
|
root->root_key.objectid);
|
|
WARN_ON(ret);
|
|
WARN_ON(ret);
|
|
-
|
|
|
|
- if (!(fs_info->sb->s_flags & MS_RDONLY))
|
|
|
|
- btrfs_orphan_cleanup(root);
|
|
|
|
-
|
|
|
|
return root;
|
|
return root;
|
|
fail:
|
|
fail:
|
|
free_fs_root(root);
|
|
free_fs_root(root);
|
|
@@ -1689,6 +1688,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
|
|
mutex_init(&fs_info->cleaner_mutex);
|
|
mutex_init(&fs_info->cleaner_mutex);
|
|
mutex_init(&fs_info->volume_mutex);
|
|
mutex_init(&fs_info->volume_mutex);
|
|
init_rwsem(&fs_info->extent_commit_sem);
|
|
init_rwsem(&fs_info->extent_commit_sem);
|
|
|
|
+ init_rwsem(&fs_info->cleanup_work_sem);
|
|
init_rwsem(&fs_info->subvol_sem);
|
|
init_rwsem(&fs_info->subvol_sem);
|
|
|
|
|
|
btrfs_init_free_cluster(&fs_info->meta_alloc_cluster);
|
|
btrfs_init_free_cluster(&fs_info->meta_alloc_cluster);
|
|
@@ -2388,6 +2388,11 @@ int btrfs_commit_super(struct btrfs_root *root)
|
|
mutex_lock(&root->fs_info->cleaner_mutex);
|
|
mutex_lock(&root->fs_info->cleaner_mutex);
|
|
btrfs_clean_old_snapshots(root);
|
|
btrfs_clean_old_snapshots(root);
|
|
mutex_unlock(&root->fs_info->cleaner_mutex);
|
|
mutex_unlock(&root->fs_info->cleaner_mutex);
|
|
|
|
+
|
|
|
|
+ /* wait until ongoing cleanup work done */
|
|
|
|
+ down_write(&root->fs_info->cleanup_work_sem);
|
|
|
|
+ up_write(&root->fs_info->cleanup_work_sem);
|
|
|
|
+
|
|
trans = btrfs_start_transaction(root, 1);
|
|
trans = btrfs_start_transaction(root, 1);
|
|
ret = btrfs_commit_transaction(trans, root);
|
|
ret = btrfs_commit_transaction(trans, root);
|
|
BUG_ON(ret);
|
|
BUG_ON(ret);
|