Skip to content

Commit 7509d4f

Browse files
Josef Bacikgregkh
authored andcommitted
btrfs: don't use ctl->free_space for max_extent_size
commit fb5c39d upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 65d41e9 commit 7509d4f

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
@@ -7573,6 +7573,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
75737573
struct btrfs_block_group_cache *block_group = NULL;
75747574
u64 search_start = 0;
75757575
u64 max_extent_size = 0;
7576+
u64 max_free_space = 0;
75767577
u64 empty_cluster = 0;
75777578
struct btrfs_space_info *space_info;
75787579
int loop = 0;
@@ -7867,8 +7868,8 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
78677868
spin_lock(&ctl->tree_lock);
78687869
if (ctl->free_space <
78697870
num_bytes + empty_cluster + empty_size) {
7870-
if (ctl->free_space > max_extent_size)
7871-
max_extent_size = ctl->free_space;
7871+
max_free_space = max(max_free_space,
7872+
ctl->free_space);
78727873
spin_unlock(&ctl->tree_lock);
78737874
goto loop;
78747875
}
@@ -8037,6 +8038,8 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
80378038
}
80388039
out:
80398040
if (ret == -ENOSPC) {
8041+
if (!max_extent_size)
8042+
max_extent_size = max_free_space;
80408043
spin_lock(&space_info->lock);
80418044
space_info->max_extent_size = max_extent_size;
80428045
spin_unlock(&space_info->lock);

0 commit comments

Comments
 (0)