Skip to content

Commit ad9e5e7

Browse files
Al Virokdave
authored andcommitted
btrfs_get_tree_subvol(): switch from fc_mount() to vfs_create_mount()
[Aaarghh...] it's simpler to do btrfs_reconfigure_for_mount() right after vfs_get_tree() - no need to mess with ->s_umount. [fix for braino(s) folded in - kudos to Klara Modin <[email protected]>] Signed-off-by: Al Viro <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 7ad68f1 commit ad9e5e7

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

fs/btrfs/super.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,17 +2004,13 @@ static int btrfs_get_tree_super(struct fs_context *fc)
20042004
* btrfs or not, setting the whole super block RO. To make per-subvolume mounting
20052005
* work with different options work we need to keep backward compatibility.
20062006
*/
2007-
static int btrfs_reconfigure_for_mount(struct fs_context *fc, struct vfsmount *mnt)
2007+
static int btrfs_reconfigure_for_mount(struct fs_context *fc)
20082008
{
20092009
int ret = 0;
20102010

2011-
if (fc->sb_flags & SB_RDONLY)
2012-
return ret;
2013-
2014-
down_write(&mnt->mnt_sb->s_umount);
2015-
if (!(fc->sb_flags & SB_RDONLY) && (mnt->mnt_sb->s_flags & SB_RDONLY))
2011+
if (!(fc->sb_flags & SB_RDONLY) && (fc->root->d_sb->s_flags & SB_RDONLY))
20162012
ret = btrfs_reconfigure(fc);
2017-
up_write(&mnt->mnt_sb->s_umount);
2013+
20182014
return ret;
20192015
}
20202016

@@ -2067,17 +2063,18 @@ static int btrfs_get_tree_subvol(struct fs_context *fc)
20672063
security_free_mnt_opts(&fc->security);
20682064
fc->security = NULL;
20692065

2070-
mnt = fc_mount(dup_fc);
2071-
if (IS_ERR(mnt)) {
2072-
put_fs_context(dup_fc);
2073-
return PTR_ERR(mnt);
2066+
ret = vfs_get_tree(dup_fc);
2067+
if (!ret) {
2068+
ret = btrfs_reconfigure_for_mount(dup_fc);
2069+
up_write(&dup_fc->root->d_sb->s_umount);
20742070
}
2075-
ret = btrfs_reconfigure_for_mount(dup_fc, mnt);
2071+
if (!ret)
2072+
mnt = vfs_create_mount(dup_fc);
2073+
else
2074+
mnt = ERR_PTR(ret);
20762075
put_fs_context(dup_fc);
2077-
if (ret) {
2078-
mntput(mnt);
2079-
return ret;
2080-
}
2076+
if (IS_ERR(mnt))
2077+
return PTR_ERR(mnt);
20812078

20822079
/*
20832080
* This free's ->subvol_name, because if it isn't set we have to

0 commit comments

Comments
 (0)