Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Apr 2011 18:30:54 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r221217 - in stable/8/sys/fs: nfs nfsclient nfsserver
Message-ID:  <201104291830.p3TIUst7010329@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Fri Apr 29 18:30:53 2011
New Revision: 221217
URL: http://svn.freebsd.org/changeset/base/221217

Log:
  MFC: r220648
  Fix the experimental NFSv4 server so that it uses VOP_PATHCONF()
  to determine if a file system supports NFSv4 ACLs. Since
  VOP_PATHCONF() must be called with a locked vnode, the function
  is called before nfsvno_fillattr() and the result is passed in
  as an extra argument.

Modified:
  stable/8/sys/fs/nfs/nfs_commonacl.c
  stable/8/sys/fs/nfs/nfs_commonport.c
  stable/8/sys/fs/nfs/nfs_commonsubs.c
  stable/8/sys/fs/nfs/nfs_var.h
  stable/8/sys/fs/nfs/nfsport.h
  stable/8/sys/fs/nfsclient/nfs_clport.c
  stable/8/sys/fs/nfsclient/nfs_clrpcops.c
  stable/8/sys/fs/nfsclient/nfs_clstate.c
  stable/8/sys/fs/nfsserver/nfs_nfsdport.c
  stable/8/sys/fs/nfsserver/nfs_nfsdserv.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/fs/nfs/nfs_commonacl.c
==============================================================================
--- stable/8/sys/fs/nfs/nfs_commonacl.c	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfs/nfs_commonacl.c	Fri Apr 29 18:30:53 2011	(r221217)
@@ -445,7 +445,7 @@ nfsrv_setacl(vnode_t vp, NFSACL_T *aclp,
 {
 	int error;
 
-	if (nfsrv_useacl == 0 || !NFSHASNFS4ACL(vnode_mount(vp)))
+	if (nfsrv_useacl == 0 || nfs_supportsnfsv4acls(vp) == 0)
 		return (NFSERR_ATTRNOTSUPP);
 	/*
 	 * With NFSv4 ACLs, chmod(2) may need to add additional entries.

Modified: stable/8/sys/fs/nfs/nfs_commonport.c
==============================================================================
--- stable/8/sys/fs/nfs/nfs_commonport.c	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfs/nfs_commonport.c	Fri Apr 29 18:30:53 2011	(r221217)
@@ -437,18 +437,18 @@ newnfs_portinit(void)
  * Return 1 if it does, 0 otherwise.
  */
 int
-nfs_supportsnfsv4acls(struct mount *mp)
+nfs_supportsnfsv4acls(struct vnode *vp)
 {
+	int error;
+	register_t retval;
 
-	if (mp->mnt_stat.f_fstypename == NULL)
-		return (0);
-	if (strcmp(mp->mnt_stat.f_fstypename, "ufs") == 0) {
-		/* Not yet */
+	ASSERT_VOP_LOCKED(vp, "nfs supports nfsv4acls");
+
+	if (nfsrv_useacl == 0)
 		return (0);
-	} else if (strcmp(mp->mnt_stat.f_fstypename, "zfs") == 0) {
-		/* Always supports them */
+	error = VOP_PATHCONF(vp, _PC_ACL_NFS4, &retval);
+	if (error == 0 && retval != 0)
 		return (1);
-	}
 	return (0);
 }
 

Modified: stable/8/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- stable/8/sys/fs/nfs/nfs_commonsubs.c	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfs/nfs_commonsubs.c	Fri Apr 29 18:30:53 2011	(r221217)
@@ -1919,7 +1919,7 @@ APPLESTATIC int
 nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp,
     NFSACL_T *saclp, struct vattr *vap, fhandle_t *fhp, int rderror,
     nfsattrbit_t *attrbitp, struct ucred *cred, NFSPROC_T *p, int isdgram,
-    int reterr, int at_root, uint64_t mounted_on_fileno)
+    int reterr, int supports_nfsv4acls, int at_root, uint64_t mounted_on_fileno)
 {
 	int bitpos, retnum = 0;
 	u_int32_t *tl;
@@ -1974,12 +1974,12 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 	 */
 	if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_ACLSUPPORT) &&
 	    (nfsrv_useacl == 0 || ((cred != NULL || p != NULL) &&
-		!NFSHASNFS4ACL(mp)))) {
+		supports_nfsv4acls == 0))) {
 		NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACLSUPPORT);
 	}
 	if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_ACL)) {
 		if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL) &&
-		    !NFSHASNFS4ACL(mp))) {
+		    supports_nfsv4acls == 0)) {
 			NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACL);
 		} else if (naclp != NULL) {
 			if (vn_lock(vp, LK_SHARED) == 0) {
@@ -2016,7 +2016,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 		case NFSATTRBIT_SUPPORTEDATTRS:
 			NFSSETSUPP_ATTRBIT(&attrbits);
 			if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL)
-			    && !NFSHASNFS4ACL(mp))) {
+			    && supports_nfsv4acls == 0)) {
 			    NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACLSUPPORT);
 			    NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACL);
 			}

