Skip to content

Commit 44acd3b

Browse files
Al Virokdave
Al Viro
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 5d84b12 commit 44acd3b

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
@@ -1996,17 +1996,13 @@ static int btrfs_get_tree_super(struct fs_context *fc)
19961996
* btrfs or not, setting the whole super block RO. To make per-subvolume mounting
19971997
* work with different options work we need to keep backward compatibility.
19981998
*/
1999-
static int btrfs_reconfigure_for_mount(struct fs_context *fc, struct vfsmount *mnt)
1999+
static int btrfs_reconfigure_for_mount(struct fs_context *fc)
20002000
{
20012001
int ret = 0;
20022002

2003-
if (fc->sb_flags & SB_RDONLY)
2004-
return ret;
2005-
2006-
down_write(&mnt->mnt_sb->s_umount);
2007-
if (!(fc->sb_flags & SB_RDONLY) && (mnt->mnt_sb->s_flags & SB_RDONLY))
2003+
if (!(fc->sb_flags & SB_RDONLY) && (fc->root->d_sb->s_flags & SB_RDONLY))
20082004
ret = btrfs_reconfigure(fc);
2009-
up_write(&mnt->mnt_sb->s_umount);
2005+
20102006
return ret;
20112007
}
20122008

@@ -2059,17 +2055,18 @@ static int btrfs_get_tree_subvol(struct fs_context *fc)
20592055
security_free_mnt_opts(&fc->security);
20602056
fc->security = NULL;
20612057

2062-
mnt = fc_mount(dup_fc);
2063-
if (IS_ERR(mnt)) {
2064-
put_fs_context(dup_fc);
2065-
return PTR_ERR(mnt);
2058+
ret = vfs_get_tree(dup_fc);
2059+
if (!ret) {
2060+
ret = btrfs_reconfigure_for_mount(dup_fc);
2061+
up_write(&dup_fc->root->d_sb->s_umount);
20662062
}
2067-
ret = btrfs_reconfigure_for_mount(dup_fc, mnt);
2063+
if (!ret)
2064+
mnt = vfs_create_mount(dup_fc);
2065+
else
2066+
mnt = ERR_PTR(ret);
20682067
put_fs_context(dup_fc);
2069-
if (ret) {
2070-
mntput(mnt);
2071-
return ret;
2072-
}
2068+
if (IS_ERR(mnt))
2069+
return PTR_ERR(mnt);
20732070

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

0 commit comments

Comments
 (0)