2021-10-14 19:17:38

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH 0/5] NFS: Re-probe server capabilities on remount

From: Anna Schumaker <[email protected]>

These patches hook into the nfs_reconfigure() function to reset and
reprobe a server's capabilities when remounted. This could be useful if
a server is upgraded to support a new NFS v4.2 feature or if it has
other changes that can only be detected at mount-time.

Thoughts?
Anna

Anna Schumaker (5):
NFS: Create an nfs4_server_set_init_caps() function
NFS: Move nfs_probe_destination() into the generic client
NFS: Replace calls to nfs_probe_fsinfo() with nfs_probe_server()
NFS: Call nfs_probe_server() during a fscontext-reconfigure event
NFS: Unexport nfs_probe_fsinfo()

fs/nfs/client.c | 37 ++++++++++++++++++--------
fs/nfs/internal.h | 3 ++-
fs/nfs/nfs4client.c | 65 ++++++++++++++-------------------------------
fs/nfs/nfs4proc.c | 2 ++
fs/nfs/super.c | 7 ++++-
5 files changed, 56 insertions(+), 58 deletions(-)

--
2.33.0


2021-10-14 19:17:39

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH 4/5] NFS: Call nfs_probe_server() during a fscontext-reconfigure event

From: Anna Schumaker <[email protected]>

This lets us update the server's attributes when the user does a "mount
-o remount" on the filesystem.

Signed-off-by: Anna Schumaker <[email protected]>
---
fs/nfs/super.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index e65c83494c05..3aced401735c 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1004,6 +1004,7 @@ int nfs_reconfigure(struct fs_context *fc)
struct nfs_fs_context *ctx = nfs_fc2context(fc);
struct super_block *sb = fc->root->d_sb;
struct nfs_server *nfss = sb->s_fs_info;
+ int ret;

sync_filesystem(sb);

@@ -1028,7 +1029,11 @@ int nfs_reconfigure(struct fs_context *fc)
}

/* compare new mount options with old ones */
- return nfs_compare_remount_data(nfss, ctx);
+ ret = nfs_compare_remount_data(nfss, ctx);
+ if (ret)
+ return ret;
+
+ return nfs_probe_server(nfss, NFS_FH(d_inode(fc->root)));
}
EXPORT_SYMBOL_GPL(nfs_reconfigure);

--
2.33.0

2021-10-14 19:18:08

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH 5/5] NFS: Unexport nfs_probe_fsinfo()

From: Anna Schumaker <[email protected]>

All the callers are now in client.c so we can remove the
EXPORT_SYMBOL_GPL() and make it static.

Signed-off-by: Anna Schumaker <[email protected]>
---
fs/nfs/client.c | 3 +--
fs/nfs/internal.h | 1 -
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 7f30a6c1a0b0..1e4dc1ab9312 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -828,7 +828,7 @@ static void nfs_server_set_fsinfo(struct nfs_server *server,
/*
* Probe filesystem information, including the FSID on v2/v3
*/
-int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, struct nfs_fattr *fattr)
+static int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, struct nfs_fattr *fattr)
{
struct nfs_fsinfo fsinfo;
struct nfs_client *clp = server->nfs_client;
@@ -862,7 +862,6 @@ int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, struct nfs

return 0;
}
-EXPORT_SYMBOL_GPL(nfs_probe_fsinfo);

/*
* Grab the destination's particulars, including lease expiry time.
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 508cb64c2661..12f6acb483bb 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -193,7 +193,6 @@ extern void nfs_clients_exit(struct net *net);
extern struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *);
int nfs_create_rpc_client(struct nfs_client *, const struct nfs_client_initdata *, rpc_authflavor_t);
struct nfs_client *nfs_get_client(const struct nfs_client_initdata *);
-int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *);
int nfs_probe_server(struct nfs_server *, struct nfs_fh *);
void nfs_server_insert_lists(struct nfs_server *);
void nfs_server_remove_lists(struct nfs_server *);
--
2.33.0

2021-10-14 19:18:08

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH 1/5] NFS: Create an nfs4_server_set_init_caps() function

From: Anna Schumaker <[email protected]>

And call it before doing an FSINFO probe to reset to the baseline
capabilities before probing.

Signed-off-by: Anna Schumaker <[email protected]>
---
fs/nfs/internal.h | 1 +
fs/nfs/nfs4client.c | 41 +++++++++++++++++++++++------------------
fs/nfs/nfs4proc.c | 2 ++
3 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 7483f196c6ef..690271adb294 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -209,6 +209,7 @@ extern struct nfs_client *
nfs4_find_client_sessionid(struct net *, const struct sockaddr *,
struct nfs4_sessionid *, u32);
extern struct nfs_server *nfs_create_server(struct fs_context *);
+extern void nfs4_server_set_init_caps(struct nfs_server *);
extern struct nfs_server *nfs4_create_server(struct fs_context *);
extern struct nfs_server *nfs4_create_referral_server(struct fs_context *);
extern int nfs4_update_server(struct nfs_server *server, const char *hostname,
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index af57332503be..3fb0ca92377c 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -1059,31 +1059,15 @@ static void nfs4_session_limit_xasize(struct nfs_server *server)
#endif
}

-static int nfs4_server_common_setup(struct nfs_server *server,
- struct nfs_fh *mntfh, bool auth_probe)
+void nfs4_server_set_init_caps(struct nfs_server *server)
{
- struct nfs_fattr *fattr;
- int error;
-
- /* data servers support only a subset of NFSv4.1 */
- if (is_ds_only_client(server->nfs_client))
- return -EPROTONOSUPPORT;
-
- fattr = nfs_alloc_fattr();
- if (fattr == NULL)
- return -ENOMEM;
-
- /* We must ensure the session is initialised first */
- error = nfs4_init_session(server->nfs_client);
- if (error < 0)
- goto out;
-
/* Set the basic capabilities */
server->caps |= server->nfs_client->cl_mvops->init_caps;
if (server->flags & NFS_MOUNT_NORDIRPLUS)
server->caps &= ~NFS_CAP_READDIRPLUS;
if (server->nfs_client->cl_proto == XPRT_TRANSPORT_RDMA)
server->caps &= ~NFS_CAP_READ_PLUS;
+
/*
* Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower
* authentication.
@@ -1091,7 +1075,28 @@ static int nfs4_server_common_setup(struct nfs_server *server,
if (nfs4_disable_idmapping &&
server->client->cl_auth->au_flavor == RPC_AUTH_UNIX)
server->caps |= NFS_CAP_UIDGID_NOMAP;
+}

+static int nfs4_server_common_setup(struct nfs_server *server,
+ struct nfs_fh *mntfh, bool auth_probe)
+{
+ struct nfs_fattr *fattr;
+ int error;
+
+ /* data servers support only a subset of NFSv4.1 */
+ if (is_ds_only_client(server->nfs_client))
+ return -EPROTONOSUPPORT;
+
+ fattr = nfs_alloc_fattr();
+ if (fattr == NULL)
+ return -ENOMEM;
+
+ /* We must ensure the session is initialised first */
+ error = nfs4_init_session(server->nfs_client);
+ if (error < 0)
+ goto out;
+
+ nfs4_server_set_init_caps(server);

