aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <clm@fb.com>2016-05-17 17:24:44 -0400
committerChris Mason <clm@fb.com>2016-05-17 17:24:44 -0400
commita88336d13c66fc171f336c6332fcb67339894e08 (patch)
tree595935ba3afc91dce9be83ca65932f3cf1379436 /fs/btrfs/extent-tree.c
parent02da2d72174c61988eb4456b53f405e3ebdebce4 (diff)
parent680834ca0ad4e9827048d4bda1e38db69c3dd1e4 (diff)
Merge branch 'for-chris-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.7
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 84e060eb0de8..290e05671ee4 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4620,7 +4620,7 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
4620 4620
4621 /* Calc the number of the pages we need flush for space reservation */ 4621 /* Calc the number of the pages we need flush for space reservation */
4622 items = calc_reclaim_items_nr(root, to_reclaim); 4622 items = calc_reclaim_items_nr(root, to_reclaim);
4623 to_reclaim = items * EXTENT_SIZE_PER_ITEM; 4623 to_reclaim = (u64)items * EXTENT_SIZE_PER_ITEM;
4624 4624
4625 trans = (struct btrfs_trans_handle *)current->journal_info; 4625 trans = (struct btrfs_trans_handle *)current->journal_info;
4626 block_rsv = &root->fs_info->delalloc_block_rsv; 4626 block_rsv = &root->fs_info->delalloc_block_rsv;
@@ -7025,36 +7025,35 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
7025 int delalloc) 7025 int delalloc)
7026{ 7026{
7027 struct btrfs_block_group_cache *used_bg = NULL; 7027 struct btrfs_block_group_cache *used_bg = NULL;
7028 bool locked = false; 7028
7029again:
7030 spin_lock(&cluster->refill_lock); 7029 spin_lock(&cluster->refill_lock);
7031 if (locked) { 7030 while (1) {
7032 if (used_bg == cluster->block_group) 7031 used_bg = cluster->block_group;
7032 if (!used_bg)
7033 return NULL;
7034
7035 if (used_bg == block_group)
7033 return used_bg; 7036 return used_bg;
7034 7037
7035 up_read(&used_bg->data_rwsem); 7038 btrfs_get_block_group(used_bg);
7036 btrfs_put_block_group(used_bg);
7037 }
7038 7039
7039 used_bg = cluster->block_group; 7040 if (!delalloc)
7040 if (!used_bg) 7041 return used_bg;
7041 return NULL;
7042 7042
7043 if (used_bg == block_group) 7043 if (down_read_trylock(&used_bg->data_rwsem))
7044 return used_bg; 7044 return used_bg;
7045 7045
7046 btrfs_get_block_group(used_bg); 7046 spin_unlock(&cluster->refill_lock);
7047 7047
7048 if (!delalloc) 7048 down_read(&used_bg->data_rwsem);
7049 return used_bg;
7050 7049
7051 if (down_read_trylock(&used_bg->data_rwsem)) 7050 spin_lock(&cluster->refill_lock);
7052 return used_bg; 7051 if (used_bg == cluster->block_group)
7052 return used_bg;
7053 7053
7054 spin_unlock(&cluster->refill_lock); 7054 up_read(&used_bg->data_rwsem);
7055 down_read(&used_bg->data_rwsem); 7055 btrfs_put_block_group(used_bg);
7056 locked = true; 7056 }
7057 goto again;
7058} 7057}
7059 7058
7060static inline void 7059static inline void
@@ -9058,7 +9057,7 @@ out:
9058 if (!for_reloc && root_dropped == false) 9057 if (!for_reloc && root_dropped == false)
9059 btrfs_add_dead_root(root); 9058 btrfs_add_dead_root(root);
9060 if (err && err != -EAGAIN) 9059 if (err && err != -EAGAIN)
9061 btrfs_std_error(root->fs_info, err, NULL); 9060 btrfs_handle_fs_error(root->fs_info, err, NULL);
9062 return err; 9061 return err;
9063} 9062}
9064 9063