btrfs: use the original mount's mount options for the legacy reconfigure
authorJosef Bacik <josef@toxicpanda.com>
Wed, 10 Jan 2024 17:54:41 +0000 (12:54 -0500)
committerDavid Sterba <dsterba@suse.com>
Thu, 18 Jan 2024 22:38:54 +0000 (23:38 +0100)
commit2018ef1d9ac3e95448b9206adc3425b0431c2411
tree8794fcc0c06faf8763f55180f15f8ba79d66f09a
parenta208b3f132b48e1f94f620024e66fea635925877
btrfs: use the original mount's mount options for the legacy reconfigure

btrfs/330, which tests our old trick to allow

mount -o ro,subvol=/x /dev/sda1 /foo
mount -o rw,subvol=/y /dev/sda1 /bar

fails on the block group tree.  This is because we aren't preserving the
mount options for what is essentially a remount, and thus we're ending
up without the FREE_SPACE_TREE mount option, which triggers our free
space tree delete codepath.  This isn't possible with the block group
tree and thus it falls over.

Fix this by making sure we copy the existing mount options for the
existing fs mount over in this case.

Fixes: f044b318675f ("btrfs: handle the ro->rw transition for mounting different subvolumes")
Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/super.c