|
@@ -7257,6 +7257,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
|
|
|
struct btrfs_block_group_cache *block_group = NULL;
|
|
|
u64 search_start = 0;
|
|
|
u64 max_extent_size = 0;
|
|
|
+ u64 max_free_space = 0;
|
|
|
u64 empty_cluster = 0;
|
|
|
struct btrfs_space_info *space_info;
|
|
|
int loop = 0;
|
|
@@ -7552,8 +7553,8 @@ unclustered_alloc:
|
|
|
spin_lock(&ctl->tree_lock);
|
|
|
if (ctl->free_space <
|
|
|
num_bytes + empty_cluster + empty_size) {
|
|
|
- if (ctl->free_space > max_extent_size)
|
|
|
- max_extent_size = ctl->free_space;
|
|
|
+ max_free_space = max(max_free_space,
|
|
|
+ ctl->free_space);
|
|
|
spin_unlock(&ctl->tree_lock);
|
|
|
goto loop;
|
|
|
}
|
|
@@ -7720,6 +7721,8 @@ loop:
|
|
|
}
|
|
|
out:
|
|
|
if (ret == -ENOSPC) {
|
|
|
+ if (!max_extent_size)
|
|
|
+ max_extent_size = max_free_space;
|
|
|
spin_lock(&space_info->lock);
|
|
|
space_info->max_extent_size = max_extent_size;
|
|
|
spin_unlock(&space_info->lock);
|