diff options
author | Josef Bacik <josef@toxicpanda.com> | 2018-10-11 15:54:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-11-13 11:08:58 -0800 |
commit | e982beca3e4e989716dda88d215d1b96b585e542 (patch) | |
tree | 81b847cd77db1ac20803b38b172412f746d87d29 | |
parent | ea9c846f54dbf03da159a1b7566aa95e9bf1674b (diff) | |
download | linux-stable-e982beca3e4e989716dda88d215d1b96b585e542.tar.gz linux-stable-e982beca3e4e989716dda88d215d1b96b585e542.tar.bz2 linux-stable-e982beca3e4e989716dda88d215d1b96b585e542.zip |
btrfs: reset max_extent_size properly
commit 21a94f7acf0f748599ea552af5d9ee7d7e41c72f 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: stable@vger.kernel.org # 4.4+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/btrfs/extent-tree.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index d7652b0d0375..5fa6a7816e78 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4530,6 +4530,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags, goto out; } else { ret = 1; + space_info->max_extent_size = 0; } space_info->force_alloc = CHUNK_ALLOC_NO_FORCE; @@ -6431,6 +6432,7 @@ static int btrfs_free_reserved_bytes(struct btrfs_block_group_cache *cache, space_info->bytes_readonly += num_bytes; cache->reserved -= num_bytes; space_info->bytes_reserved -= num_bytes; + space_info->max_extent_size = 0; if (delalloc) cache->delalloc_bytes -= num_bytes; |