Modified: stable/8/sys/fs/nfs/nfs_var.h
==============================================================================
--- stable/8/sys/fs/nfs/nfs_var.h	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfs/nfs_var.h	Fri Apr 29 18:30:53 2011	(r221217)
@@ -290,7 +290,7 @@ void nfsrv_wcc(struct nfsrv_descript *, 
     struct nfsvattr *);
 int nfsv4_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, NFSACL_T *,
     struct vattr *, fhandle_t *, int, nfsattrbit_t *,
-    struct ucred *, NFSPROC_T *, int, int, int, uint64_t);
+    struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t);
 void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *);
 void nfsrv_adj(mbuf_t, int, int);
 void nfsrv_postopattr(struct nfsrv_descript *, int, struct nfsvattr *);
@@ -328,6 +328,7 @@ int nfs_catnap(int, int, const char *);
 struct nfsreferral *nfsv4root_getreferral(vnode_t, vnode_t, u_int32_t);
 int nfsrv_atroot(vnode_t, long *);
 void newnfs_timer(void *);
+int nfs_supportsnfsv4acls(vnode_t);
 
 /* nfs_commonacl.c */
 int nfsrv_dissectace(struct nfsrv_descript *, struct acl_entry *,
@@ -558,7 +559,7 @@ void nfsvno_updfilerev(vnode_t, struct n
     NFSPROC_T *);
 int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t,
     struct nfsvattr *, fhandle_t *, int, nfsattrbit_t *,
-    struct ucred *, NFSPROC_T *, int, int, int, uint64_t);
+    struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t);
 int nfsrv_sattr(struct nfsrv_descript *, struct nfsvattr *, nfsattrbit_t *,
     NFSACL_T *, NFSPROC_T *);
 int nfsv4_sattr(struct nfsrv_descript *, struct nfsvattr *, nfsattrbit_t *,

Modified: stable/8/sys/fs/nfs/nfsport.h
==============================================================================
--- stable/8/sys/fs/nfs/nfsport.h	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfs/nfsport.h	Fri Apr 29 18:30:53 2011	(r221217)
@@ -778,12 +778,6 @@ void newnfs_realign(struct mbuf **);
 #define	NFSHASPRIVACY(n)	((n)->nm_flag & NFSMNT_PRIVACY)
 #define	NFSSETWRITEVERF(n)	((n)->nm_state |= NFSSTA_HASWRITEVERF)
 #define	NFSSETHASSETFSID(n)	((n)->nm_state |= NFSSTA_HASSETFSID)
-#ifdef NFS4_ACL_EXTATTR_NAME
-#define	NFSHASNFS4ACL(m)	nfs_supportsnfsv4acls(m)
-int nfs_supportsnfsv4acls(struct mount *);
-#else
-#define	NFSHASNFS4ACL(m)	0
-#endif
 
 /*
  * Gets the stats field out of the mount structure.

Modified: stable/8/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clport.c	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfsclient/nfs_clport.c	Fri Apr 29 18:30:53 2011	(r221217)
@@ -804,7 +804,7 @@ nfscl_fillsattr(struct nfsrv_descript *n
 		if (vap->va_mtime.tv_sec != VNOVAL)
 			NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEMODIFYSET);
 		(void) nfsv4_fillattr(nd, vp->v_mount, vp, NULL, vap, NULL, 0,
-		    &attrbits, NULL, NULL, 0, 0, 0, (uint64_t)0);
+		    &attrbits, NULL, NULL, 0, 0, 0, 0, (uint64_t)0);
 		break;
 	};
 }

Modified: stable/8/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clrpcops.c	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfsclient/nfs_clrpcops.c	Fri Apr 29 18:30:53 2011	(r221217)
@@ -4177,7 +4177,7 @@ nfsrpc_setaclrpc(vnode_t vp, struct ucre
 	NFSZERO_ATTRBIT(&attrbits);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
 	(void) nfsv4_fillattr(nd, vnode_mount(vp), vp, aclp, NULL, NULL, 0,
-	    &attrbits, NULL, NULL, 0, 0, 0, (uint64_t)0);
+	    &attrbits, NULL, NULL, 0, 0, 0, 0, (uint64_t)0);
 	error = nfscl_request(nd, vp, p, cred, stuff);
 	if (error)
 		return (error);

Modified: stable/8/sys/fs/nfsclient/nfs_clstate.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clstate.c	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfsclient/nfs_clstate.c	Fri Apr 29 18:30:53 2011	(r221217)
@@ -3062,7 +3062,7 @@ nfscl_docb(struct nfsrv_descript *nd, NF
 					    NFSATTRBIT_CHANGE);
 				}
 				(void) nfsv4_fillattr(nd, NULL, NULL, NULL, &va,
-				    NULL, 0, &rattrbits, NULL, NULL, 0, 0, 0,
+				    NULL, 0, &rattrbits, NULL, NULL, 0, 0, 0, 0,
 				    (uint64_t)0);
 				if (!ret)
 					vrele(vp);

Modified: stable/8/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- stable/8/sys/fs/nfsserver/nfs_nfsdport.c	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfsserver/nfs_nfsdport.c	Fri Apr 29 18:30:53 2011	(r221217)
@@ -1393,13 +1393,14 @@ nfsvno_updfilerev(struct vnode *vp, stru
 int
 nfsvno_fillattr(struct nfsrv_descript *nd, struct mount *mp, struct vnode *vp,
     struct nfsvattr *nvap, fhandle_t *fhp, int rderror, nfsattrbit_t *attrbitp,
-    struct ucred *cred, struct thread *p, int isdgram, int reterr, int at_root,
-    uint64_t mounted_on_fileno)
+    struct ucred *cred, struct thread *p, int isdgram, int reterr,
+    int supports_nfsv4acls, int at_root, uint64_t mounted_on_fileno)
 {
 	int error;
 
 	error = nfsv4_fillattr(nd, mp, vp, NULL, &nvap->na_vattr, fhp, rderror,
-	    attrbitp, cred, p, isdgram, reterr, at_root, mounted_on_fileno);
+	    attrbitp, cred, p, isdgram, reterr, supports_nfsv4acls, at_root,
+	    mounted_on_fileno);
 	return (error);
 }
 
@@ -1689,7 +1690,7 @@ nfsrvd_readdirplus(struct nfsrv_descript
 	struct uio io;
 	struct iovec iv;
 	struct componentname cn;
-	int at_root, needs_unbusy, not_zfs;
+	int at_root, needs_unbusy, not_zfs, supports_nfsv4acls;
 	struct mount *mp, *new_mp;
 	uint64_t mounted_on_fileno;
 
@@ -2058,8 +2059,12 @@ again:
 				*tl++ = 0;
 				*tl = txdr_unsigned(*cookiep);
 				dirlen += nfsm_strtom(nd, dp->d_name, nlen);
-				if (nvp != NULL)
+				if (nvp != NULL) {
+					supports_nfsv4acls =
+					    nfs_supportsnfsv4acls(nvp);
 					VOP_UNLOCK(nvp, 0);
+				} else
+					supports_nfsv4acls = 0;
 				if (refp != NULL) {
 					dirlen += nfsrv_putreferralattr(nd,
 					    &savbits, refp, 0,
@@ -2074,12 +2079,14 @@ again:
 				} else if (r) {
 					dirlen += nfsvno_fillattr(nd, new_mp,
 					    nvp, nvap, &nfh, r, &rderrbits,
-					    nd->nd_cred, p, isdgram, 0, at_root,
+					    nd->nd_cred, p, isdgram, 0,
+					    supports_nfsv4acls, at_root,
 					    mounted_on_fileno);
 				} else {
 					dirlen += nfsvno_fillattr(nd, new_mp,
 					    nvp, nvap, &nfh, r, &attrbits,
-					    nd->nd_cred, p, isdgram, 0, at_root,
+					    nd->nd_cred, p, isdgram, 0,
+					    supports_nfsv4acls, at_root,
 					    mounted_on_fileno);
 				}
 				if (nvp != NULL)

Modified: stable/8/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- stable/8/sys/fs/nfsserver/nfs_nfsdserv.c	Fri Apr 29 18:27:50 2011	(r221216)
+++ stable/8/sys/fs/nfsserver/nfs_nfsdserv.c	Fri Apr 29 18:30:53 2011	(r221217)
@@ -170,7 +170,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd
 {
 	struct nfsvattr nva;
 	fhandle_t fh;
-	int at_root = 0, error = 0;
+	int at_root = 0, error = 0, supports_nfsv4acls;
 	struct nfsreferral *refp;
 	nfsattrbit_t attrbits;
 	struct mount *mp;
@@ -213,6 +213,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd
 				nd->nd_repstat = nfsrv_checkgetattr(nd, vp,
 				    &nva, &attrbits, nd->nd_cred, p);
 			if (nd->nd_repstat == 0) {
+				supports_nfsv4acls = nfs_supportsnfsv4acls(vp);
 				mp = vp->v_mount;
 				if (nfsrv_enable_crossmntpt != 0 &&
 				    vp->v_type == VDIR &&
@@ -245,8 +246,8 @@ nfsrvd_getattr(struct nfsrv_descript *nd
 				if (nd->nd_repstat == 0) {
 					(void)nfsvno_fillattr(nd, mp, vp, &nva,
 					    &fh, 0, &attrbits, nd->nd_cred, p,
-					    isdgram, 1, at_root,
-					    mounted_on_fileno);
+					    isdgram, 1, supports_nfsv4acls,
+					    at_root, mounted_on_fileno);
 					vfs_unbusy(mp);
 				}
 				vrele(vp);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104291830.p3TIUst7010329>