Hi Trond, Anna,
Here's a set of patches that converts NFS to use the mount API. Note that
there are a lot of preliminary patches, some from David and some from Al.
The final patch (the one that does the actual conversion) from the David's
initial posting has been split into 4 separate patches, and the entire set
has been rebased on top of v5.3-rc6.
Changes since v3:
- changed license and copyright text in fs/nfs/fs_context.c
Changes since v2:
- fixed the conversion of the nconnect= option
- added '#if IS_ENABLED(CONFIG_NFS_V4)' around nfs4_parse_monolithic()
to avoid unused-function warning when compiling with v4 disabled
Chagnes since v1:
- split up patch 23 into 4 separate patches
-Scott
Al Viro (15):
saner calling conventions for nfs_fs_mount_common()
nfs: stash server into struct nfs_mount_info
nfs: lift setting mount_info from nfs4_remote{,_referral}_mount
nfs: fold nfs4_remote_fs_type and nfs4_remote_referral_fs_type
nfs: don't bother setting/restoring export_path around
do_nfs_root_mount()
nfs4: fold nfs_do_root_mount/nfs_follow_remote_path
nfs: lift setting mount_info from nfs_xdev_mount()
nfs: stash nfs_subversion reference into nfs_mount_info
nfs: don't bother passing nfs_subversion to ->try_mount() and
nfs_fs_mount_common()
nfs: merge xdev and remote file_system_type
nfs: unexport nfs_fs_mount_common()
nfs: don't pass nfs_subversion to ->create_server()
nfs: get rid of mount_info ->fill_super()
nfs_clone_sb_security(): simplify the check for server bogosity
nfs: get rid of ->set_security()
David Howells (8):
NFS: Move mount parameterisation bits into their own file
NFS: Constify mount argument match tables
NFS: Rename struct nfs_parsed_mount_data to struct nfs_fs_context
NFS: Split nfs_parse_mount_options()
NFS: Deindent nfs_fs_context_parse_option()
NFS: Add a small buffer in nfs_fs_context to avoid string dup
NFS: Do some tidying of the parsing code
NFS: Add fs_context support.
Scott Mayhew (3):
NFS: rename nfs_fs_context pointer arg in a few functions
NFS: Convert mount option parsing to use functionality from
fs_parser.h
NFS: Attach supplementary error information to fs_context.
fs/nfs/Makefile | 2 +-
fs/nfs/client.c | 80 +-
fs/nfs/fs_context.c | 1422 ++++++++++++++++++++++++++++
fs/nfs/fscache.c | 2 +-
fs/nfs/getroot.c | 73 +-
fs/nfs/internal.h | 132 +--
fs/nfs/namespace.c | 144 +--
fs/nfs/nfs3_fs.h | 2 +-
fs/nfs/nfs3client.c | 6 +-
fs/nfs/nfs3proc.c | 2 +-
fs/nfs/nfs4_fs.h | 9 +-
fs/nfs/nfs4client.c | 99 +-
fs/nfs/nfs4namespace.c | 285 +++---
fs/nfs/nfs4proc.c | 2 +-
fs/nfs/nfs4super.c | 257 ++---
fs/nfs/proc.c | 2 +-
fs/nfs/super.c | 1962 ++++-----------------------------------
include/linux/nfs_xdr.h | 9 +-
18 files changed, 2153 insertions(+), 2337 deletions(-)
create mode 100644 fs/nfs/fs_context.c
--
2.17.2
From: Al Viro <[email protected]>
The only possible values are nfs_fill_super and nfs_clone_super. The
latter is used only when crossing into a submount and it is almost
identical to the former; the only differences are
* ->s_time_gran unconditionally set to 1 (even for v2 mounts).
Regression dating back to 2012, actually.
* ->s_blocksize/->s_blocksize_bits set to that of parent.
Rather than messing with the method, stash ->s_blocksize_bits in
mount_info in submount case and after the (now unconditional)
call of nfs_fill_super() override ->s_blocksize/->s_blocksize_bits
if that has been set.
Reviewed-by: David Howells <[email protected]>
Signed-off-by: Al Viro <[email protected]>
---
fs/nfs/internal.h | 4 +--
fs/nfs/namespace.c | 2 +-
fs/nfs/nfs4super.c | 1 -
fs/nfs/super.c | 66 +++++++++++-----------------------------------
4 files changed, 18 insertions(+), 55 deletions(-)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 444d0fc2bcca..fa737e37f7c9 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -144,7 +144,7 @@ struct nfs_mount_request {
};
struct nfs_mount_info {
- void (*fill_super)(struct super_block *, struct nfs_mount_info *);
+ unsigned int inherited_bsize;
int (*set_security)(struct super_block *, struct dentry *, struct nfs_mount_info *);
struct nfs_parsed_mount_data *parsed;
struct nfs_clone_mount *cloned;
@@ -403,8 +403,6 @@ int nfs_set_sb_security(struct super_block *, struct dentry *, struct nfs_mount_
int nfs_clone_sb_security(struct super_block *, struct dentry *, struct nfs_mount_info *);
struct dentry *nfs_fs_mount(struct file_system_type *, int, const char *, void *);
void nfs_kill_super(struct super_block *);
-void nfs_fill_super(struct super_block *, struct nfs_mount_info *);
-void nfs_clone_super(struct super_block *, struct nfs_mount_info *);
extern struct rpc_stat nfs_rpcstat;
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 970f92a860ed..7bc5b9b8f5ea 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -229,7 +229,7 @@ struct vfsmount *nfs_do_submount(struct dentry *dentry, struct nfs_fh *fh,
.authflavor = authflavor,
};
struct nfs_mount_info mount_info = {
- .fill_super = nfs_clone_super,
+ .inherited_bsize = sb->s_blocksize_bits,
.set_security = nfs_clone_sb_security,
.cloned = &mountdata,
.mntfh = fh,
diff --git a/fs/nfs/nfs4super.c b/fs/nfs/nfs4super.c
index b6cf62125380..d387c3c3b600 100644
--- a/fs/nfs/nfs4super.c
+++ b/fs/nfs/nfs4super.c
@@ -224,7 +224,6 @@ static struct dentry *nfs4_referral_mount(struct file_system_type *fs_type,
{
struct nfs_clone_mount *data = raw_data;
struct nfs_mount_info mount_info = {
- .fill_super = nfs_fill_super,
.set_security = nfs_clone_sb_security,
.cloned = data,
.nfs_mod = &nfs_v4,
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 157d340333c8..89751ce21110 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2339,29 +2339,9 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
EXPORT_SYMBOL_GPL(nfs_remount);
/*
- * Initialise the common bits of the superblock
+ * Finish setting up an NFS superblock
*/
-static void nfs_initialise_sb(struct super_block *sb)
-{
- struct nfs_server *server = NFS_SB(sb);
-
- sb->s_magic = NFS_SUPER_MAGIC;
-
- /* We probably want something more informative here */
- snprintf(sb->s_id, sizeof(sb->s_id),
- "%u:%u", MAJOR(sb->s_dev), MINOR(sb->s_dev));
-
- if (sb->s_blocksize == 0)
- sb->s_blocksize = nfs_block_bits(server->wsize,
- &sb->s_blocksize_bits);
-
- nfs_super_set_maxbytes(sb, server->maxfilesize);
-}
-
-/*
- * Finish setting up an NFS2/3 superblock
- */
-void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
+static void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
{
struct nfs_parsed_mount_data *data = mount_info->parsed;
struct nfs_server *server = NFS_SB(sb);
@@ -2382,35 +2362,17 @@ void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
sb->s_export_op = &nfs_export_ops;
}
- nfs_initialise_sb(sb);
-}
-EXPORT_SYMBOL_GPL(nfs_fill_super);
-
-/*
- * Finish setting up a cloned NFS2/3/4 superblock
- */
-void nfs_clone_super(struct super_block *sb,
- struct nfs_mount_info *mount_info)
-{
- const struct super_block *old_sb = mount_info->cloned->sb;
- struct nfs_server *server = NFS_SB(sb);
+ sb->s_magic = NFS_SUPER_MAGIC;
- sb->s_blocksize_bits = old_sb->s_blocksize_bits;
- sb->s_blocksize = old_sb->s_blocksize;
- sb->s_maxbytes = old_sb->s_maxbytes;
- sb->s_xattr = old_sb->s_xattr;
- sb->s_op = old_sb->s_op;
- sb->s_time_gran = 1;
- sb->s_export_op = old_sb->s_export_op;
+ /* We probably want something more informative here */
+ snprintf(sb->s_id, sizeof(sb->s_id),
+ "%u:%u", MAJOR(sb->s_dev), MINOR(sb->s_dev));
- if (server->nfs_client->rpc_ops->version != 2) {
- /* The VFS shouldn't apply the umask to mode bits. We will do
- * so ourselves when necessary.
- */
- sb->s_flags |= SB_POSIXACL;
- }
+ if (sb->s_blocksize == 0)
+ sb->s_blocksize = nfs_block_bits(server->wsize,
+ &sb->s_blocksize_bits);
- nfs_initialise_sb(sb);
+ nfs_super_set_maxbytes(sb, server->maxfilesize);
}
static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
@@ -2676,8 +2638,13 @@ static struct dentry *nfs_fs_mount_common(int flags, const char *dev_name,
}
if (!s->s_root) {
+ unsigned bsize = mount_info->inherited_bsize;
/* initial superblock/root creation */
- mount_info->fill_super(s, mount_info);
+ nfs_fill_super(s, mount_info);
+ if (bsize) {
+ s->s_blocksize_bits = bsize;
+ s->s_blocksize = 1U << bsize;
+ }
nfs_get_cache_cookie(s, mount_info->parsed, mount_info->cloned);
if (!(server->flags & NFS_MOUNT_UNSHARED))
s->s_iflags |= SB_I_MULTIROOT;
@@ -2712,7 +2679,6 @@ struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *raw_data)
{
struct nfs_mount_info mount_info = {
- .fill_super = nfs_fill_super,
.set_security = nfs_set_sb_security,
};
struct dentry *mntroot = ERR_PTR(-ENOMEM);
--
2.17.2
From: Al Viro <[email protected]>
Allow it to take ERR_PTR() for server and return ERR_CAST() of it in
such case. All callers used to open-code that...
Reviewed-by: David Howells <[email protected]>
Signed-off-by: Al Viro <[email protected]>
---
fs/nfs/nfs4super.c | 16 +---------------
fs/nfs/super.c | 11 ++++-------
2 files changed, 5 insertions(+), 22 deletions(-)
diff --git a/fs/nfs/nfs4super.c b/fs/nfs/nfs4super.c
index 04c57066a11a..baece9857bcf 100644
--- a/fs/nfs/nfs4super.c
+++ b/fs/nfs/nfs4super.c
@@ -110,21 +110,12 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags,
{
struct nfs_mount_info *mount_info = info;
struct nfs_server *server;
- struct dentry *mntroot = ERR_PTR(-ENOMEM);
mount_info->set_security = nfs_set_sb_security;
/* Get a volume representation */
server = nfs4_create_server(mount_info, &nfs_v4);
- if (IS_ERR(server)) {
- mntroot = ERR_CAST(server);
- goto out;
- }
-
- mntroot = nfs_fs_mount_common(server, flags, dev_name, mount_info, &nfs_v4);
-
-out:
- return mntroot;
+ return nfs_fs_mount_common(server, flags, dev_name, mount_info, &nfs_v4);
}
static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type,
@@ -280,11 +271,6 @@ nfs4_remote_referral_mount(struct file_system_type *fs_type, int flags,
/* create a new volume representation */
server = nfs4_create_referral_server(mount_info.cloned, mount_info.mntfh);
- if (IS_ERR(server)) {
- mntroot = ERR_CAST(server);
- goto out;
- }
-
mntroot = nfs_fs_mount_common(server, flags, dev_name, &mount_info, &nfs_v4);
out:
nfs_free_fhandle(mount_info.mntfh);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 703f595dce90..467d7a636f0b 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1903,9 +1903,6 @@ struct dentry *nfs_try_mount(int flags, const char *dev_name,
else
server = nfs_mod->rpc_ops->create_server(mount_info, nfs_mod);
- if (IS_ERR(server))
- return ERR_CAST(server);
-
return nfs_fs_mount_common(server, flags, dev_name, mount_info, nfs_mod);
}
EXPORT_SYMBOL_GPL(nfs_try_mount);
@@ -2641,6 +2638,9 @@ struct dentry *nfs_fs_mount_common(struct nfs_server *server,
};
int error;
+ if (IS_ERR(server))
+ return ERR_CAST(server);
+
if (server->flags & NFS_MOUNT_UNSHARED)
compare_super = NULL;
@@ -2789,10 +2789,7 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
/* create a new volume representation */
server = nfs_mod->rpc_ops->clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor);
- if (IS_ERR(server))
- mntroot = ERR_CAST(server);
- else
- mntroot = nfs_fs_mount_common(server, flags,
+ mntroot = nfs_fs_mount_common(server, flags,
dev_name, &mount_info, nfs_mod);
dprintk("<-- nfs_xdev_mount() = %ld\n",
--
2.17.2
From: Al Viro <[email protected]>
Do it in nfs_do_submount() instead. As a side benefit, nfs_clone_data
doesn't need ->fh and ->fattr anymore.
Reviewed-by: David Howells <[email protected]>
Signed-off-by: Al Viro <[email protected]>
---
fs/nfs/internal.h | 3 +--
fs/nfs/namespace.c | 35 +++++++++++++++++++++--------------
fs/nfs/super.c | 25 ++++---------------------
3 files changed, 26 insertions(+), 37 deletions(-)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index c132e683e1c9..eeb54b45875c 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -42,8 +42,6 @@ static inline int nfs_attr_use_mounted_on_fileid(struct nfs_fattr *fattr)
struct nfs_clone_mount {
const struct super_block *sb;
const struct dentry *dentry;
- struct nfs_fh *fh;
- struct nfs_fattr *fattr;
char *hostname;
char *mnt_path;
struct sockaddr *addr;
@@ -413,6 +411,7 @@ struct dentry * nfs_xdev_mount_common(struct file_system_type *, int,
const char *, struct nfs_mount_info *);
void nfs_kill_super(struct super_block *);
void nfs_fill_super(struct super_block *, struct nfs_mount_info *);
+void nfs_clone_super(struct super_block *, struct nfs_mount_info *);
extern struct rpc_stat nfs_rpcstat;
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 9287eb666322..7c78e6956639 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -19,6 +19,7 @@
#include <linux/vfs.h>
#include <linux/sunrpc/gss_api.h>
#include "internal.h"
+#include "nfs.h"
#define NFSDBG_FACILITY NFSDBG_VFS
@@ -210,16 +211,6 @@ void nfs_release_automount_timer(void)
cancel_delayed_work(&nfs_automount_task);
}
-/*
- * Clone a mountpoint of the appropriate type
- */
-static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
- const char *devname,
- struct nfs_clone_mount *mountdata)
-{
- return vfs_submount(mountdata->dentry, &nfs_xdev_fs_type, devname, mountdata);
-}
-
/**
* nfs_do_submount - set up mountpoint when crossing a filesystem boundary
* @dentry: parent directory
@@ -231,13 +222,20 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
struct vfsmount *nfs_do_submount(struct dentry *dentry, struct nfs_fh *fh,
struct nfs_fattr *fattr, rpc_authflavor_t authflavor)
{
+ struct super_block *sb = dentry->d_sb;
struct nfs_clone_mount mountdata = {
- .sb = dentry->d_sb,
+ .sb = sb,
.dentry = dentry,
- .fh = fh,
- .fattr = fattr,
.authflavor = authflavor,
};
+ struct nfs_mount_info mount_info = {
+ .fill_super = nfs_clone_super,
+ .set_security = nfs_clone_sb_security,
+ .cloned = &mountdata,
+ .mntfh = fh,
+ };
+ struct nfs_subversion *nfs_mod = NFS_SB(sb)->nfs_client->cl_nfs_mod;
+ struct nfs_server *server;
struct vfsmount *mnt;
char *page = (char *) __get_free_page(GFP_USER);
char *devname;
@@ -245,12 +243,21 @@ struct vfsmount *nfs_do_submount(struct dentry *dentry, struct nfs_fh *fh,
if (page == NULL)
return ERR_PTR(-ENOMEM);
+ server = nfs_mod->rpc_ops->clone_server(NFS_SB(sb), fh,
+ fattr, authflavor);
+ if (IS_ERR(server))
+ return ERR_CAST(server);
+
+ mount_info.server = server;
+
devname = nfs_devname(dentry, page, PAGE_SIZE);
if (IS_ERR(devname))
mnt = ERR_CAST(devname);
else
- mnt = nfs_do_clone_mount(NFS_SB(dentry->d_sb), devname, &mountdata);
+ mnt = vfs_submount(dentry, &nfs_xdev_fs_type, devname, &mount_info);
+ if (mount_info.server)
+ nfs_free_server(mount_info.server);
free_page((unsigned long)page);
return mnt;
}
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 10544ef8de57..7fc354207347 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2386,7 +2386,7 @@ EXPORT_SYMBOL_GPL(nfs_fill_super);
/*
* Finish setting up a cloned NFS2/3/4 superblock
*/
-static void nfs_clone_super(struct super_block *sb,
+void nfs_clone_super(struct super_block *sb,
struct nfs_mount_info *mount_info)
{
const struct super_block *old_sb = mount_info->cloned->sb;
@@ -2771,27 +2771,10 @@ static struct dentry *
nfs_xdev_mount(struct file_system_type *fs_type, int flags,
const char *dev_name, void *raw_data)
{
- struct nfs_clone_mount *data = raw_data;
- struct nfs_mount_info mount_info = {
- .fill_super = nfs_clone_super,
- .set_security = nfs_clone_sb_security,
- .cloned = data,
- };
- struct dentry *mntroot = ERR_PTR(-ENOMEM);
- struct nfs_subversion *nfs_mod = NFS_SB(data->sb)->nfs_client->cl_nfs_mod;
-
- dprintk("--> nfs_xdev_mount()\n");
+ struct nfs_mount_info *info = raw_data;
+ struct nfs_subversion *nfs_mod = NFS_SB(info->cloned->sb)->nfs_client->cl_nfs_mod;
- mount_info.mntfh = mount_info.cloned->fh;
-
- /* create a new volume representation */
- mount_info.server = nfs_mod->rpc_ops->clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor);
-
- mntroot = nfs_fs_mount_common(flags, dev_name, &mount_info, nfs_mod);
-
- dprintk("<-- nfs_xdev_mount() = %ld\n",
- IS_ERR(mntroot) ? PTR_ERR(mntroot) : 0L);
- return mntroot;
+ return nfs_fs_mount_common(flags, dev_name, info, nfs_mod);
}
#if IS_ENABLED(CONFIG_NFS_V4)
--
2.17.2