Skip to content

Commit 21a94f7

Browse files
josefbacikkdave
authored andcommitted
btrfs: reset max_extent_size properly
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]>
1 parent b2b5b65 commit 21a94f7

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
@@ -4565,6 +4565,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
45654565
goto out;
45664566
} else {
45674567
ret = 1;
4568+
space_info->max_extent_size = 0;
45684569
}
45694570

45704571
space_info->force_alloc = CHUNK_ALLOC_NO_FORCE;
@@ -6459,6 +6460,7 @@ static void btrfs_free_reserved_bytes(struct btrfs_block_group_cache *cache,
64596460
space_info->bytes_readonly += num_bytes;
64606461
cache->reserved -= num_bytes;
64616462
space_info->bytes_reserved -= num_bytes;
6463+
space_info->max_extent_size = 0;
64626464

64636465
if (delalloc)
64646466
cache->delalloc_bytes -= num_bytes;

0 commit comments

Comments
 (0)