aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/block-group.c
diff options
context:
space:
mode:
authorBoris Burkov <boris@bur.io>2020-11-18 15:06:18 -0800
committerDavid Sterba <dsterba@suse.com>2020-12-09 19:16:07 +0100
commit997e3e2e71b32b31bfab6b299d9db05af285b457 (patch)
tree3e14ab3fe2d7c3d6817fd3d616571603e8240d65 /fs/btrfs/block-group.c
parentbtrfs: start orphan cleanup on ro->rw remount (diff)
downloadlinux-dev-997e3e2e71b32b31bfab6b299d9db05af285b457.tar.xz
linux-dev-997e3e2e71b32b31bfab6b299d9db05af285b457.zip
btrfs: only mark bg->needs_free_space if free space tree is on
If we attempt to create a free space tree while any block groups have needs_free_space set, we will double add the new free space item and hit EEXIST. Previously, we only created the free space tree on a new mount, so we never hit the case, but if we try to create it on a remount, such block groups could exist and trip us up. We don't do anything with this field unless the free space tree is enabled, so there is no harm in not setting it. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Boris Burkov <boris@bur.io> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/block-group.c')
-rw-r--r--fs/btrfs/block-group.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 9c3523b6e016..614b6b5b3102 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -2165,7 +2165,8 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
cache->flags = type;
cache->last_byte_to_unpin = (u64)-1;
cache->cached = BTRFS_CACHE_FINISHED;
- cache->needs_free_space = 1;
+ if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE))
+ cache->needs_free_space = 1;
ret = exclude_super_stripes(cache);
if (ret) {
/* We may have excluded something, so call this just in case */