Skip to contentSkip to conversation

NFSD: Move the nfs3.h include out of nfsd.h

PATCH In review Chuck Lever 2 participants 6 messages Aug 18 – Aug 19

Subsystems (2)
lore
Share & tools
lore

Chuck Lever

author maintainer
#0 lore raw

PATCH 1/3 NFSD: Move the nfs3.h include out of nfsd.h

fs/nfsd/nfsd.h is included throughout the server, yet it uses no NFSv3 protocol definition of its own. The <linux/nfs3.h> include there served only to make those definitions reach the few source files that need them, by way of nfsd.h itself or the xdr.h chain that pulls it in.

Give each consumer its own include and drop the one in nfsd.h, so the header no longer carries a dependency unrelated to its contents. nfsfh.c, nfsctl.c, nfs3xdr.c, nfs3proc.c, and nfs2acl.c reference NFS3_* definitions directly; add <linux/nfs3.h> to each.

---
 fs/nfsd/nfs2acl.c  | 1 +
 fs/nfsd/nfs3proc.c | 1 +
 fs/nfsd/nfs3xdr.c  | 1 +
 fs/nfsd/nfsctl.c   | 1 +
 fs/nfsd/nfsd.h     | 1 -
 fs/nfsd/nfsfh.c    | 1 +
 6 files changed, 5 insertions(+), 1 deletion(-)
fs/nfsd/nfs2acl.c +1 -0
index 33610deda3b0..0a5c444fef99 100644
@@ -10,6 +10,7 @@
 /* FIXME: nfsacl.h is a broken header */
 #include <linux/nfsacl.h>
 #include <linux/gfp.h>
+#include <linux/nfs3.h>
 #include "cache.h"
 #include "xdr3.h"
 #include "vfs.h"
fs/nfsd/nfs3proc.c +1 -0
index 17bbe5d13f18..60cd01b6a37d 100644
@@ -9,6 +9,7 @@
 #include <linux/ext2_fs.h>
 #include <linux/magic.h>
 #include <linux/namei.h>
+#include <linux/nfs3.h>
 
 #include "cache.h"
 #include "xdr3.h"
fs/nfsd/nfs3xdr.c +1 -0
index 090cea8e545d..a14e829e1c41 100644
@@ -8,6 +8,7 @@
  */
 
 #include <linux/namei.h>
+#include <linux/nfs3.h>
 #include <linux/sunrpc/svc_xprt.h>
 #include "xdr3.h"
 #include "auth.h"
fs/nfsd/nfsctl.c +1 -0
index 4e5e083d8477..0117b89ba538 100644
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 #include <linux/fsnotify.h>
 #include <linux/nfslocalio.h>
+#include <linux/nfs3.h>
 
 #include "idmap.h"
 #include "nfsd.h"
fs/nfsd/nfsd.h +0 -1
index 64315890eef5..a145294c59c8 100644
@@ -14,7 +14,6 @@
 
 #include <linux/nfs.h>
 #include <linux/nfs2.h>
-#include <linux/nfs3.h>
 #include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/svc_xprt.h>
 
fs/nfsd/nfsfh.c +1 -0
index b1f3c22af525..2bd6907f443f 100644
@@ -9,6 +9,7 @@
  */
 
 #include <linux/exportfs.h>
+#include <linux/nfs3.h>
 
 #include <linux/sunrpc/svcauth_gss.h>
 #include <crypto/utils.h>
Signature · 1 line
2.54.0
author maintainer
#1 lore raw

PATCH 2/3 NFSD: Include <linux/nfs_fh.h> where struct nfs_fh is used

struct nfsd4_copy embeds a struct nfs_fh, and nlm_fopen() reads the size and data fields of one. Neither fs/nfsd/xdr4.h nor fs/nfsd/lockd.c includes the header that defines the type; both reach it by way of nfsd.h, which pulls in <linux/nfs.h>.

Add the direct include to both files, so nfsd.h can later drop the <linux/nfs.h> it carries for no use of its own.

