diff mbox series

[RFC,34/35] nfsd: add export flag to disable user extended attributes

Message ID 78ebac8806c7a8753c629fddb5dfa7340f8325a2.1568309119.git.fllinden@amazon.com (mailing list archive)
State New, archived
Headers show
Series user xattr support (RFC8276) | expand

Commit Message

Frank van der Linden Sept. 2, 2019, 11:06 p.m. UTC
Like with some other features, add a flag that allows a filesystem
to be exported without extended user attribute support, even if
support is compiled in.

Signed-off-by: Frank van der Linden <fllinden@amazon.com>
---
 fs/nfsd/export.c                 |  1 +
 fs/nfsd/nfs4xdr.c                |  7 +++++--
 fs/nfsd/vfs.c                    | 12 ++++++++++++
 include/uapi/linux/nfsd/export.h |  3 ++-
 4 files changed, 20 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index baa01956a5b3..4e363272f757 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1105,6 +1105,7 @@  static struct flags {
 	{ NFSEXP_V4ROOT, {"v4root", ""}},
 	{ NFSEXP_PNFS, {"pnfs", ""}},
 	{ NFSEXP_SECURITY_LABEL, {"security_label", ""}},
+	{ NFSEXP_NOUSERXATTR, {"no_userxattr", ""}},
 	{ 0, {"", ""}}
 };
 
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 92b9a067c744..4ed0fb023ee1 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3154,8 +3154,11 @@  nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
 		p = xdr_reserve_space(xdr, 4);
 		if (!p)
 			goto out_resource;
-		err = xattr_supported_namespace(d_inode(dentry),
-						XATTR_USER_PREFIX);
+		if (exp->ex_flags & NFSEXP_NOUSERXATTR)
+			err = -EOPNOTSUPP;
+		else
+			err = xattr_supported_namespace(d_inode(dentry),
+							XATTR_USER_PREFIX);
 		*p++ = cpu_to_be32(err == 0);
 	}
 #endif
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index d76e3041fa8e..97a40dbd53a7 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -2046,6 +2046,9 @@  nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name, void *buf,
 	if (err)
 		return err;
 
+	if (fhp->fh_export->ex_flags & NFSEXP_NOUSERXATTR)
+		return nfserr_opnotsupp;
+
 	lerr = vfs_getxattr(fhp->fh_dentry, name, buf, *lenp);
 	if (lerr < 0)
 		err = nfsd_xattr_errno(lerr);
@@ -2065,6 +2068,9 @@  nfsd_listxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, void *buf, int *lenp)
 	if (err)
 		return err;
 
+	if (fhp->fh_export->ex_flags & NFSEXP_NOUSERXATTR)
+		return nfserr_opnotsupp;
+
 	lerr = vfs_listxattr(fhp->fh_dentry, buf, *lenp);
 
 	if (lerr < 0)
@@ -2092,6 +2098,9 @@  nfsd_removexattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name)
 	if (err)
 		return err;
 
+	if (fhp->fh_export->ex_flags & NFSEXP_NOUSERXATTR)
+		return nfserr_opnotsupp;
+
 	ret = fh_want_write(fhp);
 	if (ret)
 		return nfserrno(ret);
@@ -2116,6 +2125,9 @@  nfsd_setxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
 	if (err)
 		return err;
 
+	if (fhp->fh_export->ex_flags & NFSEXP_NOUSERXATTR)
+		return nfserr_opnotsupp;
+
 	ret = fh_want_write(fhp);
 	if (ret)
 		return nfserrno(ret);
diff --git a/include/uapi/linux/nfsd/export.h b/include/uapi/linux/nfsd/export.h
index 2124ba904779..b46ee0240fca 100644
--- a/include/uapi/linux/nfsd/export.h
+++ b/include/uapi/linux/nfsd/export.h
@@ -53,9 +53,10 @@ 
  */
 #define	NFSEXP_V4ROOT		0x10000
 #define NFSEXP_PNFS		0x20000
+#define NFSEXP_NOUSERXATTR	0x40000
 
 /* All flags that we claim to support.  (Note we don't support NOACL.) */
-#define NFSEXP_ALLFLAGS		0x3FEFF
+#define NFSEXP_ALLFLAGS		0x7FEFF
 
 /* The flags that may vary depending on security flavor: */
 #define NFSEXP_SECINFO_FLAGS	(NFSEXP_READONLY | NFSEXP_ROOTSQUASH \