Linux NFS development
 help / color / mirror / Atom feed
* [PATCH 1/2] NFS: Import NFS3ERR definitions
@ 2026-08-26 19:44 Chuck Lever
  2026-08-26 19:44 ` [PATCH 2/2] NFSD: Rework be32 nfserr definitions Chuck Lever
  2026-08-28 14:42 ` [PATCH 1/2] NFS: Import NFS3ERR definitions Jeff Layton
  0 siblings, 2 replies; 4+ messages in thread
From: Chuck Lever @ 2026-08-26 19:44 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

enum nfs_stat in uapi/linux/nfs.h collects the on-the-wire status
codes for every NFS version under version-agnostic NFSERR_* names.
The in-kernel NFS client and server reference these names
internally, which drags uapi/linux/nfs.h into many translation
units that need nothing else from that header.

xdrgen conversion will provide spec-based definitions of the NFS
status enum constants. Replacing the existing internal references
with version-specific names requires a version-specific spelling
for each code that NFSD uses.

linux/nfs4.h already supplies the NFSv4 codes, but NFSv3 has no
counterpart header, and not every NFSv3 code has an NFS4ERR_*
spelling: NFSERR_NOT_SYNC (10002) and NFSERR_REMOTE (71) have no
NFSv4 equivalent at all, and NFSERR_JUKEBOX (10008) appears in
NFSv4 as NFS4ERR_DELAY.

Introduce the NFSv3 status codes as NFS3ERR_* in linux/nfs3.h so a
subsequent patch can respell NFSD's status definitions without
relying on uapi/linux/nfs.h.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 include/linux/nfs3.h | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/include/linux/nfs3.h b/include/linux/nfs3.h
index 1d18da0860d5..b6539a75edea 100644
--- a/include/linux/nfs3.h
+++ b/include/linux/nfs3.h
@@ -7,6 +7,41 @@
 
 #include <uapi/linux/nfs3.h>
 
+/*
+ * NFSv3 error status values.
+ * See RFC 1813 Section 2.5
+ */
+enum {
+	NFS3ERR_PERM		= 1,
+	NFS3ERR_NOENT		= 2,
+	NFS3ERR_IO		= 5,
+	NFS3ERR_NXIO		= 6,
+	NFS3ERR_ACCES		= 13,
+	NFS3ERR_EXIST		= 17,
+	NFS3ERR_XDEV		= 18,
+	NFS3ERR_NODEV		= 19,
+	NFS3ERR_NOTDIR		= 20,
+	NFS3ERR_ISDIR		= 21,
+	NFS3ERR_INVAL		= 22,
+	NFS3ERR_FBIG		= 27,
+	NFS3ERR_NOSPC		= 28,
+	NFS3ERR_ROFS		= 30,
+	NFS3ERR_MLINK		= 31,
+	NFS3ERR_NAMETOOLONG	= 63,
+	NFS3ERR_NOTEMPTY	= 66,
+	NFS3ERR_DQUOT		= 69,
+	NFS3ERR_STALE		= 70,
+	NFS3ERR_REMOTE		= 71,
+	NFS3ERR_BADHANDLE	= 10001,
+	NFS3ERR_NOT_SYNC	= 10002,
+	NFS3ERR_BAD_COOKIE	= 10003,
+	NFS3ERR_NOTSUPP		= 10004,
+	NFS3ERR_TOOSMALL	= 10005,
+	NFS3ERR_SERVERFAULT	= 10006,
+	NFS3ERR_BADTYPE		= 10007,
+	NFS3ERR_JUKEBOX		= 10008,
+};
+
 enum nfs3_stable_how {
 	NFS_UNSTABLE = 0,
 	NFS_DATA_SYNC = 1,
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] NFSD: Rework be32 nfserr definitions
  2026-08-26 19:44 [PATCH 1/2] NFS: Import NFS3ERR definitions Chuck Lever
