btrfs: open code fc_mount() to avoid releasing s_umount rw_sempahore
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 6 May 2025 19:58:26 +0000 (20:58 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:53:29 +0000 (23:53 +0200)
commit75764b41bfc3a463b8a5f240e93f6342510dc944
tree6814326e10812ffda65be20266ec5b97b1dc0cb9
parent4013cde56e170bc71e2d242c1933f4b7c1e4486a
btrfs: open code fc_mount() to avoid releasing s_umount rw_sempahore

[CURRENT BEHAVIOR]
Currently inside btrfs_get_tree_subvol(), we call fc_mount() to grab a
tree, then re-lock s_umount inside btrfs_reconfigure_for_mount() to
avoid race with remount.

However fc_mount() itself is just doing two things:

1. Call vfs_get_tree()
2. Release s_umount then call vfs_create_mount()

[ENHANCEMENT]
Instead of calling fc_mount(), we can open-code it with vfs_get_tree()
first.
This provides a benefit that, since we have the full control of
s_umount, we do not need to re-lock that rw_sempahore when calling
btrfs_reconfigure_for_mount(), meaning less race between RO/RW remount.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Reviewed-by: Qu Wenruo <wqu@suse.com>
[ Rework the subject and commit message, refactor the error handling ]
Signed-off-by: Qu Wenruo <wqu@suse.com>
Tested-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/super.c