From owner-svn-src-projects@freebsd.org Fri Sep 13 01:03:55 2019 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D8890E0A9E for ; Fri, 13 Sep 2019 01:03:55 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46Ty7v5LKgz3yt1; Fri, 13 Sep 2019 01:03:55 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B790274C3; Fri, 13 Sep 2019 01:03:55 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x8D13t0l036300; Fri, 13 Sep 2019 01:03:55 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x8D13tmB036298; Fri, 13 Sep 2019 01:03:55 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201909130103.x8D13tmB036298@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 13 Sep 2019 01:03:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r352269 - projects/nfsv42/sys/fs/nfs X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/nfsv42/sys/fs/nfs X-SVN-Commit-Revision: 352269 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Sep 2019 01:03:55 -0000 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 +#include + #include /* @@ -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.