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 03/27] NFSD: Use xdrgen-generated NFSv2 protocol definitions
Date: Wed, 16 Sep 2026 12:28:34 -0400 [thread overview]
Message-ID: <20260916162859.2051-6-cel@kernel.org> (raw)
In-Reply-To: <20260916162859.2051-1-cel@kernel.org>
Switch the server's NFSv2 implementation to use the machine-
generated protocol definitions.
Signed-off-by: Chuck Lever <cel@kernel.org>
---
fs/nfs_common/common.c | 5 +++--
fs/nfsd/nfsd.h | 2 --
fs/nfsd/nfserr.h | 2 +-
fs/nfsd/nfsproc.c | 2 ++
fs/nfsd/nfsxdr.c | 9 ++++++++-
include/linux/nfs_common.h | 4 ++--
6 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/fs/nfs_common/common.c b/fs/nfs_common/common.c
index 0778743ae2c2..a05f2ace31ec 100644
--- a/fs/nfs_common/common.c
+++ b/fs/nfs_common/common.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/module.h>
+#include <uapi/linux/nfs.h>
#include <linux/nfs_common.h>
#include <linux/nfs4.h>
@@ -53,12 +54,12 @@ static const struct {
* Returns a local errno value, or -EIO if the NFS status code is
* not recognized. This function is used jointly by NFSv2 and NFSv3.
*/
-int nfs_stat_to_errno(enum nfs_stat status)
+int nfs_stat_to_errno(int status)
{
int i;
for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
- if (nfs_errtbl[i].stat == (int)status)
+ if (nfs_errtbl[i].stat == status)
return nfs_errtbl[i].errno;
}
return -EIO;
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 69e3e92b3ec1..d1e413d21e76 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -12,8 +12,6 @@
#include <linux/types.h>
#include <linux/mount.h>
-#include <linux/nfs.h>
-#include <linux/nfs2.h>
#include <linux/sunrpc/svc.h>
#include <linux/sunrpc/svc_xprt.h>
diff --git a/fs/nfsd/nfserr.h b/fs/nfsd/nfserr.h
index d1c434b834b2..35debf1141a3 100644
--- a/fs/nfsd/nfserr.h
+++ b/fs/nfsd/nfserr.h
@@ -10,7 +10,7 @@
#ifndef LINUX_NFSD_NFSERR_H
#define LINUX_NFSD_NFSERR_H
-#include <linux/nfs.h>
+#include <linux/sunrpc/xdrgen/nfs2.h>
#include <linux/nfs3.h>
#include <linux/nfs4.h>
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index 09d360839825..1ce75779312b 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -6,7 +6,9 @@
*/
#include <linux/namei.h>
+#include <linux/sunrpc/svc.h>
+#include "nfs2xdr_gen.h"
#include "cache.h"
#include "xdr.h"
#include "vfs.h"
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index 0961c13d6ab1..d55e7d6414a0 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -22,6 +22,13 @@
*/
#define NFS2_SATTR_SET_TO_SERVER_TIME (1000000)
+/*
+ * Linux-internal ftype values for socket and unknown inodes, not
+ * in RFC 1094's wire enum; values match enum nfs_ftype.
+ */
+#define NFBAD (7)
+#define NFSOCK (6)
+
/*
* Mapping of S_IF* types to NFS file types
*/
@@ -599,7 +606,7 @@ svcxdr_encode_entry_common(struct nfsd_readdirres *resp, const char *name,
if (xdr_stream_encode_u32(xdr, (u32)ino) < 0)
return false;
/* name */
- if (xdr_stream_encode_opaque(xdr, name, min(namlen, NFS2_MAXNAMLEN)) < 0)
+ if (xdr_stream_encode_opaque(xdr, name, min(namlen, NFS_MAXNAMLEN)) < 0)
return false;
/* cookie */
resp->cookie_offset = dirlist->len;
diff --git a/include/linux/nfs_common.h b/include/linux/nfs_common.h
index a541c3a02887..88dccd8564cf 100644
--- a/include/linux/nfs_common.h
+++ b/include/linux/nfs_common.h
@@ -6,11 +6,11 @@
#define _LINUX_NFS_COMMON_H
#include <linux/errno.h>
-#include <uapi/linux/nfs.h>
+#include <linux/types.h>
/* Mapping from NFS error code to "errno" error code. */
-int nfs_stat_to_errno(enum nfs_stat status);
+int nfs_stat_to_errno(int status);
int nfs4_stat_to_errno(int stat);
__u32 nfs_localio_errno_to_nfs4_stat(int errno);
--
2.55.0
next prev parent reply other threads:[~2026-09-16 16:29 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 16:28 [PATCH v1 00/27] Convert server-side NFSv2 XDR to use xdrgen Chuck Lever
2026-09-16 16:28 ` [PATCH v1 01/27] Documentation: Add the RPC language description of NFSv2 Chuck Lever
2026-09-16 16:28 ` [PATCH v1 1/2] NFSD: map fh_verify() status codes for NFS_ACLv2 replies Chuck Lever
2026-09-17 11:57 ` Jeff Layton
2026-09-16 16:28 ` [PATCH v1 02/27] NFSD: Add infrastructure for generating NFSv2 XDR encoders and decoders Chuck Lever
2026-09-16 16:28 ` [PATCH v1 2/2] NFSD: map fh_verify() status codes for NFS_ACLv3 replies Chuck Lever
2026-09-17 11:57 ` Jeff Layton
2026-09-16 16:28 ` Chuck Lever [this message]
2026-09-16 16:28 ` [PATCH v1 04/27] NFSD: Remove '#include "xdr.h"' from fs/nfsd/xdr3.h Chuck Lever
2026-09-16 16:28 ` [PATCH v1 05/27] NFSD: Relocate the NFSv2 XDR storage union into nfsproc.c Chuck Lever
2026-09-16 16:28 ` [PATCH v1 06/27] NFSD: Use xdrgen XDR functions for the NFSv2 NULL procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 07/27] NFSD: Use xdrgen XDR functions for NFSv2 GETATTR procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 08/27] NFSD: Use xdrgen XDR functions for NFSv2 SETATTR procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 09/27] NFSD: Use xdrgen XDR functions for the NFSv2 ROOT procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 10/27] NFSD: Use xdrgen XDR functions for the NFSv2 LOOKUP procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 11/27] NFSD: Use xdrgen XDR functions for NFSv2 READLINK procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 12/27] NFSD: Use xdrgen XDR functions for NFSv2 READ procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 13/27] NFSD: Use xdrgen XDR functions for the NFSv2 WRITECACHE procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 14/27] NFSD: Use xdrgen XDR functions for NFSv2 WRITE procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 15/27] NFSD: Refactor nfsd_proc_create() Chuck Lever
2026-09-16 16:28 ` [PATCH v1 16/27] NFSD: Use xdrgen XDR functions for NFSv2 CREATE procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 17/27] NFSD: Use xdrgen XDR functions for the NFSv2 REMOVE procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 18/27] NFSD: Use xdrgen XDR functions for the NFSv2 RENAME procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 19/27] NFSD: Use xdrgen XDR functions for the NFSv2 LINK procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 20/27] NFSD: Use xdrgen XDR functions for NFSv2 SYMLINK procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 21/27] NFSD: Use xdrgen XDR functions for NFSv2 MKDIR procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 22/27] NFSD: Use xdrgen XDR functions for NFSv2 RMDIR procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 23/27] NFSD: Use xdrgen XDR functions for the NFSv2 STATFS procedure Chuck Lever
2026-09-16 16:28 ` [PATCH v1 24/27] NFSD: Use xdrgen XDR functions for NFSv2 READDIR arguments Chuck Lever
2026-09-16 16:28 ` [PATCH v1 25/27] NFSD: Add a streaming directory reader Chuck Lever
2026-09-16 16:28 ` [PATCH v1 26/27] NFSD: Refactor NFSv2 directory cookie encoding Chuck Lever
2026-09-16 16:28 ` [PATCH v1 27/27] NFSD: Use xdrgen XDR functions for NFSv2 READDIR results Chuck Lever
2026-09-17 11:56 ` [PATCH v1 00/27] Convert server-side NFSv2 XDR to use xdrgen Jeff Layton
2026-09-17 14:57 ` 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=20260916162859.2051-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox