Linux NFS development
 help / color / mirror / Atom feed
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 26/29] nfsd: implement v4 server support for NFS_LOCALIO_PROGRAM
Date: Fri,  7 Jun 2024 10:26:43 -0400	[thread overview]
Message-ID: <20240607142646.20924-27-snitzer@kernel.org> (raw)
In-Reply-To: <20240607142646.20924-1-snitzer@kernel.org>

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
 fs/nfsd/localio.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfsd/nfsd.h    |  5 ++++
 fs/nfsd/nfssvc.c  | 25 ++++++++++-------
 3 files changed, 90 insertions(+), 10 deletions(-)

diff --git a/fs/nfsd/localio.c b/fs/nfsd/localio.c
index eda4fa49b316..e4d2adf9531f 100644
--- a/fs/nfsd/localio.c
+++ b/fs/nfsd/localio.c
@@ -16,6 +16,7 @@
 #include "filecache.h"
 #include "cache.h"
 #include "xdr3.h"
+#include "xdr4.h"
 
 #define NFSDDBG_FACILITY		NFSDDBG_FH
 
@@ -267,3 +268,72 @@ const struct svc_version nfsd_localio_version3 = {
 	.vs_xdrsize	= NFS3_SVC_XDRSIZE,
 };
 #endif /* CONFIG_NFSD_V3_LOCALIO */
+
+#if defined(CONFIG_NFSD_V4_LOCALIO)
+static bool nfs4svc_encode_getuuidres(struct svc_rqst *rqstp,
+				      struct xdr_stream *xdr)
+{
+	struct nfsd_getuuidres *resp = rqstp->rq_resp;
+	__be32 *p;
+
+	p = xdr_reserve_space(xdr, 8);
+	if (!p)
+		return 0;
+	*p++ = cpu_to_be32(LOCALIOPROC_GETUUID);
+	*p++ = resp->status;
+
+	if (resp->status == nfs_ok) {
+		u8 uuid[UUID_SIZE];
+
+		export_uuid(uuid, &resp->uuid);
+		p = xdr_reserve_space(xdr, 4 + UUID_SIZE);
+		if (!p)
+			return 0;
+		xdr_encode_opaque(p, uuid, UUID_SIZE);
+		dprintk("%s: nfs_ok uuid=%pU uuid_len=%lu\n",
+			__func__, uuid, sizeof(uuid));
+	}
+
+	return 1;
+}
+
+#define ST 1		/* status */
+#define NFS4_filename_sz	(1+(NFS4_MAXNAMLEN>>2))
+
+static const struct svc_procedure nfsd_localio_procedures4[2] = {
+	[LOCALIOPROC_NULL] = {
+		.pc_func = nfsd_proc_null,
+		.pc_decode = nfssvc_decode_voidarg,
+		.pc_encode = nfssvc_encode_voidres,
+		.pc_argsize = sizeof(struct nfsd_voidargs),
+		.pc_ressize = sizeof(struct nfsd_voidres),
+		.pc_cachetype = RC_NOCACHE,
+		.pc_xdrressize = ST,
+		.pc_name = "NULL",
+	},
+	[LOCALIOPROC_GETUUID] = {
+		.pc_func = nfsd_proc_getuuid,
+		.pc_decode = nfssvc_decode_voidarg,
+		.pc_encode = nfs4svc_encode_getuuidres,
+		.pc_argsize = sizeof(struct nfsd_voidargs),
+		.pc_ressize = sizeof(struct nfsd_getuuidres),
+		.pc_cachetype = RC_NOCACHE,
+		.pc_xdrressize = ST+NFS4_filename_sz,
+		.pc_name = "GETUUID",
+	},
+};
+
+static DEFINE_PER_CPU_ALIGNED(unsigned long,
+			      nfsd_localio_count4[ARRAY_SIZE(nfsd_localio_procedures4)]);
+const struct svc_version nfsd_localio_version4 = {
+	.vs_vers	        = 4,
+	.vs_nproc	        = 2,
+	.vs_proc	        = nfsd_localio_procedures4,
+	.vs_dispatch	        = nfsd_dispatch,
+	.vs_count	        = nfsd_localio_count4,
+	.vs_xdrsize	        = NFS4_SVC_XDRSIZE,
+	.vs_rpcb_optnl		= true,
+	.vs_need_cong_ctrl	= true,
+
+};
+#endif /* CONFIG_NFSD_V4_LOCALIO */
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index d6771669531d..dd225330837f 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -147,6 +147,11 @@ extern const struct svc_version nfsd_localio_version3;
 #else
 #define nfsd_localio_version3 NULL
 #endif
+#if defined(CONFIG_NFSD_V4_LOCALIO)
+extern const struct svc_version nfsd_localio_version4;
+#else
+#define nfsd_localio_version4 NULL
+#endif
 
 struct nfsd_net;
 
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index fab699699869..72ed4ed11c95 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -38,7 +38,7 @@
 atomic_t			nfsd_th_cnt = ATOMIC_INIT(0);
 extern struct svc_program	nfsd_program;
 static int			nfsd(void *vrqstp);
-#if defined(CONFIG_NFSD_V3_LOCALIO)
+#if defined(CONFIG_NFSD_V3_LOCALIO) || defined(CONFIG_NFSD_V4_LOCALIO)
 static int			nfsd_localio_rpcbind_set(struct net *,
 						     const struct svc_program *,
 						     u32, int,
@@ -47,7 +47,7 @@ static int			nfsd_localio_rpcbind_set(struct net *,
 static __be32			nfsd_localio_init_request(struct svc_rqst *,
 						const struct svc_program *,
 						struct svc_process_info *);
-#endif /* CONFIG_NFSD_V3_LOCALIO */
+#endif /* CONFIG_NFSD_V3_LOCALIO || CONFIG_NFSD_V4_LOCALIO */
 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
 static int			nfsd_acl_rpcbind_set(struct net *,
 						     const struct svc_program *,
@@ -91,9 +91,14 @@ DEFINE_SPINLOCK(nfsd_drc_lock);
 unsigned long	nfsd_drc_max_mem;
 unsigned long	nfsd_drc_mem_used;
 
-#if defined(CONFIG_NFSD_V3_LOCALIO)
+#if defined(CONFIG_NFSD_V3_LOCALIO) || defined(CONFIG_NFSD_V4_LOCALIO)
 static const struct svc_version *nfsd_localio_version[] = {
+#if defined(CONFIG_NFSD_V3_LOCALIO)
 	[3] = &nfsd_localio_version3,
+#endif
+#if defined(CONFIG_NFSD_V4_LOCALIO)
+	[4] = &nfsd_localio_version4,
+#endif
 };
 
 #define NFSD_LOCALIO_MINVERS            3
@@ -109,7 +114,7 @@ static struct svc_program	nfsd_localio_program = {
 	.pg_init_request	= nfsd_localio_init_request,
 	.pg_rpcbind_set		= nfsd_localio_rpcbind_set,
 };
-#endif /* CONFIG_NFSD_V3_LOCALIO */
+#endif /* CONFIG_NFSD_V3_LOCALIO || CONFIG_NFSD_V4_LOCALIO */
 
 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
 static const struct svc_version *nfsd_acl_version[] = {
@@ -125,9 +130,9 @@ static const struct svc_version *nfsd_acl_version[] = {
 #define NFSD_ACL_NRVERS		ARRAY_SIZE(nfsd_acl_version)
 
 static struct svc_program	nfsd_acl_program = {
-#if defined(CONFIG_NFSD_V3_LOCALIO)
+#if defined(CONFIG_NFSD_V3_LOCALIO) || defined(CONFIG_NFSD_V4_LOCALIO)
 	.pg_next		= &nfsd_localio_program,
-#endif /* CONFIG_NFSD_V3_LOCALIO */
+#endif /* CONFIG_NFSD_V3_LOCALIO || CONFIG_NFSD_V4_LOCALIO */
 	.pg_prog		= NFS_ACL_PROGRAM,
 	.pg_nvers		= NFSD_ACL_NRVERS,
 	.pg_vers		= nfsd_acl_version,
@@ -157,9 +162,9 @@ struct svc_program		nfsd_program = {
 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
 	.pg_next		= &nfsd_acl_program,
 #else
-#if defined(CONFIG_NFSD_V3_LOCALIO)
+#if defined(CONFIG_NFSD_V3_LOCALIO) || defined(CONFIG_NFSD_V4_LOCALIO)
 	.pg_next		= &nfsd_localio_program,
-#endif /* CONFIG_NFSD_V3_LOCALIO */
+#endif /* CONFIG_NFSD_V3_LOCALIO || CONFIG_NFSD_V4_LOCALIO */
 #endif
 	.pg_prog		= NFS_PROGRAM,		/* program number */
 	.pg_nvers		= NFSD_NRVERS,		/* nr of entries in nfsd_version */
@@ -855,7 +860,7 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred, const char *scop
 	return error;
 }
 
-#if defined(CONFIG_NFSD_V3_LOCALIO)
+#if defined(CONFIG_NFSD_V3_LOCALIO) || defined(CONFIG_NFSD_V4_LOCALIO)
 static bool
 nfsd_support_localio_version(int vers)
 {
@@ -889,7 +894,7 @@ nfsd_localio_init_request(struct svc_rqst *rqstp,
 
 	return rpc_prog_unavail;
 }
-#endif /* CONFIG_NFSD_V3_LOCALIO */
+#endif /* CONFIG_NFSD_V3_LOCALIO || CONFIG_NFSD_V4_LOCALIO */
 
 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
 static bool
-- 
2.44.0


  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 ` [for-6.11 PATCH 25/29] nfs: implement v4 client support for NFS_LOCALIO_PROGRAM Mike Snitzer
2024-06-07 14:26 ` Mike Snitzer [this message]
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-27-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