svn commit: r352269 - projects/nfsv42/sys/fs/nfs
Rick Macklem
rmacklem at FreeBSD.org
Fri Sep 13 01:03:55 UTC 2019
Author: rmacklem
Date: Fri Sep 13 01:03:54 2019
New Revision: 352269
URL: https://svnweb.freebsd.org/changeset/base/352269
Log:
Add support for xattr_support attribute to the NFSv4.2 server.
RFC-8276 adds a recommended attribute called xattr_support to indicate if
a server supports the extended attribute operations.
This patch adds support for it to the server. The client does not use this
attribute.
The patch also adds definitions for the extended attribute access operation
bits.
Modified:
projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c
projects/nfsv42/sys/fs/nfs/nfsproto.h
Modified: projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c Fri Sep 13 00:58:33 2019 (r352268)
+++ projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c Fri Sep 13 01:03:54 2019 (r352269)
@@ -47,6 +47,8 @@ __FBSDID("$FreeBSD$");
#include <fs/nfs/nfsport.h>
+#include <sys/extattr.h>
+
#include <security/mac/mac_framework.h>
/*
@@ -2485,6 +2487,8 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount
struct nfsfsinfo fsinf;
struct timespec temptime;
NFSACL_T *aclp, *naclp = NULL;
+ size_t atsiz;
+ bool xattrsupp;
#ifdef QUOTA
struct dqblk dqb;
uid_t savuid;
@@ -2559,6 +2563,18 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount
}
}
+ /* Check to see if Extended Attributes are supported. */
+ xattrsupp = false;
+ if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_XATTRSUPPORT)) {
+ if (NFSVOPLOCK(vp, LK_SHARED) == 0) {
+ error = VOP_GETEXTATTR(vp, EXTATTR_NAMESPACE_USER,
+ "xxx", NULL, &atsiz, cred, p);
+ NFSVOPUNLOCK(vp, 0);
+ if (error != EOPNOTSUPP)
+ xattrsupp = true;
+ }
+ }
+
/*
* Put out the attribute bitmap for the ones being filled in
* and get the field for the number of attributes returned.
@@ -3006,6 +3022,14 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount
case NFSATTRBIT_LAYOUTBLKSIZE:
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
*tl = txdr_unsigned(NFS_SRVMAXIO);
+ retnum += NFSX_UNSIGNED;
+ break;
+ case NFSATTRBIT_XATTRSUPPORT:
+ NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
+ if (xattrsupp)
+ *tl = newnfs_true;
+ else
+ *tl = newnfs_false;
retnum += NFSX_UNSIGNED;
break;
default:
Modified: projects/nfsv42/sys/fs/nfs/nfsproto.h
==============================================================================
--- projects/nfsv42/sys/fs/nfs/nfsproto.h Fri Sep 13 00:58:33 2019 (r352268)
+++ projects/nfsv42/sys/fs/nfs/nfsproto.h Fri Sep 13 01:03:54 2019 (r352269)
@@ -629,6 +629,11 @@
#define NFSACCESS_DELETE 0x10
#define NFSACCESS_EXECUTE 0x20
+/* Additional Extended Attribute access bits RFC-8276. */
+#define NFSACCESS_XAREAD 0x40
+#define NFSACCESS_XAWRITE 0x80
+#define NFSACCESS_XALIST 0x100
+
#define NFSWRITE_UNSTABLE 0
#define NFSWRITE_DATASYNC 1
#define NFSWRITE_FILESYNC 2
@@ -978,6 +983,8 @@ struct nfsv3_sattr {
#define NFSATTRBIT_SPACEFREED 78
#define NFSATTRBIT_CHANGEATTRTYPE 79
#define NFSATTRBIT_SECLABEL 80
+/* Not sure what attribute bit #81 is? */
+#define NFSATTRBIT_XATTRSUPPORT 82
#define NFSATTRBM_SUPPORTEDATTRS 0x00000001
#define NFSATTRBM_TYPE 0x00000002
@@ -1060,8 +1067,10 @@ struct nfsv3_sattr {
#define NFSATTRBM_SPACEFREED 0x00004000
#define NFSATTRBM_CHANGEATTRTYPE 0x00008000
#define NFSATTRBM_SECLABEL 0x00010000
+/* Not sure what attribute bit#81/0x00020000 is? */
+#define NFSATTRBM_XATTRSUPPORT 0x00040000
-#define NFSATTRBIT_MAX 81
+#define NFSATTRBIT_MAX 83
/*
* Sets of attributes that are supported, by words in the bitmap.
@@ -1145,7 +1154,8 @@ struct nfsv3_sattr {
(NFSATTRBM_LAYOUTTYPE | \
NFSATTRBM_LAYOUTBLKSIZE | \
NFSATTRBM_LAYOUTALIGNMENT | \
- NFSATTRBM_SUPPATTREXCLCREAT)
+ NFSATTRBM_SUPPATTREXCLCREAT | \
+ NFSATTRBM_XATTRSUPPORT)
/*
* These are the set only attributes.
@@ -1186,7 +1196,7 @@ struct nfsv3_sattr {
/*
* NFSATTRBIT_NFSV42 - Attributes only supported by NFSv4.2.
*/
-#define NFSATTRBIT_NFSV42_2 0
+#define NFSATTRBIT_NFSV42_2 NFSATTRBM_XATTRSUPPORT
/*
* Set of attributes that the getattr vnode op needs.
More information about the svn-src-projects
mailing list