---
 fs/nfsd/lockd.c | 1 +
 fs/nfsd/xdr4.h  | 2 ++
 2 files changed, 3 insertions(+)
fs/nfsd/lockd.c +1 -0
index 5ec0f5456063..f24e45dc37a0 100644
@@ -9,6 +9,7 @@
 
 #include <linux/file.h>
 #include <linux/lockd/bind.h>
+#include <linux/nfs_fh.h>
 #include "nfsd.h"
 #include "nfserr.h"
 #include "vfs.h"
fs/nfsd/xdr4.h +2 -0
index 7bbb375874ef..b841bc462dac 100644
@@ -37,6 +37,8 @@
 #ifndef _LINUX_NFSD_XDR4_H
 #define _LINUX_NFSD_XDR4_H
 
+#include <linux/nfs_fh.h>
+
 #include "state.h"
 #include "vfs.h"
 
Signature · 1 line
2.54.0
author maintainer
#3 lore raw

PATCH 3/3 NFSD: Clean up header guards in fs/nfsd/xdr.h

In reply to Chuck Lever

Make the header guards less ambiguous about their provenance.

---
 fs/nfsd/xdr.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/nfsd/xdr.h +3 -3
index df540c940cef..52660b9f8dde 100644
@@ -1,8 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* XDR types for nfsd. This is mainly a typing exercise. */
 
-#ifndef LINUX_NFSD_H
-#define LINUX_NFSD_H
+#ifndef _LINUX_NFSD_XDR_H
+#define _LINUX_NFSD_XDR_H
 
 #include <linux/vfs.h>
 #include "nfsd.h"
@@ -175,4 +175,4 @@ bool svcxdr_encode_stat(struct xdr_stream *xdr, __be32 status);
 bool svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
 			 const struct svc_fh *fhp, const struct kstat *stat);
 
-#endif /* LINUX_NFSD_H */
+#endif /* _LINUX_NFSD_XDR_H */
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 1/3
#5 lore raw
In reply to Chuck Lever
Quoted 86 lines · Chuck Lever

fs/nfsd/nfsd.h is included throughout the server, yet it uses no NFSv3 protocol definition of its own. The <linux/nfs3.h> include there served only to make those definitions reach the few source files that need them, by way of nfsd.h itself or the xdr.h chain that pulls it in.

Give each consumer its own include and drop the one in nfsd.h, so the header no longer carries a dependency unrelated to its contents. nfsfh.c, nfsctl.c, nfs3xdr.c, nfs3proc.c, and nfs2acl.c reference NFS3_* definitions directly; add <linux/nfs3.h> to each.

---
 fs/nfsd/nfs2acl.c  | 1 +
 fs/nfsd/nfs3proc.c | 1 +
 fs/nfsd/nfs3xdr.c  | 1 +
 fs/nfsd/nfsctl.c   | 1 +
 fs/nfsd/nfsd.h     | 1 -
 fs/nfsd/nfsfh.c    | 1 +
 6 files changed, 5 insertions(+), 1 deletion(-)
fs/nfsd/nfs2acl.c +1 -0
index 33610deda3b0..0a5c444fef99 100644
@@ -10,6 +10,7 @@
 /* FIXME: nfsacl.h is a broken header */
 #include <linux/nfsacl.h>
 #include <linux/gfp.h>
+#include <linux/nfs3.h>
 #include "cache.h"
 #include "xdr3.h"
 #include "vfs.h"
fs/nfsd/nfs3proc.c +1 -0
index 17bbe5d13f18..60cd01b6a37d 100644
@@ -9,6 +9,7 @@
 #include <linux/ext2_fs.h>
 #include <linux/magic.h>
 #include <linux/namei.h>
+#include <linux/nfs3.h>
 
 #include "cache.h"
 #include "xdr3.h"
fs/nfsd/nfs3xdr.c +1 -0
index 090cea8e545d..a14e829e1c41 100644
@@ -8,6 +8,7 @@
  */
 
 #include <linux/namei.h>
+#include <linux/nfs3.h>
 #include <linux/sunrpc/svc_xprt.h>
 #include "xdr3.h"
 #include "auth.h"
fs/nfsd/nfsctl.c +1 -0
index 4e5e083d8477..0117b89ba538 100644
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 #include <linux/fsnotify.h>
 #include <linux/nfslocalio.h>
+#include <linux/nfs3.h>
 
 #include "idmap.h"
 #include "nfsd.h"
fs/nfsd/nfsd.h +0 -1
index 64315890eef5..a145294c59c8 100644
@@ -14,7 +14,6 @@
 
 #include <linux/nfs.h>
 #include <linux/nfs2.h>
-#include <linux/nfs3.h>
 #include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/svc_xprt.h>
 
fs/nfsd/nfsfh.c +0 -0
index b1f3c22af525..2bd6907f443f 100644

fs/nfsd/nfsfh.c line 15

Quoted 7 lines
fs/nfsd/nfsfh.c +1 -0
@@ -9,6 +9,7 @@
  */
 
 #include <linux/exportfs.h>
+#include <linux/nfs3.h>
 
 #include <linux/sunrpc/svcauth_gss.h>
 #include <crypto/utils.h>
maintainer Reviewed-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] NFSD: Include <linux/nfs_fh.h> where struct nfs_fh is used

In reply to Chuck Lever
Quoted 31 lines · Chuck Lever

struct nfsd4_copy embeds a struct nfs_fh, and nlm_fopen() reads the size and data fields of one. Neither fs/nfsd/xdr4.h nor fs/nfsd/lockd.c includes the header that defines the type; both reach it by way of nfsd.h, which pulls in <linux/nfs.h>.

Add the direct include to both files, so nfsd.h can later drop the <linux/nfs.h> it carries for no use of its own.

---
 fs/nfsd/lockd.c | 1 +
 fs/nfsd/xdr4.h  | 2 ++
 2 files changed, 3 insertions(+)
fs/nfsd/lockd.c +1 -0
index 5ec0f5456063..f24e45dc37a0 100644
@@ -9,6 +9,7 @@
 
 #include <linux/file.h>
 #include <linux/lockd/bind.h>
+#include <linux/nfs_fh.h>
 #include "nfsd.h"
 #include "nfserr.h"
 #include "vfs.h"
fs/nfsd/xdr4.h +0 -0
index 7bbb375874ef..b841bc462dac 100644

fs/nfsd/xdr4.h line 44

Quoted 8 lines
fs/nfsd/xdr4.h +2 -0
@@ -37,6 +37,8 @@
 #ifndef _LINUX_NFSD_XDR4_H
 #define _LINUX_NFSD_XDR4_H
 
+#include <linux/nfs_fh.h>
+
 #include "state.h"
 #include "vfs.h"
 
maintainer Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] NFSD: Clean up header guards in fs/nfsd/xdr.h

In reply to Chuck Lever
Quoted 23 lines · Chuck Lever

Make the header guards less ambiguous about their provenance.

---
 fs/nfsd/xdr.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/nfsd/xdr.h +2 -2
index df540c940cef..52660b9f8dde 100644
@@ -1,8 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* XDR types for nfsd. This is mainly a typing exercise. */
 
-#ifndef LINUX_NFSD_H
-#define LINUX_NFSD_H
+#ifndef _LINUX_NFSD_XDR_H
+#define _LINUX_NFSD_XDR_H
 
 #include <linux/vfs.h>
 #include "nfsd.h"

fs/nfsd/xdr.h bool svcxdr_encode_stat(struct xdr_stream *xdr, __be32 status); · line 178

Quoted 5 lines
fs/nfsd/xdr.h +1 -1
@@ -175,4 +175,4 @@ bool svcxdr_encode_stat(struct xdr_stream *xdr, __be32 status);
 bool svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
 			 const struct svc_fh *fhp, const struct kstat *stat);
 
-#endif /* LINUX_NFSD_H */
+#endif /* _LINUX_NFSD_XDR_H */