All of lore.kernel.org
 help / color / mirror / Atom feed
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 v1 10/13] NFSD: Remove the hand-coded XDR helpers for the NFS_ACLv3 procedures
Date: Sun, 25 Oct 2026 11:16:19 -0400	[thread overview]
Message-ID: <20261025151622.141025-11-cel@kernel.org> (raw)
In-Reply-To: <20261025151622.141025-1-cel@kernel.org>

The NFS_ACLv3 GETACL and SETACL procedures were the last callers of
svcxdr_decode_nfs_fh3(), svcxdr_encode_nfsstat3(), and
svcxdr_encode_post_op_attr(). With their arguments and replies now
handled by xdrgen, the three helpers have no caller, and
svcxdr_encode_fattr3(), nfs3_ftypes[], and encode_nfstime3() have no
caller other than svcxdr_encode_post_op_attr().

Remove the hand-coded helpers and their declarations in xdr3.h.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/nfs3xdr.c | 166 ----------------------------------------------
 fs/nfsd/xdr3.h    |   5 --
 2 files changed, 171 deletions(-)

diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 850647ac98bb..8e231e0eb0f8 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -20,172 +20,6 @@
 
 #include "nfs3xdr_gen.h"
 
-/*
- * Mapping of S_IF* types to NFS file types
- */
-static const u32 nfs3_ftypes[] = {
-	NF3NON,  NF3FIFO, NF3CHR, NF3BAD,
-	NF3DIR,  NF3BAD,  NF3BLK, NF3BAD,
-	NF3REG,  NF3BAD,  NF3LNK, NF3BAD,
-	NF3SOCK, NF3BAD,  NF3LNK, NF3BAD,
-};
-
-
-/*
- * Basic NFSv3 data types (RFC 1813 Sections 2.5 and 2.6)
- */
-
-static __be32 *
-encode_nfstime3(__be32 *p, const struct timespec64 *time)
-{
-	*p++ = cpu_to_be32((u32)time->tv_sec);
-	*p++ = cpu_to_be32(time->tv_nsec);
-
-	return p;
-}
-
-/**
- * svcxdr_decode_nfs_fh3 - Decode an NFSv3 file handle
- * @xdr: XDR stream positioned at an undecoded NFSv3 FH
- * @fhp: OUT: filled-in server file handle
- *
- * Return values:
- *  %false: The encoded file handle was not valid
- *  %true: @fhp has been initialized
- */
-bool
-svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp)
-{
-	__be32 *p;
-	u32 size;
-
-	if (xdr_stream_decode_u32(xdr, &size) < 0)
-		return false;
-	if (size == 0 || size > NFS3_FHSIZE)
-		return false;
-	p = xdr_inline_decode(xdr, size);
-	if (!p)
-		return false;
-	fh_init(fhp, NFS3_FHSIZE);
-	fhp->fh_handle.fh_size = size;
-	memcpy(&fhp->fh_handle.fh_raw, p, size);
-
-	return true;
-}
-
-/**
- * svcxdr_encode_nfsstat3 - Encode an NFSv3 status code
- * @xdr: XDR stream
- * @status: status value to encode
- *
- * Return values:
- *   %false: Send buffer space was exhausted
- *   %true: Success
- */
-bool
-svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status)
-{
-	__be32 *p;
-
-	p = xdr_reserve_space(xdr, sizeof(status));
-	if (!p)
-		return false;
-	*p = status;
-
-	return true;
-}
-
-static bool
-svcxdr_encode_fattr3(struct svc_rqst *rqstp, struct xdr_stream *xdr,
-		     const struct svc_fh *fhp, const struct kstat *stat)
-{
-	struct user_namespace *userns = nfsd_user_namespace(rqstp);
-	__be32 *p;
-	u64 fsid;
-
-	p = xdr_reserve_space(xdr, XDR_UNIT * 21);
-	if (!p)
-		return false;
-
-	*p++ = cpu_to_be32(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
-	*p++ = cpu_to_be32((u32)(stat->mode & S_IALLUGO));
-	*p++ = cpu_to_be32((u32)stat->nlink);
-	*p++ = cpu_to_be32((u32)from_kuid_munged(userns, stat->uid));
-	*p++ = cpu_to_be32((u32)from_kgid_munged(userns, stat->gid));
-	if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN)
-		p = xdr_encode_hyper(p, (u64)NFS3_MAXPATHLEN);
-	else
-		p = xdr_encode_hyper(p, (u64)stat->size);
-
-	/* used */
-	p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9);
-
-	/* rdev */
-	*p++ = cpu_to_be32((u32)MAJOR(stat->rdev));
-	*p++ = cpu_to_be32((u32)MINOR(stat->rdev));
-
-	switch(fsid_source(fhp)) {
-	case FSIDSOURCE_FSID:
-		fsid = (u64)fhp->fh_export->ex_fsid;
-		break;
-	case FSIDSOURCE_UUID:
-		fsid = ((u64 *)fhp->fh_export->ex_uuid)[0];
-		fsid ^= ((u64 *)fhp->fh_export->ex_uuid)[1];
-		break;
-	default:
-		fsid = (u64)huge_encode_dev(fhp->fh_dentry->d_sb->s_dev);
-	}
-	p = xdr_encode_hyper(p, fsid);
-
-	/* fileid */
-	p = xdr_encode_hyper(p, stat->ino);
-
-	p = encode_nfstime3(p, &stat->atime);
-	p = encode_nfstime3(p, &stat->mtime);
-	encode_nfstime3(p, &stat->ctime);
-
-	return true;
-}
-
-/**
- * svcxdr_encode_post_op_attr - Encode NFSv3 post-op attributes
- * @rqstp: Context of a completed RPC transaction
- * @xdr: XDR stream
- * @fhp: File handle to encode
- *
- * Return values:
- *   %false: Send buffer space was exhausted
- *   %true: Success
- */
-bool
-svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
-			   const struct svc_fh *fhp)
-{
-	struct dentry *dentry = fhp->fh_dentry;
-	struct kstat stat;
-
-	/*
-	 * The inode may be NULL if the call failed because of a
-	 * stale file handle. In this case, no attributes are
-	 * returned.
-	 */
-	if (fhp->fh_no_wcc || !dentry || !d_really_is_positive(dentry))
-		goto no_post_op_attrs;
-	if (fh_getattr(fhp, &stat) != nfs_ok)
-		goto no_post_op_attrs;
-
-	if (xdr_stream_encode_item_present(xdr) < 0)
-		return false;
-	lease_get_mtime(d_inode(dentry), &stat.mtime);
-	if (!svcxdr_encode_fattr3(rqstp, xdr, fhp, &stat))
-		return false;
-
-	return true;
-
-no_post_op_attrs:
-	return xdr_stream_encode_item_absent(xdr) > 0;
-}
-
 /*
  * XDR encode functions
  */
diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h
index a6f0e0b7bfe4..90dadcacdf2b 100644
--- a/fs/nfsd/xdr3.h
+++ b/fs/nfsd/xdr3.h
@@ -151,10 +151,5 @@ void nfsd3_fill_post_op_attr(struct svc_rqst *rqstp, struct post_op_attr *attr,
 			     struct svc_fh *fhp);
 void nfsd3_fill_post_op_fh3(struct post_op_fh3 *post_op_fh,
 			    const struct svc_fh *fhp, u8 *data);
-/* Helper functions for NFSv3 ACL code */
-bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp);
-bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status);
-bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
-				const struct svc_fh *fhp);
 
 #endif /* _LINUX_NFSD_XDR3_H */
-- 
2.56.0


  parent reply	other threads:[~2026-10-26 21:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25 15:16 [PATCH v1 00/13] Convert server-side NFS_ACLv3 XDR to use xdrgen Chuck Lever
2026-10-25 15:16 ` [PATCH v1 01/13] Documentation: Add the RPC language description of NFS_ACLv3 Chuck Lever
2026-10-25 15:16 ` [PATCH v1 02/13] NFSD: Add infrastructure for generating NFS_ACLv3 XDR encoders and decoders Chuck Lever
2026-10-25 15:16 ` [PATCH v1 03/13] NFSD: Remove '#include "xdr3.h"' from nfs3acl.c Chuck Lever
2026-10-25 15:16 ` [PATCH v1 04/13] NFSD: New NFS_ACLv3 status codes Chuck Lever
2026-10-25 15:16 ` [PATCH v1 05/13] NFSD: Use xdrgen XDR functions for the NFS-ACL v3 NULL procedure Chuck Lever
2026-10-25 15:16 ` [PATCH v1 06/13] NFSD: Implement NFS-ACL v3 ACL encoding and decoding with xdrgen Chuck Lever
2026-10-25 15:16 ` [PATCH v1 07/13] NFSD: Use xdrgen XDR functions for the NFS-ACL v3 GETACL procedure Chuck Lever
2026-10-25 15:16 ` [PATCH v1 08/13] NFSD: Use xdrgen XDR functions for the NFS-ACL v3 SETACL procedure Chuck Lever
2026-10-25 15:16 ` [PATCH v1 09/13] NFSD: Map every NFS_ACLv3 reply status into aclstat3 Chuck Lever
2026-10-25 15:16 ` Chuck Lever [this message]
2026-10-25 15:16 ` [PATCH v1 11/13] NFS: Move NFSACL_MAXPAGES into fs/nfs/nfs3_fs.h Chuck Lever
2026-10-26 22:50   ` Anna Schumaker
2026-10-25 15:16 ` [PATCH v1 12/13] NFSD: Share the attribute conversion helpers with the NFS_ACL procs Chuck Lever
2026-10-25 15:16 ` [PATCH v1 13/13] nfs_common: Remove the unused NFS ACL stream codecs Chuck Lever
2026-10-27 10:56 ` [PATCH v1 00/13] Convert server-side NFS_ACLv3 XDR to use xdrgen Jeff Layton

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=20261025151622.141025-11-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.