diff mbox series

[v5,10/10] btrfs: skip space_cache v1 setup when not using it

Message ID 09febed7882924087141f081273fb4bbcaae7928.1603828718.git.boris@bur.io (mailing list archive)
State New, archived
Headers show
Series [v5,01/10] btrfs: lift rw mount setup from mount and remount | expand

Commit Message

Boris Burkov Oct. 27, 2020, 9:08 p.m. UTC
If we are not using space cache v1, we should not create the free space
object or free space inodes. This comes up when we delete the existing
free space objects/inodes when migrating to v2, only to see them get
recreated for every dirtied block group.

Signed-off-by: Boris Burkov <boris@bur.io>
---
 fs/btrfs/block-group.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 8938b11a3339..59a130fdcd5c 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -2325,6 +2325,9 @@  static int cache_save_setup(struct btrfs_block_group *block_group,
 	int retries = 0;
 	int ret = 0;
 
+	if (!btrfs_test_opt(fs_info, SPACE_CACHE))
+		return 0;
+
 	/*
 	 * If this block group is smaller than 100 megs don't bother caching the
 	 * block group.