Skip to content

Commit e982bec

Browse files
josefbacikgregkh
authored andcommitted
btrfs: reset max_extent_size properly
commit 21a94f7 upstream. If we use up our block group before allocating a new one we'll easily get a max_extent_size that's set really really low, which will result in a lot of fragmentation. We need to make sure we're resetting the max_extent_size when we add a new chunk or add new space. CC: [email protected] # 4.4+ 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 ea9c846 commit e982bec

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/btrfs/extent-tree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4530,6 +4530,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
45304530
goto out;
45314531
} else {
45324532
ret = 1;
4533+
space_info->max_extent_size = 0;
45334534
}
45344535

45354536
space_info->force_alloc = CHUNK_ALLOC_NO_FORCE;
@@ -6431,6 +6432,7 @@ static int btrfs_free_reserved_bytes(struct btrfs_block_group_cache *cache,
64316432
space_info->bytes_readonly += num_bytes;
64326433
cache->reserved -= num_bytes;
64336434
space_info->bytes_reserved -= num_bytes;
6435+
space_info->max_extent_size = 0;
64346436

64356437
if (delalloc)
64366438
cache->delalloc_bytes -= num_bytes;

0 commit comments

Comments
 (0)