Skip to content

Commit fb5c39d

Browse files
Josef Bacikkdave
authored andcommitted
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: [email protected] # 4.14+ Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent ad22cf6 commit fb5c39d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/btrfs/extent-tree.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7257,6 +7257,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
72577257
struct btrfs_block_group_cache *block_group = NULL;
72587258
u64 search_start = 0;
72597259
u64 max_extent_size = 0;
7260+
u64 max_free_space = 0;
72607261
u64 empty_cluster = 0;
72617262
struct btrfs_space_info *space_info;
72627263
int loop = 0;
@@ -7552,8 +7553,8 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
75527553
spin_lock(&ctl->tree_lock);
75537554
if (ctl->free_space <
75547555
num_bytes + empty_cluster + empty_size) {
7555-
if (ctl->free_space > max_extent_size)
7556-
max_extent_size = ctl->free_space;
7556+
max_free_space = max(max_free_space,
7557+
ctl->free_space);
75577558
spin_unlock(&ctl->tree_lock);
75587559
goto loop;
75597560
}
@@ -7720,6 +7721,8 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
77207721
}
77217722
out:
77227723
if (ret == -ENOSPC) {
7724+
if (!max_extent_size)
7725+
max_extent_size = max_free_space;
77237726
spin_lock(&space_info->lock);
77247727
space_info->max_extent_size = max_extent_size;
77257728
spin_unlock(&space_info->lock);

0 commit comments

Comments
 (0)