diff options
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 45 |
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 | |
7029 | again: | ||
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 | ||
7060 | static inline void | 7059 | static 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 | ||