@ 2026-08-26 19:44 ` Chuck Lever
  2026-08-28 14:42   ` Jeff Layton
  2026-08-28 14:42 ` [PATCH 1/2] NFS: Import NFS3ERR definitions Jeff Layton
  1 sibling, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2026-08-26 19:44 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

fs/nfsd/nfserr.h builds NFSD's internal __be32 nfserr_* values
by wrapping the version-agnostic NFSERR_* status codes from
uapi/linux/nfs.h in cpu_to_be32(), which it reaches through its
include of linux/nfs.h.

A subsequent patch replaces that include with the xdrgen-generated
linux/sunrpc/xdrgen/nfs2.h. The generated header re-supplies
only the eighteen NFSv2 status codes; the NFSv3 and NFSv4 codes
that nfserr.h also uses (NFSERR_INVAL, NFSERR_JUKEBOX,
NFSERR_RESOURCE, and the rest) would be left undeclared.

Respell those definitions in terms of the version-specific
NFS3ERR_* and NFS4ERR_* codes from linux/nfs3.h and linux/nfs4.h,
and switch the one bare NFSERR_MOVED in nfs4xdr.c to NFS4ERR_MOVED.
The wire values are unchanged; NFSD no longer depends on the
version-agnostic NFSv3 and NFSv4 names.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/nfs4xdr.c |   2 +-
 fs/nfsd/nfserr.h  | 129 +++++++++++++++++++++++-----------------------
 2 files changed, 66 insertions(+), 65 deletions(-)

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5bfbeb87394e..00ddaac499c6 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3213,7 +3213,7 @@ static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *bmval2, u32
 	    *bmval1 & ~WORD1_ABSENT_FS_ATTRS) {
 		if (*bmval0 & FATTR4_WORD0_RDATTR_ERROR ||
 	            *bmval0 & FATTR4_WORD0_FS_LOCATIONS)
-			*rdattr_err = NFSERR_MOVED;
+			*rdattr_err = NFS4ERR_MOVED;
 		else
 			return nfserr_moved;
 	}
diff --git a/fs/nfsd/nfserr.h b/fs/nfsd/nfserr.h
index 9b9df7aab220..d1c434b834b2 100644
--- a/fs/nfsd/nfserr.h
+++ b/fs/nfsd/nfserr.h
@@ -11,76 +11,77 @@
 #define LINUX_NFSD_NFSERR_H
 
 #include <linux/nfs.h>
+#include <linux/nfs3.h>
 #include <linux/nfs4.h>
 
 /*
  * These macros provide pre-xdr'ed values for faster operation.
  */
-#define	nfs_ok			cpu_to_be32(NFS_OK)
-#define	nfserr_perm		cpu_to_be32(NFSERR_PERM)
-#define	nfserr_noent		cpu_to_be32(NFSERR_NOENT)
-#define	nfserr_io		cpu_to_be32(NFSERR_IO)
-#define	nfserr_nxio		cpu_to_be32(NFSERR_NXIO)
-#define	nfserr_acces		cpu_to_be32(NFSERR_ACCES)
-#define	nfserr_exist		cpu_to_be32(NFSERR_EXIST)
-#define	nfserr_xdev		cpu_to_be32(NFSERR_XDEV)
-#define	nfserr_nodev		cpu_to_be32(NFSERR_NODEV)
-#define	nfserr_notdir		cpu_to_be32(NFSERR_NOTDIR)
-#define	nfserr_isdir		cpu_to_be32(NFSERR_ISDIR)
-#define	nfserr_inval		cpu_to_be32(NFSERR_INVAL)
-#define	nfserr_fbig		cpu_to_be32(NFSERR_FBIG)
-#define	nfserr_nospc		cpu_to_be32(NFSERR_NOSPC)
-#define	nfserr_rofs		cpu_to_be32(NFSERR_ROFS)
-#define	nfserr_mlink		cpu_to_be32(NFSERR_MLINK)
-#define	nfserr_nametoolong	cpu_to_be32(NFSERR_NAMETOOLONG)
-#define	nfserr_notempty		cpu_to_be32(NFSERR_NOTEMPTY)
-#define	nfserr_dquot		cpu_to_be32(NFSERR_DQUOT)
-#define	nfserr_stale		cpu_to_be32(NFSERR_STALE)
-#define	nfserr_remote		cpu_to_be32(NFSERR_REMOTE)
-#define	nfserr_wflush		cpu_to_be32(NFSERR_WFLUSH)
-#define	nfserr_badhandle	cpu_to_be32(NFSERR_BADHANDLE)
-#define	nfserr_notsync		cpu_to_be32(NFSERR_NOT_SYNC)
-#define	nfserr_badcookie	cpu_to_be32(NFSERR_BAD_COOKIE)
-#define	nfserr_notsupp		cpu_to_be32(NFSERR_NOTSUPP)
-#define	nfserr_toosmall		cpu_to_be32(NFSERR_TOOSMALL)
-#define	nfserr_serverfault	cpu_to_be32(NFSERR_SERVERFAULT)
-#define	nfserr_badtype		cpu_to_be32(NFSERR_BADTYPE)
-#define	nfserr_jukebox		cpu_to_be32(NFSERR_JUKEBOX)
-#define	nfserr_denied		cpu_to_be32(NFSERR_DENIED)
-#define	nfserr_deadlock		cpu_to_be32(NFSERR_DEADLOCK)
-#define nfserr_expired          cpu_to_be32(NFSERR_EXPIRED)
-#define	nfserr_bad_cookie	cpu_to_be32(NFSERR_BAD_COOKIE)
-#define	nfserr_same		cpu_to_be32(NFSERR_SAME)
-#define	nfserr_clid_inuse	cpu_to_be32(NFSERR_CLID_INUSE)
-#define	nfserr_stale_clientid	cpu_to_be32(NFSERR_STALE_CLIENTID)
-#define	nfserr_resource		cpu_to_be32(NFSERR_RESOURCE)
-#define	nfserr_moved		cpu_to_be32(NFSERR_MOVED)
-#define	nfserr_nofilehandle	cpu_to_be32(NFSERR_NOFILEHANDLE)
-#define	nfserr_minor_vers_mismatch	cpu_to_be32(NFSERR_MINOR_VERS_MISMATCH)
-#define nfserr_share_denied	cpu_to_be32(NFSERR_SHARE_DENIED)
-#define nfserr_stale_stateid	cpu_to_be32(NFSERR_STALE_STATEID)
-#define nfserr_old_stateid	cpu_to_be32(NFSERR_OLD_STATEID)
-#define nfserr_bad_stateid	cpu_to_be32(NFSERR_BAD_STATEID)
-#define nfserr_bad_seqid	cpu_to_be32(NFSERR_BAD_SEQID)
-#define	nfserr_symlink		cpu_to_be32(NFSERR_SYMLINK)
-#define	nfserr_not_same		cpu_to_be32(NFSERR_NOT_SAME)
-#define nfserr_lock_range	cpu_to_be32(NFSERR_LOCK_RANGE)
-#define	nfserr_restorefh	cpu_to_be32(NFSERR_RESTOREFH)
-#define	nfserr_attrnotsupp	cpu_to_be32(NFSERR_ATTRNOTSUPP)
-#define	nfserr_bad_xdr		cpu_to_be32(NFSERR_BAD_XDR)
-#define	nfserr_openmode		cpu_to_be32(NFSERR_OPENMODE)
-#define	nfserr_badowner		cpu_to_be32(NFSERR_BADOWNER)
-#define	nfserr_locks_held	cpu_to_be32(NFSERR_LOCKS_HELD)
-#define	nfserr_op_illegal	cpu_to_be32(NFSERR_OP_ILLEGAL)
-#define	nfserr_grace		cpu_to_be32(NFSERR_GRACE)
-#define	nfserr_no_grace		cpu_to_be32(NFSERR_NO_GRACE)
-#define	nfserr_reclaim_bad	cpu_to_be32(NFSERR_RECLAIM_BAD)
-#define	nfserr_badname		cpu_to_be32(NFSERR_BADNAME)
-#define	nfserr_admin_revoked	cpu_to_be32(NFS4ERR_ADMIN_REVOKED)
-#define	nfserr_cb_path_down	cpu_to_be32(NFSERR_CB_PATH_DOWN)
-#define	nfserr_locked		cpu_to_be32(NFSERR_LOCKED)
-#define	nfserr_wrongsec		cpu_to_be32(NFSERR_WRONGSEC)
+#define	nfs_ok				cpu_to_be32(NFS_OK)
+#define	nfserr_perm			cpu_to_be32(NFSERR_PERM)
+#define	nfserr_noent			cpu_to_be32(NFSERR_NOENT)
+#define	nfserr_io			cpu_to_be32(NFSERR_IO)
+#define	nfserr_nxio			cpu_to_be32(NFSERR_NXIO)
+#define	nfserr_acces			cpu_to_be32(NFSERR_ACCES)
+#define	nfserr_exist			cpu_to_be32(NFSERR_EXIST)
+#define	nfserr_xdev			cpu_to_be32(NFS3ERR_XDEV)
+#define	nfserr_nodev			cpu_to_be32(NFSERR_NODEV)
+#define	nfserr_notdir			cpu_to_be32(NFSERR_NOTDIR)
+#define	nfserr_isdir			cpu_to_be32(NFSERR_ISDIR)
+#define	nfserr_inval			cpu_to_be32(NFS3ERR_INVAL)
+#define	nfserr_fbig			cpu_to_be32(NFSERR_FBIG)
+#define	nfserr_nospc			cpu_to_be32(NFSERR_NOSPC)
+#define	nfserr_rofs			cpu_to_be32(NFSERR_ROFS)
+#define	nfserr_mlink			cpu_to_be32(NFS3ERR_MLINK)
+#define	nfserr_nametoolong		cpu_to_be32(NFSERR_NAMETOOLONG)
+#define	nfserr_notempty			cpu_to_be32(NFSERR_NOTEMPTY)
+#define	nfserr_dquot			cpu_to_be32(NFSERR_DQUOT)
+#define	nfserr_stale			cpu_to_be32(NFSERR_STALE)
+#define	nfserr_remote			cpu_to_be32(NFS3ERR_REMOTE)
+#define	nfserr_wflush			cpu_to_be32(NFSERR_WFLUSH)
+#define	nfserr_badhandle		cpu_to_be32(NFS3ERR_BADHANDLE)
+#define	nfserr_notsync			cpu_to_be32(NFS3ERR_NOT_SYNC)
+#define	nfserr_badcookie		cpu_to_be32(NFS3ERR_BAD_COOKIE)
+#define	nfserr_notsupp			cpu_to_be32(NFS3ERR_NOTSUPP)
+#define	nfserr_toosmall			cpu_to_be32(NFS3ERR_TOOSMALL)
+#define	nfserr_serverfault		cpu_to_be32(NFS3ERR_SERVERFAULT)
+#define	nfserr_badtype			cpu_to_be32(NFS3ERR_BADTYPE)
+#define	nfserr_jukebox			cpu_to_be32(NFS3ERR_JUKEBOX)
 #define nfserr_delay			cpu_to_be32(NFS4ERR_DELAY)
+#define	nfserr_same			cpu_to_be32(NFS4ERR_SAME)
+#define	nfserr_denied			cpu_to_be32(NFS4ERR_DENIED)
+#define	nfserr_deadlock			cpu_to_be32(NFS4ERR_DEADLOCK)
+#define	nfserr_expired			cpu_to_be32(NFS4ERR_EXPIRED)
+#define	nfserr_bad_cookie		cpu_to_be32(NFS4ERR_BAD_COOKIE)
+#define	nfserr_clid_inuse		cpu_to_be32(NFS4ERR_CLID_INUSE)
+#define	nfserr_stale_clientid		cpu_to_be32(NFS4ERR_STALE_CLIENTID)
+#define	nfserr_resource			cpu_to_be32(NFS4ERR_RESOURCE)
+#define	nfserr_moved			cpu_to_be32(NFS4ERR_MOVED)
+#define	nfserr_nofilehandle		cpu_to_be32(NFS4ERR_NOFILEHANDLE)
+#define	nfserr_minor_vers_mismatch	cpu_to_be32(NFS4ERR_MINOR_VERS_MISMATCH)
+#define nfserr_share_denied		cpu_to_be32(NFS4ERR_SHARE_DENIED)
+#define nfserr_stale_stateid		cpu_to_be32(NFS4ERR_STALE_STATEID)
+#define nfserr_old_stateid		cpu_to_be32(NFS4ERR_OLD_STATEID)
+#define nfserr_bad_stateid		cpu_to_be32(NFS4ERR_BAD_STATEID)
+#define nfserr_bad_seqid		cpu_to_be32(NFS4ERR_BAD_SEQID)
+#define	nfserr_symlink			cpu_to_be32(NFS4ERR_SYMLINK)
+#define	nfserr_not_same			cpu_to_be32(NFS4ERR_NOT_SAME)
+#define nfserr_lock_range		cpu_to_be32(NFS4ERR_LOCK_RANGE)
+#define	nfserr_restorefh		cpu_to_be32(NFS4ERR_RESTOREFH)
+#define	nfserr_attrnotsupp		cpu_to_be32(NFS4ERR_ATTRNOTSUPP)
+#define	nfserr_bad_xdr			cpu_to_be32(NFS4ERR_BADXDR)
+#define	nfserr_openmode			cpu_to_be32(NFS4ERR_OPENMODE)
+#define	nfserr_badowner			cpu_to_be32(NFS4ERR_BADOWNER)
+#define	nfserr_locks_held		cpu_to_be32(NFS4ERR_LOCKS_HELD)
+#define	nfserr_op_illegal		cpu_to_be32(NFS4ERR_OP_ILLEGAL)
+#define	nfserr_grace			cpu_to_be32(NFS4ERR_GRACE)
+#define	nfserr_no_grace			cpu_to_be32(NFS4ERR_NO_GRACE)
+#define	nfserr_reclaim_bad		cpu_to_be32(NFS4ERR_RECLAIM_BAD)
+#define	nfserr_badname			cpu_to_be32(NFS4ERR_BADNAME)
+#define	nfserr_admin_revoked		cpu_to_be32(NFS4ERR_ADMIN_REVOKED)
+#define	nfserr_cb_path_down		cpu_to_be32(NFS4ERR_CB_PATH_DOWN)
+#define	nfserr_locked			cpu_to_be32(NFS4ERR_LOCKED)
+#define	nfserr_wrongsec			cpu_to_be32(NFS4ERR_WRONGSEC)
 #define nfserr_badiomode		cpu_to_be32(NFS4ERR_BADIOMODE)
 #define nfserr_badlayout		cpu_to_be32(NFS4ERR_BADLAYOUT)
 #define nfserr_bad_session_digest	cpu_to_be32(NFS4ERR_BAD_SESSION_DIGEST)
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] NFS: Import NFS3ERR definitions
  2026-08-26 19:44 [PATCH 1/2] NFS: Import NFS3ERR definitions Chuck Lever
  2026-08-26 19:44 ` [PATCH 2/2] NFSD: Rework be32 nfserr definitions Chuck Lever
@ 2026-08-28 14:42 ` Jeff Layton
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2026-08-28 14:42 UTC (permalink / raw)
  To: Chuck Lever, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

On Wed, 2026-08-26 at 15:44 -0400, Chuck Lever wrote:
> enum nfs_stat in uapi/linux/nfs.h collects the on-the-wire status
> codes for every NFS version under version-agnostic NFSERR_* names.
> The in-kernel NFS client and server reference these names
> internally, which drags uapi/linux/nfs.h into many translation
> units that need nothing else from that header.
> 
> xdrgen conversion will provide spec-based definitions of the NFS
> status enum constants. Replacing the existing internal references
> with version-specific names requires a version-specific spelling
> for each code that NFSD uses.
> 
> linux/nfs4.h already supplies the NFSv4 codes, but NFSv3 has no
> counterpart header, and not every NFSv3 code has an NFS4ERR_*
> spelling: NFSERR_NOT_SYNC (10002) and NFSERR_REMOTE (71) have no
> NFSv4 equivalent at all, and NFSERR_JUKEBOX (10008) appears in
> NFSv4 as NFS4ERR_DELAY.
> 
> Introduce the NFSv3 status codes as NFS3ERR_* in linux/nfs3.h so a
> subsequent patch can respell NFSD's status definitions without
> relying on uapi/linux/nfs.h.
> 
> Signed-off-by: Chuck Lever <cel@kernel.org>
> ---
>  include/linux/nfs3.h | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/include/linux/nfs3.h b/include/linux/nfs3.h
> index 1d18da0860d5..b6539a75edea 100644
> --- a/include/linux/nfs3.h
> +++ b/include/linux/nfs3.h
> @@ -7,6 +7,41 @@
>  
>  #include <uapi/linux/nfs3.h>
>  
> +/*
> + * NFSv3 error status values.
> + * See RFC 1813 Section 2.5
> + */
> +enum {
> +	NFS3ERR_PERM		= 1,
> +	NFS3ERR_NOENT		= 2,
> +	NFS3ERR_IO		= 5,
> +	NFS3ERR_NXIO		= 6,
> +	NFS3ERR_ACCES		= 13,
> +	NFS3ERR_EXIST		= 17,
> +	NFS3ERR_XDEV		= 18,
> +	NFS3ERR_NODEV		= 19,
> +	NFS3ERR_NOTDIR		= 20,
> +	NFS3ERR_ISDIR		= 21,
> +	NFS3ERR_INVAL		= 22,
> +	NFS3ERR_FBIG		= 27,
> +	NFS3ERR_NOSPC		= 28,
> +	NFS3ERR_ROFS		= 30,
> +	NFS3ERR_MLINK		= 31,
> +	NFS3ERR_NAMETOOLONG	= 63,
> +	NFS3ERR_NOTEMPTY	= 66,
> +	NFS3ERR_DQUOT		= 69,
> +	NFS3ERR_STALE		= 70,
> +	NFS3ERR_REMOTE		= 71,
> +	NFS3ERR_BADHANDLE	= 10001,
> +	NFS3ERR_NOT_SYNC	= 10002,
> +	NFS3ERR_BAD_COOKIE	= 10003,
> +	NFS3ERR_NOTSUPP		= 10004,
> +	NFS3ERR_TOOSMALL	= 10005,
> +	NFS3ERR_SERVERFAULT	= 10006,
> +	NFS3ERR_BADTYPE		= 10007,
> +	NFS3ERR_JUKEBOX		= 10008,
> +};
> +
>  enum nfs3_stable_how {
>  	NFS_UNSTABLE = 0,
>  	NFS_DATA_SYNC = 1,

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] NFSD: Rework be32 nfserr definitions
  2026-08-26 19:44 ` [PATCH 2/2] NFSD: Rework be32 nfserr definitions Chuck Lever
