From c9d6f6ba2d15f8df32e04d4329ebf3c10bf8285b Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 16 Sep 2026 12:28:35 -0400 Subject: [PATCH] NFSD: Remove '#include "xdr.h"' from fs/nfsd/xdr3.h Separate the dependencies between fs/nfsd/xdr3.h and fs/nfsd/xdr.h so that NFSD's NFSv2 and NFSv3 implementations can be converted independently to use xdrgen. The only reason xdr3.h includes xdr.h is to pick up the definition of struct nfsd_fhandle. xdr3.h does not name the structure itself; its consumers nfs3proc.c and nfs3xdr.c do, reaching the definition through xdr3.h. That structure wraps a single struct svc_fh, which is defined in nfsfh.h, a header both xdr.h and xdr3.h already include via vfs.h. Move struct nfsd_fhandle next to svc_fh in nfsfh.h so the two XDR headers share one definition and xdr3.h no longer depends on xdr.h. nfs2acl.c, which includes both headers, then sees that single definition instead of a clashing pair. Stripping xdr.h to its own dependencies also removes the transitive route by which nfsxdr.c and nfs3xdr.c reached nfsd.h. Both expand the nfserr_* and nfs_ok status-code macros that nfsd.h defines, so each gains a direct #include of nfsd.h in place of the one xdr.h used to supply. As a clean-up, the #includes at the top of both header files are made the same. Acked-by: Jeff Layton Link: https://patch.msgid.link/20260916162859.2051-7-cel@kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs2acl.c | 2 +- fs/nfsd/nfs3xdr.c | 2 ++ fs/nfsd/nfsfh.h | 5 +++++ fs/nfsd/xdr.h | 7 +------ fs/nfsd/xdr3.h | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 0673e83b6666..eada1ab51415 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -10,8 +10,8 @@ /* FIXME: nfsacl.h is a broken header */ #include #include -#include #include "cache.h" +#include "xdr.h" #include "xdr3.h" #include "vfs.h" diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index a14e829e1c41..f0895f5e32f6 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -10,6 +10,8 @@ #include #include #include + +#include "nfsd.h" #include "xdr3.h" #include "auth.h" #include "netns.h" diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h index 7d8e3f015307..aa3ff3086406 100644 --- a/fs/nfsd/nfsfh.h +++ b/fs/nfsd/nfsfh.h @@ -111,6 +111,11 @@ typedef struct svc_fh { struct kstat fh_post_attr; /* full attrs after operation */ u64 fh_post_change; /* nfsv4 change; see above */ } svc_fh; + +struct nfsd_fhandle { + struct svc_fh fh; +}; + #define NFSD4_FH_FOREIGN (1<<0) #define SET_FH_FLAG(c, f) ((c)->fh_flags |= (f)) #define HAS_FH_FLAG(c, f) ((c)->fh_flags & (f)) diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h index 52660b9f8dde..a2a3b2f58a1d 100644 --- a/fs/nfsd/xdr.h +++ b/fs/nfsd/xdr.h @@ -5,13 +5,8 @@ #define _LINUX_NFSD_XDR_H #include -#include "nfsd.h" -#include "nfsfh.h" -#include "vfs.h" -struct nfsd_fhandle { - struct svc_fh fh; -}; +#include "vfs.h" struct nfsd_sattrargs { struct svc_fh fh; diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index cad875d14231..22272695e451 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -8,7 +8,8 @@ #ifndef _LINUX_NFSD_XDR3_H #define _LINUX_NFSD_XDR3_H -#include "xdr.h" +#include + #include "vfs.h" struct nfsd3_sattrargs {