From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [PATCH v3 28/34] NFSD: Use xdrgen XDR functions for NFSv3 READDIRPLUS arguments
Date: Tue, 13 Oct 2026 08:49:43 -0400 [thread overview]
Message-ID: <20261013124944.316808-9-cel@kernel.org> (raw)
In-Reply-To: <20261013124944.316808-1-cel@kernel.org>
Replace the NFSPROC3_READDIRPLUS entry in the nfsd_procedures3 array
with an entry that dispatches the xdrgen-generated
nfs_svc_decode_READDIRPLUS3args. A wrapper structure bridges the
generated xdrgen READDIRPLUS3args type and the legacy svc_fh
representation the NFSD VFS layer still uses.
The pc_argzero field is now set to zero for the NFSv3 READDIRPLUS
procedure. The xdrgen decoders are trusted to initialize all
arguments in the argp->xdrgen field, making the early defensive
memset unnecessary. The remaining argp fields are cleared as
needed.
nfs3svc_decode_readdirplusargs() no longer has any callers, so it
is removed.
Signed-off-by: Chuck Lever <cel@kernel.org>
---
fs/nfsd/nfs3proc.c | 62 +++++++++++++++++++++++++++-------------------
fs/nfsd/nfs3xdr.c | 26 -------------------
fs/nfsd/xdr3.h | 9 -------
3 files changed, 36 insertions(+), 61 deletions(-)
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
index 1764cd5e562d..307a3b195364 100644
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -225,6 +225,13 @@ struct READDIR3args_wrapper {
static_assert(offsetof(struct READDIR3args_wrapper, xdrgen) == 0);
+struct READDIRPLUS3args_wrapper {
+ struct READDIRPLUS3args xdrgen;
+ struct svc_fh fh;
+};
+
+static_assert(offsetof(struct READDIRPLUS3args_wrapper, xdrgen) == 0);
+
static int nfsd3_ftype3_to_mode(ftype3 ftype)
{
switch (ftype) {
@@ -1551,27 +1558,32 @@ static __be32 nfsd3_proc_readdir(struct svc_rqst *rqstp)
return rpc_success;
}
-/*
- * Read a portion of a directory, including file handles and attrs.
- * For now, we choose to ignore the dircount parameter.
+/**
+ * nfsd3_proc_readdirplus - READDIRPLUS: Extended read from directory
+ * @rqstp: RPC transaction context
+ *
+ * Return:
+ * %rpc_success: RPC executed successfully
+ *
+ * RPC synopsis:
+ * READDIRPLUS3res NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17;
*/
-static __be32
-nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
+static __be32 nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
{
- struct nfsd3_readdirargs *argp = rqstp->rq_argp;
+ struct READDIRPLUS3args_wrapper *argp = rqstp->rq_argp;
struct nfsd3_readdirres *resp = rqstp->rq_resp;
- loff_t offset;
+ loff_t offset = argp->xdrgen.cookie;
+ struct svc_fh *fhp = &argp->fh;
- trace_nfsd_vfs_readdir(rqstp, &argp->fh, argp->count, argp->cookie);
+ nfsd3_fh3_to_svc_fh(fhp, &argp->xdrgen.dir);
+ trace_nfsd_vfs_readdir(rqstp, fhp, argp->xdrgen.maxcount,
+ argp->xdrgen.cookie);
- nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
-
- fh_copy(&resp->fh, &argp->fh);
+ nfsd3_init_dirlist_pages(rqstp, resp, argp->xdrgen.maxcount);
+ fh_copy(&resp->fh, fhp);
resp->common.err = nfs_ok;
resp->cookie_offset = 0;
resp->rqstp = rqstp;
- offset = argp->cookie;
-
resp->status = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
if (resp->status != nfs_ok)
goto out;
@@ -1583,7 +1595,7 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
resp->status = nfsd_readdir(rqstp, &resp->fh, &offset,
&resp->common, nfs3svc_encode_entryplus3);
- memcpy(resp->verf, argp->verf, 8);
+ memcpy(resp->verf, argp->xdrgen.cookieverf, NFS3_COOKIEVERFSIZE);
nfs3svc_encode_cookie3(resp, offset);
/* Recycle only pages that were part of the reply */
@@ -1824,8 +1836,6 @@ static __be32 nfsd3_proc_commit(struct svc_rqst *rqstp)
* NFSv3 Server procedures.
* Only the results of non-idempotent operations are cached.
*/
-#define nfsd3_readdirplusargs nfsd3_readdirargs
-
static const struct svc_procedure nfsd_procedures3[22] = {
[NFSPROC3_NULL] = {
.pc_func = nfsd3_proc_null,
@@ -2018,15 +2028,15 @@ static const struct svc_procedure nfsd_procedures3[22] = {
.pc_name = "READDIR",
},
[NFSPROC3_READDIRPLUS] = {
- .pc_func = nfsd3_proc_readdirplus,
- .pc_decode = nfs3svc_decode_readdirplusargs,
- .pc_encode = nfs3svc_encode_readdirres,
- .pc_release = nfs3svc_release_fhandle,
- .pc_argsize = sizeof(struct nfsd3_readdirplusargs),
- .pc_argzero = sizeof(struct nfsd3_readdirplusargs),
- .pc_ressize = sizeof(struct nfsd3_readdirres),
- .pc_cachetype = RC_NOCACHE,
- .pc_name = "READDIRPLUS",
+ .pc_func = nfsd3_proc_readdirplus,
+ .pc_decode = nfs_svc_decode_READDIRPLUS3args,
+ .pc_encode = nfs3svc_encode_readdirres,
+ .pc_release = nfs3svc_release_fhandle,
+ .pc_argsize = sizeof(struct READDIRPLUS3args_wrapper),
+ .pc_argzero = 0,
+ .pc_ressize = sizeof(struct nfsd3_readdirres),
+ .pc_cachetype = RC_NOCACHE,
+ .pc_name = "READDIRPLUS",
},
[NFSPROC3_FSSTAT] = {
.pc_func = nfsd3_proc_fsstat,
@@ -2106,7 +2116,7 @@ union nfsd3_xdrstore {
struct LINK3args_wrapper linkargs;
struct LINK3res linkres;
struct READDIR3args_wrapper readdirargs;
- struct nfsd3_readdirargs readdirplusargs;
+ struct READDIRPLUS3args_wrapper readdirplusargs;
struct READLINK3res readlinkres;
struct READ3res readres;
struct nfsd3_writeres writeres;
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 0e83a2245c45..b1a930b857d7 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -224,32 +224,6 @@ svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
return xdr_stream_encode_item_absent(xdr) > 0;
}
-/*
- * XDR decode functions
- */
-
-bool
-nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
- struct nfsd3_readdirargs *args = rqstp->rq_argp;
- u32 dircount;
-
- if (!svcxdr_decode_nfs_fh3(xdr, &args->fh))
- return false;
- if (xdr_stream_decode_u64(xdr, &args->cookie) < 0)
- return false;
- args->verf = xdr_inline_decode(xdr, NFS3_COOKIEVERFSIZE);
- if (!args->verf)
- return false;
- /* dircount is ignored */
- if (xdr_stream_decode_u32(xdr, &dircount) < 0)
- return false;
- if (xdr_stream_decode_u32(xdr, &args->count) < 0)
- return false;
-
- return true;
-}
-
/*
* XDR encode functions
*/
diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h
index 3fb4a01011ca..4c4642077342 100644
--- a/fs/nfsd/xdr3.h
+++ b/fs/nfsd/xdr3.h
@@ -24,13 +24,6 @@ struct nfsd3_accessargs {
__u32 access;
};
-struct nfsd3_readdirargs {
- struct svc_fh fh;
- __u64 cookie;
- __u32 count;
- __be32 * verf;
-};
-
struct nfsd3_getaclargs {
struct svc_fh fh;
__u32 mask;
@@ -113,8 +106,6 @@ struct nfsd3_getaclres {
struct kstat stat;
};
-bool nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
-
bool nfs3svc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
bool nfs3svc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
--
2.55.0
next prev parent reply other threads:[~2026-10-13 12:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 12:49 [PATCH v3 20/34] NFSD: Use xdrgen XDR functions for the NFSv3 RMDIR procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 21/34] NFSD: Use xdrgen XDR functions for the NFSv3 RENAME procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 22/34] NFSD: Use xdrgen XDR functions for the NFSv3 LINK procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 23/34] NFSD: Use xdrgen XDR functions for the NFSv3 FSSTAT procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 24/34] NFSD: Use xdrgen XDR functions for the NFSv3 FSINFO procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 25/34] NFSD: Use xdrgen XDR functions for the NFSv3 PATHCONF procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 26/34] NFSD: Use xdrgen XDR functions for the NFSv3 COMMIT procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 27/34] NFSD: Use xdrgen XDR functions for NFSv3 READDIR arguments Chuck Lever
2026-10-13 12:49 ` Chuck Lever [this message]
2026-10-13 12:49 ` [PATCH v3 29/34] NFSD: Refactor NFSv3 directory cookie encoding Chuck Lever
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=20261013124944.316808-9-cel@kernel.org \
--to=cel@kernel.org \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.