@ 2026-08-28 14:42   ` Jeff Layton
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2026-08-28 14:42 UTC (permalink / raw)
  To: Chuck Lever, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

On Wed, 2026-08-26 at 15:44 -0400, Chuck Lever wrote:
> fs/nfsd/nfserr.h builds NFSD's internal __be32 nfserr_* values
> by wrapping the version-agnostic NFSERR_* status codes from
> uapi/linux/nfs.h in cpu_to_be32(), which it reaches through its
> include of linux/nfs.h.
> 
> A subsequent patch replaces that include with the xdrgen-generated
> linux/sunrpc/xdrgen/nfs2.h. The generated header re-supplies
> only the eighteen NFSv2 status codes; the NFSv3 and NFSv4 codes
> that nfserr.h also uses (NFSERR_INVAL, NFSERR_JUKEBOX,
> NFSERR_RESOURCE, and the rest) would be left undeclared.
> 
> Respell those definitions in terms of the version-specific
> NFS3ERR_* and NFS4ERR_* codes from linux/nfs3.h and linux/nfs4.h,
> and switch the one bare NFSERR_MOVED in nfs4xdr.c to NFS4ERR_MOVED.
> The wire values are unchanged; NFSD no longer depends on the
> version-agnostic NFSv3 and NFSv4 names.
> 
> Signed-off-by: Chuck Lever <cel@kernel.org>
> ---
>  fs/nfsd/nfs4xdr.c |   2 +-
>  fs/nfsd/nfserr.h  | 129 +++++++++++++++++++++++-----------------------
>  2 files changed, 66 insertions(+), 65 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 5bfbeb87394e..00ddaac499c6 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -3213,7 +3213,7 @@ static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *bmval2, u32
>  	    *bmval1 & ~WORD1_ABSENT_FS_ATTRS) {
>  		if (*bmval0 & FATTR4_WORD0_RDATTR_ERROR ||
>  	            *bmval0 & FATTR4_WORD0_FS_LOCATIONS)
> -			*rdattr_err = NFSERR_MOVED;
> +			*rdattr_err = NFS4ERR_MOVED;
>  		else
>  			return nfserr_moved;
>  	}
> diff --git a/fs/nfsd/nfserr.h b/fs/nfsd/nfserr.h
> index 9b9df7aab220..d1c434b834b2 100644
> --- a/fs/nfsd/nfserr.h
> +++ b/fs/nfsd/nfserr.h
> @@ -11,76 +11,77 @@
>  #define LINUX_NFSD_NFSERR_H
>  
>  #include <linux/nfs.h>
> +#include <linux/nfs3.h>
>  #include <linux/nfs4.h>
>  
>  /*
>   * These macros provide pre-xdr'ed values for faster operation.
>   */
> -#define	nfs_ok			cpu_to_be32(NFS_OK)
> -#define	nfserr_perm		cpu_to_be32(NFSERR_PERM)
> -#define	nfserr_noent		cpu_to_be32(NFSERR_NOENT)
> -#define	nfserr_io		cpu_to_be32(NFSERR_IO)
> -#define	nfserr_nxio		cpu_to_be32(NFSERR_NXIO)
> -#define	nfserr_acces		cpu_to_be32(NFSERR_ACCES)
> -#define	nfserr_exist		cpu_to_be32(NFSERR_EXIST)
> -#define	nfserr_xdev		cpu_to_be32(NFSERR_XDEV)
> -#define	nfserr_nodev		cpu_to_be32(NFSERR_NODEV)
> -#define	nfserr_notdir		cpu_to_be32(NFSERR_NOTDIR)
> -#define	nfserr_isdir		cpu_to_be32(NFSERR_ISDIR)
> -#define	nfserr_inval		cpu_to_be32(NFSERR_INVAL)
> -#define	nfserr_fbig		cpu_to_be32(NFSERR_FBIG)
> -#define	nfserr_nospc		cpu_to_be32(NFSERR_NOSPC)
> -#define	nfserr_rofs		cpu_to_be32(NFSERR_ROFS)
> -#define	nfserr_mlink		cpu_to_be32(NFSERR_MLINK)
> -#define	nfserr_nametoolong	cpu_to_be32(NFSERR_NAMETOOLONG)
> -#define	nfserr_notempty		cpu_to_be32(NFSERR_NOTEMPTY)
> -#define	nfserr_dquot		cpu_to_be32(NFSERR_DQUOT)
> -#define	nfserr_stale		cpu_to_be32(NFSERR_STALE)
> -#define	nfserr_remote		cpu_to_be32(NFSERR_REMOTE)
> -#define	nfserr_wflush		cpu_to_be32(NFSERR_WFLUSH)
> -#define	nfserr_badhandle	cpu_to_be32(NFSERR_BADHANDLE)
> -#define	nfserr_notsync		cpu_to_be32(NFSERR_NOT_SYNC)
> -#define	nfserr_badcookie	cpu_to_be32(NFSERR_BAD_COOKIE)
> -#define	nfserr_notsupp		cpu_to_be32(NFSERR_NOTSUPP)
> -#define	nfserr_toosmall		cpu_to_be32(NFSERR_TOOSMALL)
> -#define	nfserr_serverfault	cpu_to_be32(NFSERR_SERVERFAULT)
> -#define	nfserr_badtype		cpu_to_be32(NFSERR_BADTYPE)
> -#define	nfserr_jukebox		cpu_to_be32(NFSERR_JUKEBOX)
> -#define	nfserr_denied		cpu_to_be32(NFSERR_DENIED)
> -#define	nfserr_deadlock		cpu_to_be32(NFSERR_DEADLOCK)
> -#define nfserr_expired          cpu_to_be32(NFSERR_EXPIRED)
> -#define	nfserr_bad_cookie	cpu_to_be32(NFSERR_BAD_COOKIE)
> -#define	nfserr_same		cpu_to_be32(NFSERR_SAME)
> -#define	nfserr_clid_inuse	cpu_to_be32(NFSERR_CLID_INUSE)
> -#define	nfserr_stale_clientid	cpu_to_be32(NFSERR_STALE_CLIENTID)
> -#define	nfserr_resource		cpu_to_be32(NFSERR_RESOURCE)
> -#define	nfserr_moved		cpu_to_be32(NFSERR_MOVED)
> -#define	nfserr_nofilehandle	cpu_to_be32(NFSERR_NOFILEHANDLE)
> -#define	nfserr_minor_vers_mismatch	cpu_to_be32(NFSERR_MINOR_VERS_MISMATCH)
> -#define nfserr_share_denied	cpu_to_be32(NFSERR_SHARE_DENIED)
> -#define nfserr_stale_stateid	cpu_to_be32(NFSERR_STALE_STATEID)
> -#define nfserr_old_stateid	cpu_to_be32(NFSERR_OLD_STATEID)
> -#define nfserr_bad_stateid	cpu_to_be32(NFSERR_BAD_STATEID)
> -#define nfserr_bad_seqid	cpu_to_be32(NFSERR_BAD_SEQID)
> -#define	nfserr_symlink		cpu_to_be32(NFSERR_SYMLINK)
> -#define	nfserr_not_same		cpu_to_be32(NFSERR_NOT_SAME)
> -#define nfserr_lock_range	cpu_to_be32(NFSERR_LOCK_RANGE)
> -#define	nfserr_restorefh	cpu_to_be32(NFSERR_RESTOREFH)
> -#define	nfserr_attrnotsupp	cpu_to_be32(NFSERR_ATTRNOTSUPP)
> -#define	nfserr_bad_xdr		cpu_to_be32(NFSERR_BAD_XDR)
> -#define	nfserr_openmode		cpu_to_be32(NFSERR_OPENMODE)
> -#define	nfserr_badowner		cpu_to_be32(NFSERR_BADOWNER)
> -#define	nfserr_locks_held	cpu_to_be32(NFSERR_LOCKS_HELD)
> -#define	nfserr_op_illegal	cpu_to_be32(NFSERR_OP_ILLEGAL)
> -#define	nfserr_grace		cpu_to_be32(NFSERR_GRACE)
> -#define	nfserr_no_grace		cpu_to_be32(NFSERR_NO_GRACE)
> -#define	nfserr_reclaim_bad	cpu_to_be32(NFSERR_RECLAIM_BAD)
> -#define	nfserr_badname		cpu_to_be32(NFSERR_BADNAME)
> -#define	nfserr_admin_revoked	cpu_to_be32(NFS4ERR_ADMIN_REVOKED)
> -#define	nfserr_cb_path_down	cpu_to_be32(NFSERR_CB_PATH_DOWN)
> -#define	nfserr_locked		cpu_to_be32(NFSERR_LOCKED)
> -#define	nfserr_wrongsec		cpu_to_be32(NFSERR_WRONGSEC)
> +#define	nfs_ok				cpu_to_be32(NFS_OK)
> +#define	nfserr_perm			cpu_to_be32(NFSERR_PERM)
> +#define	nfserr_noent			cpu_to_be32(NFSERR_NOENT)
> +#define	nfserr_io			cpu_to_be32(NFSERR_IO)
> +#define	nfserr_nxio			cpu_to_be32(NFSERR_NXIO)
> +#define	nfserr_acces			cpu_to_be32(NFSERR_ACCES)
> +#define	nfserr_exist			cpu_to_be32(NFSERR_EXIST)
> +#define	nfserr_xdev			cpu_to_be32(NFS3ERR_XDEV)
> +#define	nfserr_nodev			cpu_to_be32(NFSERR_NODEV)
> +#define	nfserr_notdir			cpu_to_be32(NFSERR_NOTDIR)
> +#define	nfserr_isdir			cpu_to_be32(NFSERR_ISDIR)
> +#define	nfserr_inval			cpu_to_be32(NFS3ERR_INVAL)
> +#define	nfserr_fbig			cpu_to_be32(NFSERR_FBIG)
> +#define	nfserr_nospc			cpu_to_be32(NFSERR_NOSPC)
> +#define	nfserr_rofs			cpu_to_be32(NFSERR_ROFS)
> +#define	nfserr_mlink			cpu_to_be32(NFS3ERR_MLINK)
> +#define	nfserr_nametoolong		cpu_to_be32(NFSERR_NAMETOOLONG)
> +#define	nfserr_notempty			cpu_to_be32(NFSERR_NOTEMPTY)
> +#define	nfserr_dquot			cpu_to_be32(NFSERR_DQUOT)
> +#define	nfserr_stale			cpu_to_be32(NFSERR_STALE)
> +#define	nfserr_remote			cpu_to_be32(NFS3ERR_REMOTE)
> +#define	nfserr_wflush			cpu_to_be32(NFSERR_WFLUSH)
> +#define	nfserr_badhandle		cpu_to_be32(NFS3ERR_BADHANDLE)
> +#define	nfserr_notsync			cpu_to_be32(NFS3ERR_NOT_SYNC)
> +#define	nfserr_badcookie		cpu_to_be32(NFS3ERR_BAD_COOKIE)
> +#define	nfserr_notsupp			cpu_to_be32(NFS3ERR_NOTSUPP)
> +#define	nfserr_toosmall			cpu_to_be32(NFS3ERR_TOOSMALL)
> +#define	nfserr_serverfault		cpu_to_be32(NFS3ERR_SERVERFAULT)
> +#define	nfserr_badtype			cpu_to_be32(NFS3ERR_BADTYPE)
> +#define	nfserr_jukebox			cpu_to_be32(NFS3ERR_JUKEBOX)
>  #define nfserr_delay			cpu_to_be32(NFS4ERR_DELAY)
> +#define	nfserr_same			cpu_to_be32(NFS4ERR_SAME)
> +#define	nfserr_denied			cpu_to_be32(NFS4ERR_DENIED)
> +#define	nfserr_deadlock			cpu_to_be32(NFS4ERR_DEADLOCK)
> +#define	nfserr_expired			cpu_to_be32(NFS4ERR_EXPIRED)
> +#define	nfserr_bad_cookie		cpu_to_be32(NFS4ERR_BAD_COOKIE)
> +#define	nfserr_clid_inuse		cpu_to_be32(NFS4ERR_CLID_INUSE)
> +#define	nfserr_stale_clientid		cpu_to_be32(NFS4ERR_STALE_CLIENTID)
> +#define	nfserr_resource			cpu_to_be32(NFS4ERR_RESOURCE)
> +#define	nfserr_moved			cpu_to_be32(NFS4ERR_MOVED)
> +#define	nfserr_nofilehandle		cpu_to_be32(NFS4ERR_NOFILEHANDLE)
> +#define	nfserr_minor_vers_mismatch	cpu_to_be32(NFS4ERR_MINOR_VERS_MISMATCH)
> +#define nfserr_share_denied		cpu_to_be32(NFS4ERR_SHARE_DENIED)
> +#define nfserr_stale_stateid		cpu_to_be32(NFS4ERR_STALE_STATEID)
> +#define nfserr_old_stateid		cpu_to_be32(NFS4ERR_OLD_STATEID)
> +#define nfserr_bad_stateid		cpu_to_be32(NFS4ERR_BAD_STATEID)
> +#define nfserr_bad_seqid		cpu_to_be32(NFS4ERR_BAD_SEQID)
> +#define	nfserr_symlink			cpu_to_be32(NFS4ERR_SYMLINK)
> +#define	nfserr_not_same			cpu_to_be32(NFS4ERR_NOT_SAME)
> +#define nfserr_lock_range		cpu_to_be32(NFS4ERR_LOCK_RANGE)
> +#define	nfserr_restorefh		cpu_to_be32(NFS4ERR_RESTOREFH)
> +#define	nfserr_attrnotsupp		cpu_to_be32(NFS4ERR_ATTRNOTSUPP)
> +#define	nfserr_bad_xdr			cpu_to_be32(NFS4ERR_BADXDR)
> +#define	nfserr_openmode			cpu_to_be32(NFS4ERR_OPENMODE)
> +#define	nfserr_badowner			cpu_to_be32(NFS4ERR_BADOWNER)
> +#define	nfserr_locks_held		cpu_to_be32(NFS4ERR_LOCKS_HELD)
> +#define	nfserr_op_illegal		cpu_to_be32(NFS4ERR_OP_ILLEGAL)
> +#define	nfserr_grace			cpu_to_be32(NFS4ERR_GRACE)
> +#define	nfserr_no_grace			cpu_to_be32(NFS4ERR_NO_GRACE)
> +#define	nfserr_reclaim_bad		cpu_to_be32(NFS4ERR_RECLAIM_BAD)
> +#define	nfserr_badname			cpu_to_be32(NFS4ERR_BADNAME)
> +#define	nfserr_admin_revoked		cpu_to_be32(NFS4ERR_ADMIN_REVOKED)
> +#define	nfserr_cb_path_down		cpu_to_be32(NFS4ERR_CB_PATH_DOWN)
> +#define	nfserr_locked			cpu_to_be32(NFS4ERR_LOCKED)
> +#define	nfserr_wrongsec			cpu_to_be32(NFS4ERR_WRONGSEC)
>  #define nfserr_badiomode		cpu_to_be32(NFS4ERR_BADIOMODE)
>  #define nfserr_badlayout		cpu_to_be32(NFS4ERR_BADLAYOUT)
>  #define nfserr_bad_session_digest	cpu_to_be32(NFS4ERR_BAD_SESSION_DIGEST)

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-28 14:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-26 19:44 [PATCH 1/2] NFS: Import NFS3ERR definitions Chuck Lever
2026-08-26 19:44 ` [PATCH 2/2] NFSD: Rework be32 nfserr definitions Chuck Lever
2026-08-28 14:42   ` Jeff Layton
2026-08-28 14:42 ` [PATCH 1/2] NFS: Import NFS3ERR definitions Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox