diff options
author | Josef Bacik <jbacik@fb.com> | 2018-10-11 15:54:09 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-10-19 06:20:03 -0400 |
commit | fb5c39d7a887108087de6ff93d3f326b01b4ef41 (patch) | |
tree | 5f37db86a709d30c3ef123b6393d132c2bf1f299 | |
parent | ad22cf6ea47fa20fbe11ac324a0a15c0a9a4a2a9 (diff) |
btrfs: don't use ctl->free_space for max_extent_size
max_extent_size is supposed to be the largest contiguous range for the
space info, and ctl->free_space is the total free space in the block
group. We need to keep track of these separately and _only_ use the
max_free_space if we don't have a max_extent_size, as that means our
original request was too large to search any of the block groups for and
therefore wouldn't have a max_extent_size set.
CC: stable@vger.kernel.org # 4.14+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/extent-tree.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 87d6666cd8e3..85d1ceb90273 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -7257,6 +7257,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, | |||
7257 | struct btrfs_block_group_cache *block_group = NULL; | 7257 | struct btrfs_block_group_cache *block_group = NULL; |
7258 | u64 search_start = 0; | 7258 | u64 search_start = 0; |
7259 | u64 max_extent_size = 0; | 7259 | u64 max_extent_size = 0; |
7260 | u64 max_free_space = 0; | ||
7260 | u64 empty_cluster = 0; | 7261 | u64 empty_cluster = 0; |
7261 | struct btrfs_space_info *space_info; | 7262 | struct btrfs_space_info *space_info; |
7262 | int loop = 0; | 7263 | int loop = 0; |
@@ -7552,8 +7553,8 @@ unclustered_alloc: | |||
7552 | spin_lock(&ctl->tree_lock); | 7553 | spin_lock(&ctl->tree_lock); |
7553 | if (ctl->free_space < | 7554 | if (ctl->free_space < |
7554 | num_bytes + empty_cluster + empty_size) { | 7555 | num_bytes + empty_cluster + empty_size) { |
7555 | if (ctl->free_space > max_extent_size) | 7556 | max_free_space = max(max_free_space, |
7556 | max_extent_size = ctl->free_space; | 7557 | ctl->free_space); |
7557 | spin_unlock(&ctl->tree_lock); | 7558 | spin_unlock(&ctl->tree_lock); |
7558 | goto loop; | 7559 | goto loop; |
7559 | } | 7560 | } |
@@ -7720,6 +7721,8 @@ loop: | |||
7720 | } | 7721 | } |
7721 | out: | 7722 | out: |
7722 | if (ret == -ENOSPC) { | 7723 | if (ret == -ENOSPC) { |
7724 | if (!max_extent_size) | ||
7725 | max_extent_size = max_free_space; | ||
7723 | spin_lock(&space_info->lock); | 7726 | spin_lock(&space_info->lock); |
7724 | space_info->max_extent_size = max_extent_size; | 7727 | space_info->max_extent_size = max_extent_size; |
7725 | spin_unlock(&space_info->lock); | 7728 | spin_unlock(&space_info->lock); |