NFS: Don't hard-code the fs_type when submounting
Subsystems (2)
PATCH 1/1 NFS: Don't hard-code the fs_type when submounting
Hard-coding the fstype causes "nfs4" mounts to appear as "nfs", which breaks scripts that do "umount -at nfs4".
--- fs/nfs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/namespace.c +1 -1
@@ -153,7 +153,7 @@ struct vfsmount *nfs_d_automount(struct path *path)/* Open a new filesystem context, transferring parameters from the * parent superblock, including the network namespace. */ - fc =fs_context_for_submount (&nfs_fs_type, path->dentry); + fc =fs_context_for_submount (path->mnt->mnt_sb->s_type, path->dentry);if (IS_ERR (fc))return ERR_CAST (fc);
Signature · 1 line
2.24.1
Quoted 15 lines · Scott Mayhew
Hard-coding the fstype causes "nfs4" mounts to appear as "nfs", which breaks scripts that do "umount -at nfs4".
Reported-by Patrick Steinhardt <[email protected]>Fixes f2aedb713c28 ("NFS: Add fs_context support.")Signed-off-by Scott Mayhew <[email protected]>--- fs/nfs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/nfs/namespace.c +0
-0
fs/nfs/namespace.c struct vfsmount *nfs_d_automount(struct path *path) · line 158
Quoted 7 lines
fs/nfs/namespace.c +1
-1@@ -153,7 +153,7 @@ struct vfsmount *nfs_d_automount(struct path *path)/* Open a new filesystem context, transferring parameters from the * parent superblock, including the network namespace. */ - fc =fs_context_for_submount (&nfs_fs_type, path->dentry); + fc =fs_context_for_submount (path->mnt->mnt_sb->s_type, path->dentry);if (IS_ERR (fc))return ERR_CAST (fc);
Thanks for your fix! While this fixes the fstype with mount.nfs4(8), it still doesn't work when using mount(8):
$ sudo mount server:/mnt /mnt && findmnt -n -ofstype /mnt
nfs
$ sudo umount /mnt
$ sudo mount.nfs4 server:/mnt /mnt && findmnt -n -ofstype /mnt
nfs4I guess the issue is that the kernel doesn't yet know which NFS version the server provides at the point where fs_context_for_submount() is called.
Patrick
Quoted 33 lines · Patrick Steinhardt
Quoted 15 lines · Scott Mayhew
Hard-coding the fstype causes "nfs4" mounts to appear as "nfs", which breaks scripts that do "umount -at nfs4".
Reported-by Patrick Steinhardt <[email protected]>Fixes f2aedb713c28 ("NFS: Add fs_context support.")Signed-off-by Scott Mayhew <[email protected]>--- fs/nfs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/nfs/namespace.c +0
-0fs/nfs/namespace.c struct vfsmount *nfs_d_automount(struct path *path) · line 158
Quoted 7 lines
fs/nfs/namespace.c +1
-1@@ -153,7 +153,7 @@ struct vfsmount *nfs_d_automount(struct path *path)/* Open a new filesystem context, transferring parameters from the * parent superblock, including the network namespace. */ - fc =fs_context_for_submount (&nfs_fs_type, path->dentry); + fc =fs_context_for_submount (path->mnt->mnt_sb->s_type, path->dentry);if (IS_ERR (fc))return ERR_CAST (fc);Thanks for your fix! While this fixes the fstype with
mount.nfs4(8), it still doesn't work when using mount(8):$ sudo mount server:/mnt /mnt && findmnt -n -ofstype /mnt nfs $ sudo umount /mnt $ sudo mount.nfs4 server:/mnt /mnt && findmnt -n -ofstype /mnt nfs4
Quoted 3 lines
I guess the issue is that the kernel doesn't yet know which NFS version the server provides at the point where
fs_context_for_submount()is called.
Thanks for testing. Actually the problem is that the super_block's s_type is now based on the fs_context->fs_type field, which is set when the fs_context is created (way before the mount options are parsed). When you use mount(8) without specifying '-t nfs4', it defaults to using the mount.nfs helper, which calls mount(2) with 'nfs' as the fstype. I'm sending a second patch that double-checks the fs_context->fs_type after the mount options have been parsed. We still shouldn't be hard-coding the fstype in fs_context_for_submount() though (i.e. both patches are needed).
-Scott
Quoted 2 lines
Patrick
Quoted 39 lines · Scott Mayhew
Quoted 33 lines · Patrick Steinhardt
Quoted 15 lines · Scott Mayhew
Hard-coding the fstype causes "nfs4" mounts to appear as "nfs", which breaks scripts that do "umount -at nfs4".
Reported-by Patrick Steinhardt <[email protected]>Fixes f2aedb713c28 ("NFS: Add fs_context support.")Signed-off-by Scott Mayhew <[email protected]>--- fs/nfs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/nfs/namespace.c +0
-0fs/nfs/namespace.c struct vfsmount *nfs_d_automount(struct path *path) · line 158
Quoted 7 lines
fs/nfs/namespace.c +1
-1@@ -153,7 +153,7 @@ struct vfsmount *nfs_d_automount(struct path *path)/* Open a new filesystem context, transferring parameters from the * parent superblock, including the network namespace. */ - fc =fs_context_for_submount (&nfs_fs_type, path->dentry); + fc =fs_context_for_submount (path->mnt->mnt_sb->s_type, path->dentry);if (IS_ERR (fc))return ERR_CAST (fc);Thanks for your fix! While this fixes the fstype with
mount.nfs4(8), it still doesn't work when using mount(8):$ sudo mount server:/mnt /mnt && findmnt -n -ofstype /mnt nfs $ sudo umount /mnt $ sudo mount.nfs4 server:/mnt /mnt && findmnt -n -ofstype /mnt nfs4Quoted 3 lines
I guess the issue is that the kernel doesn't yet know which NFS version the server provides at the point where
fs_context_for_submount()is called.
Quoted 9 lines
Thanks for testing. Actually the problem is that the super_block's
s_typeis now based on thefs_context->fs_typefield, which is set when thefs_contextis created (way before the mount options are parsed). When you use mount(8) without specifying '-t nfs4', it defaults to using the mount.nfs helper, which calls mount(2) with 'nfs' as the fstype. I'm sending a second patch that double-checks thefs_context->fs_typeafter the mount options have been parsed. We still shouldn't be hard-coding the fstype infs_context_for_submount()though (i.e. both patches are needed).
I can confirm that the problem is fixed with both patches applied. Thanks a lot!
Patrick