/* Probe the root fh to retrieve its FSID and filehandle */
error = nfs4_get_rootfh(server, mntfh, auth_probe);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index fc0be32b19fc..77bbdced702f 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3923,6 +3923,8 @@ int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle)
.interruptible = true,
};
int err;
+
+ nfs4_server_set_init_caps(server);
do {
err = nfs4_handle_exception(server,
_nfs4_server_capabilities(server, fhandle),
--
2.33.0

2021-10-14 19:18:08

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH 3/5] NFS: Replace calls to nfs_probe_fsinfo() with nfs_probe_server()

From: Anna Schumaker <[email protected]>

Clean up. There are a few places where we want to probe the server, but
don't actually care about the fsinfo result. Change these to use
nfs_probe_server(), which handles the fattr allocation for us.

Signed-off-by: Anna Schumaker <[email protected]>
---
fs/nfs/client.c | 10 +---------
fs/nfs/nfs4client.c | 8 +-------
2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index b7b79a348c2b..7f30a6c1a0b0 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1082,7 +1082,6 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
rpc_authflavor_t flavor)
{
struct nfs_server *server;
- struct nfs_fattr *fattr_fsinfo;
int error;

server = nfs_alloc_server();
@@ -1091,11 +1090,6 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,

server->cred = get_cred(source->cred);

- error = -ENOMEM;
- fattr_fsinfo = nfs_alloc_fattr();
- if (fattr_fsinfo == NULL)
- goto out_free_server;
-
/* Copy data from the source */
server->nfs_client = source->nfs_client;
server->destroy = source->destroy;
@@ -1111,7 +1105,7 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
goto out_free_server;

/* probe the filesystem info for this server filesystem */
- error = nfs_probe_fsinfo(server, fh, fattr_fsinfo);
+ error = nfs_probe_server(server, fh);
if (error < 0)
goto out_free_server;

@@ -1125,11 +1119,9 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
nfs_server_insert_lists(server);
server->mount_time = jiffies;

- nfs_free_fattr(fattr_fsinfo);
return server;

out_free_server:
- nfs_free_fattr(fattr_fsinfo);
nfs_free_server(server);
return ERR_PTR(error);
}
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 85978ecb727e..d8b5a250ca05 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -1080,17 +1080,12 @@ void nfs4_server_set_init_caps(struct nfs_server *server)
static int nfs4_server_common_setup(struct nfs_server *server,
struct nfs_fh *mntfh, bool auth_probe)
{
- struct nfs_fattr *fattr;
int error;

/* data servers support only a subset of NFSv4.1 */
if (is_ds_only_client(server->nfs_client))
return -EPROTONOSUPPORT;

- fattr = nfs_alloc_fattr();
- if (fattr == NULL)
- return -ENOMEM;
-
/* We must ensure the session is initialised first */
error = nfs4_init_session(server->nfs_client);
if (error < 0)
@@ -1108,7 +1103,7 @@ static int nfs4_server_common_setup(struct nfs_server *server,
(unsigned long long) server->fsid.minor);
nfs_display_fhandle(mntfh, "Pseudo-fs root FH");

- error = nfs_probe_fsinfo(server, mntfh, fattr);
+ error = nfs_probe_server(server, mntfh);
if (error < 0)
goto out;

@@ -1122,7 +1117,6 @@ static int nfs4_server_common_setup(struct nfs_server *server,
server->mount_time = jiffies;
server->destroy = nfs4_destroy_server;
out:
- nfs_free_fattr(fattr);
return error;
}

--
2.33.0