Skip to content

Commit c55a431

Browse files
boryaskdave
authored andcommitted
btrfs: fix spurious free_space_tree remount warning
The intended logic of the check is to catch cases where the desired free_space_tree setting doesn't match the mounted setting, and the remount is anything but ro->rw. However, it makes the mistake of checking equality on a masked integer (btrfs_test_opt) against a boolean (btrfs_fs_compat_ro). If you run the reproducer: $ mount -o space_cache=v2 dev mnt $ mount -o remount,ro mnt you would expect no warning, because the remount is not attempting to change the free space tree setting, but we do see the warning. To fix this, add explicit bool type casts to the condition. I tested a variety of transitions: sudo mount -o space_cache=v2 /dev/vg0/lv0 mnt/lol (fst enabled) mount -o remount,ro mnt/lol (no warning, no fst change) sudo mount -o remount,rw,space_cache=v1,clear_cache (no warning, ro->rw) sudo mount -o remount,rw,space_cache=v2 mnt (warning, rw->rw with change) sudo mount -o remount,ro mnt (no warning, no fst change) sudo mount -o remount,rw,space_cache=v2 mnt (no warning, no fst change) Reported-by: Chris Murphy <lists@colorremedies.com> CC: stable@vger.kernel.org # 5.11 Signed-off-by: Boris Burkov <boris@bur.io> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 5011c5a commit c55a431

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,8 +1918,8 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
19181918
btrfs_resize_thread_pool(fs_info,
19191919
fs_info->thread_pool_size, old_thread_pool_size);
19201920

1921-
if (btrfs_test_opt(fs_info, FREE_SPACE_TREE) !=
1922-
btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE) &&
1921+
if ((bool)btrfs_test_opt(fs_info, FREE_SPACE_TREE) !=
1922+
(bool)btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE) &&
19231923
(!sb_rdonly(sb) || (*flags & SB_RDONLY))) {
19241924
btrfs_warn(fs_info,
19251925
"remount supports changing free space tree only from ro to rw");

0 commit comments

Comments
 (0)