summaryrefslogtreecommitdiff
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2023-04-28 09:13:05 +0300
committerDavid Sterba <dsterba@suse.com>2023-05-10 15:51:27 +0300
commit1d6a4fc85717677e00fefffd847a50fc5928ce69 (patch)
tree1f87a86bbd720f7daca0e3f436684509f5031636 /fs/btrfs/super.c
parentc83b56d1dd87cf67492bb770c26d6f87aee70ed6 (diff)
downloadlinux-1d6a4fc85717677e00fefffd847a50fc5928ce69.tar.xz
btrfs: make clear_cache mount option to rebuild FST without disabling it
Previously clear_cache mount option would simply disable free-space-tree feature temporarily then re-enable it to rebuild the whole free space tree. But this is problematic for block-group-tree feature, as we have an artificial dependency on free-space-tree feature. If we go the existing method, after clearing the free-space-tree feature, we would flip the filesystem to read-only mode, as we detect a super block write with block-group-tree but no free-space-tree feature. This patch would change the behavior by properly rebuilding the free space tree without disabling this feature, thus allowing clear_cache mount option to work with block group tree. Now we can mount a filesystem with block-group-tree feature and clear_mount option: $ mkfs.btrfs -O block-group-tree /dev/test/scratch1 -f $ sudo mount /dev/test/scratch1 /mnt/btrfs -o clear_cache $ sudo dmesg -t | head -n 5 BTRFS info (device dm-1): force clearing of disk cache BTRFS info (device dm-1): using free space tree BTRFS info (device dm-1): auto enabling async discard BTRFS info (device dm-1): rebuilding free space tree BTRFS info (device dm-1): checking UUID tree CC: stable@vger.kernel.org # 6.1+ Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 0f2f915e42b0..ec18e2210602 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -828,8 +828,7 @@ out:
ret = -EINVAL;
}
if (btrfs_fs_compat_ro(info, BLOCK_GROUP_TREE) &&
- (btrfs_test_opt(info, CLEAR_CACHE) ||
- !btrfs_test_opt(info, FREE_SPACE_TREE))) {
+ !btrfs_test_opt(info, FREE_SPACE_TREE)) {
btrfs_err(info, "cannot disable free space tree with block-group-tree feature");
ret = -EINVAL;
}