From: Mike Snitzer <snitzer@kernel.org>
To: linux-nfs@vger.kernel.org
Cc: Jeff Layton <jlayton@kernel.org>,
Chuck Lever <chuck.lever@oracle.com>,
Trond Myklebust <trondmy@hammerspace.com>,
snitzer@hammerspace.com
Subject: [for-6.11 PATCH 25/29] nfs: implement v4 client support for NFS_LOCALIO_PROGRAM
Date: Fri, 7 Jun 2024 10:26:42 -0400 [thread overview]
Message-ID: <20240607142646.20924-26-snitzer@kernel.org> (raw)
In-Reply-To: <20240607142646.20924-1-snitzer@kernel.org>
While doing so, factor out nfs_init_localioclient() so it is used by
both nfs3client.c and nfs4client.c
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
fs/nfs/internal.h | 28 ++++++++++++++++++++--
fs/nfs/localio.c | 2 +-
fs/nfs/nfs3client.c | 19 +--------------
fs/nfs/nfs4_fs.h | 2 ++
fs/nfs/nfs4client.c | 23 ++++++++++++++++++
fs/nfs/nfs4proc.c | 3 +++
fs/nfs/nfs4xdr.c | 53 +++++++++++++++++++++++++++++++++++++++++
include/linux/nfs_xdr.h | 2 ++
8 files changed, 111 insertions(+), 21 deletions(-)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 9f81a94e798c..1b2adca930fa 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -452,7 +452,31 @@ extern void nfs_set_cache_invalid(struct inode *inode, unsigned long flags);
extern bool nfs_check_cache_invalid(struct inode *, unsigned long);
extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);
-#if defined(CONFIG_NFS_V3_LOCALIO)
+#if defined(CONFIG_NFS_V3_LOCALIO) || defined(CONFIG_NFS_V4_LOCALIO)
+/*
+ * Initialise an NFS localio client connection.
+ * Inlined here to allow nfs[34]client.c to share this code.
+ */
+static __always_inline void
+nfs_init_localioclient(struct nfs_client *clp,
+ const struct rpc_program *program, u32 vers)
+{
+ bool supported = false;
+
+ if (unlikely(!IS_ERR(clp->cl_rpcclient_localio)))
+ goto out;
+ clp->cl_rpcclient_localio = rpc_bind_new_program(clp->cl_rpcclient,
+ program, vers);
+ if (IS_ERR(clp->cl_rpcclient_localio))
+ goto out;
+ /* No errors! Assume that localio is supported */
+ supported = true;
+out:
+ dfprintk_rcu(CLIENT, "%s: server (%s) %s NFS v%u LOCALIO\n", __func__,
+ rpc_peeraddr2str(clp->cl_rpcclient_localio, RPC_DISPLAY_ADDR),
+ (supported ? "supports" : "does not support"), vers);
+}
+
/* localio.c */
extern void nfs_local_init(void);
extern void nfs_local_enable(struct nfs_client *);
@@ -507,7 +531,7 @@ static inline bool nfs_server_is_local(const struct nfs_client *clp)
{
return false;
}
-#endif /* CONFIG_NFS_V3_LOCALIO */
+#endif /* CONFIG_NFS_V3_LOCALIO || CONFIG_NFS_V4_LOCALIO */
/* super.c */
extern const struct super_operations nfs_sops;
diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c
index 145708444998..ab92c92f04e5 100644
--- a/fs/nfs/localio.c
+++ b/fs/nfs/localio.c
@@ -269,6 +269,7 @@ void nfs_local_probe(struct nfs_client *clp)
switch (clp->cl_rpcclient->cl_vers) {
case 3:
+ case 4:
/*
* Retrieve server's uuid via LOCALIO protocol and verify the
* server with that uuid it is known to be local. This ensures
@@ -280,7 +281,6 @@ void nfs_local_probe(struct nfs_client *clp)
if (!nfsd_uuid_is_local(&uuid))
return;
break;
- case 4:
default:
return; /* localio not supported */
}
diff --git a/fs/nfs/nfs3client.c b/fs/nfs/nfs3client.c
index c41122ee808c..123e7c1fd339 100644
--- a/fs/nfs/nfs3client.c
+++ b/fs/nfs/nfs3client.c
@@ -152,23 +152,6 @@ const struct rpc_program nfslocalio_program3 = {
*/
void nfs3_init_localioclient(struct nfs_client *clp)
{
- if (unlikely(!IS_ERR(clp->cl_rpcclient_localio)))
- goto out;
-
- clp->cl_rpcclient_localio = rpc_bind_new_program(clp->cl_rpcclient,
- &nfslocalio_program3, 3);
- if (IS_ERR(clp->cl_rpcclient_localio)) {
- dprintk_rcu("%s: server (%s) does not support NFS v3 LOCALIO\n", __func__,
- rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
- return;
- }
-out:
- /* No errors! Assume that localio is supported */
- dprintk_rcu("%s: server (%s) supports NFS v3 LOCALIO\n", __func__,
- rpc_peeraddr2str(clp->cl_rpcclient_localio, RPC_DISPLAY_ADDR));
-}
-#else
-void nfs3_init_localioclient(struct nfs_client *clp)
-{
+ nfs_init_localioclient(clp, &nfslocalio_program3, 3);
}
#endif /* CONFIG_NFS_V3_LOCALIO */
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 7024230f0d1d..a0a41917dec2 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -538,6 +538,8 @@ extern int nfs4_proc_commit(struct file *dst, __u64 offset, __u32 count, struct
extern const nfs4_stateid zero_stateid;
extern const nfs4_stateid invalid_stateid;
+extern void nfs4_init_localioclient(struct nfs_client *);
+
/* nfs4super.c */
struct nfs_mount_info;
extern struct nfs_subversion nfs_v4;
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 84573df5cf5a..d2f634aa1e1b 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -1384,3 +1384,26 @@ int nfs4_update_server(struct nfs_server *server, const char *hostname,
return nfs_probe_server(server, NFS_FH(d_inode(server->super->s_root)));
}
+
+#if defined(CONFIG_NFS_V4_LOCALIO)
+static struct rpc_stat nfslocalio_rpcstat = { &nfslocalio_program4 };
+static const struct rpc_version *nfslocalio_version[] = {
+ [4] = &nfslocalio_version4,
+};
+
+const struct rpc_program nfslocalio_program4 = {
+ .name = "nfslocalio",
+ .number = NFS_LOCALIO_PROGRAM,
+ .nrvers = ARRAY_SIZE(nfslocalio_version),
+ .version = nfslocalio_version,
+ .stats = &nfslocalio_rpcstat,
+};
+
+/*
+ * Initialise an NFSv4 localio client connection
+ */
+void nfs4_init_localioclient(struct nfs_client *clp)
+{
+ nfs_init_localioclient(clp, &nfslocalio_program4, 4);
+}
+#endif /* CONFIG_NFS_V4_LOCALIO */
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index c93c12063b3a..060bc8dbee61 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -10745,6 +10745,9 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
.discover_trunking = nfs4_discover_trunking,
.enable_swap = nfs4_enable_swap,
.disable_swap = nfs4_disable_swap,
+#if defined(CONFIG_NFS_V4_LOCALIO)
+ .init_localioclient = nfs4_init_localioclient,
+#endif
};
static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 1416099dfcd1..e6f3556a320e 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -7728,3 +7728,56 @@ const struct rpc_version nfs_version4 = {
.procs = nfs4_procedures,
.counts = nfs_version4_counts,
};
+
+#if defined(CONFIG_NFS_V4_LOCALIO)
+
+#define NFS4_filename_sz (1+(NFS4_MAXNAMLEN>>2))
+#define LOCALIO4_getuuidres_sz (1+NFS4_filename_sz)
+
+static void nfs4_xdr_enc_getuuidargs(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const void *data)
+{
+ /* void function */
+}
+
+static inline int nfs4_decode_getuuidresok(struct xdr_stream *xdr,
+ struct nfs_getuuidres *result)
+{
+ return decode_opaque_inline(xdr, &result->len, (char **)&result->uuid);
+}
+
+static int nfs4_xdr_dec_getuuidres(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ void *result)
+{
+ // FIXME: need proper handling that isn't abusing nfs_opnum4
+ int error = decode_op_hdr(xdr, LOCALIOPROC_GETUUID);
+ if (unlikely(error))
+ goto out;
+ error = nfs4_decode_getuuidresok(xdr, result);
+out:
+ return error;
+}
+
+static const struct rpc_procinfo nfs4_localio_procedures[] = {
+ [LOCALIOPROC_GETUUID] = {
+ .p_proc = LOCALIOPROC_GETUUID,
+ .p_encode = nfs4_xdr_enc_getuuidargs,
+ .p_decode = nfs4_xdr_dec_getuuidres,
+ .p_arglen = 1,
+ .p_replen = LOCALIO4_getuuidres_sz,
+ .p_statidx = LOCALIOPROC_GETUUID,
+ .p_name = "GETUUID",
+ },
+};
+
+static unsigned int nfs4_localio_counts[ARRAY_SIZE(nfs4_localio_procedures)];
+const struct rpc_version nfslocalio_version4 = {
+ .number = 4,
+ .nrprocs = ARRAY_SIZE(nfs4_localio_procedures),
+ .procs = nfs4_localio_procedures,
+ .counts = nfs4_localio_counts,
+};
+
+#endif /* CONFIG_NFS_V4_LOCALIO */
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 9a030e9bd9cf..b6a16eca4664 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1842,5 +1842,7 @@ extern const struct rpc_program nfsacl_program;
extern const struct rpc_version nfslocalio_version3;
extern const struct rpc_program nfslocalio_program3;
+extern const struct rpc_version nfslocalio_version4;
+extern const struct rpc_program nfslocalio_program4;
#endif
--
2.44.0
next prev parent reply other threads:[~2024-06-07 14:27 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-07 14:26 [for-6.11 PATCH 00/29] nfs/nfsd: add support for localio bypass Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 01/29] nfs: pass nfs_client to nfs_initiate_pgio Mike Snitzer
2024-06-10 12:02 ` Jeff Layton
2024-06-07 14:26 ` [for-6.11 PATCH 02/29] nfs: pass nfs_client to nfs_initiate_commit Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 03/29] nfs: pass descriptor thru nfs_initiate_pgio path Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 04/29] sunrpc: handle NULL req->defer in cache_defer_req Mike Snitzer
2024-06-10 12:21 ` Jeff Layton
2024-06-11 1:03 ` NeilBrown
2024-06-11 2:57 ` Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 05/29] sunrpc: export svc_defer Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 06/29] sunrpc: add rpcauth_map_to_svc_cred Mike Snitzer
2024-06-10 12:19 ` Jeff Layton
2024-06-07 14:26 ` [for-6.11 PATCH 07/29] sunrpc: add and export rpc_ntop6_addr_noscopeid Mike Snitzer
2024-06-09 12:36 ` Jeff Layton
2024-06-10 16:33 ` Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 08/29] nfs: move nfs_stat_to_errno to nfs.h Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 09/29] NFS: Manage boot verifier correctly in the case of localio Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 10/29] nfs/nfsd: add "local io" support Mike Snitzer
2024-06-10 12:43 ` Jeff Layton
2024-06-10 16:42 ` Mike Snitzer
2024-06-12 2:25 ` Mike Snitzer
2024-06-12 3:17 ` NeilBrown
2024-06-12 3:41 ` Mike Snitzer
2024-06-12 4:09 ` NeilBrown
2024-06-12 4:48 ` Mike Snitzer
2024-06-12 6:30 ` NeilBrown
2024-06-07 14:26 ` [for-6.11 PATCH 11/29] NFS: Enable localio for non-pNFS I/O Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 12/29] nfs/flexfiles: check local DS when making DS connections Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 13/29] pnfs/flexfiles: Enable localio for flexfiles I/O Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 14/29] NFS: Add tracepoints for nfs_local_enable and nfs_local_disable Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 15/29] NFS: Don't call filesystem write() routines directly Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 16/29] NFS: Don't call filesystem read() " Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 17/29] NFS: Use completion rather than flush_work() in nfs_local_commit() Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 18/29] NFS: localio writes need to use a normal workqueue Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 19/29] nfs/write: fix nfs_initiate_commit to return error from nfs_local_commit Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 20/29] nfs/localio: discontinue network address based localio setup Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 21/29] nfs_common: add NFS v3 LOCALIO protocol extension enablement Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 22/29] nfs: implement v3 client support for NFS_LOCALIO_PROGRAM Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 23/29] nfsd: implement v3 server " Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 24/29] nfs_common: add NFS v4 LOCALIO protocol extension enablement Mike Snitzer
2024-06-07 14:26 ` Mike Snitzer [this message]
2024-06-07 14:26 ` [for-6.11 PATCH 26/29] nfsd: implement v4 server support for NFS_LOCALIO_PROGRAM Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 27/29] nfs/nfsd: switch GETUUID to using {encode,decode}_opaque_fixed Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 28/29] nfs/nfsd: consolidate {encode,decode}_opaque_fixed in nfs_xdr.h Mike Snitzer
2024-06-07 14:26 ` [for-6.11 PATCH 29/29] nfs/localio: move managing nfsd_open_local_fh symbol to nfs_common Mike Snitzer
2024-06-07 18:06 ` [for-6.11 PATCH 30/29] nfs/nfsd: ensure localio server always uses its network namespace Mike Snitzer
2024-06-09 15:44 ` Chuck Lever
2024-06-10 16:50 ` Mike Snitzer
2024-06-10 22:37 ` Mike Snitzer
2024-06-07 18:09 ` [for-6.11 PATCH 00/29] nfs/nfsd: add support for localio bypass Mike Snitzer
2024-06-10 12:47 ` Jeff Layton
2024-06-10 16:47 ` Mike Snitzer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240607142646.20924-26-snitzer@kernel.org \
--to=snitzer@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=snitzer@hammerspace.com \
--cc=trondmy@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox