Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Apr 2009 16:47:33 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r191249 - in head/sys: kern sys ufs/ufs
Message-ID:  <200904181647.n3IGlXdp081435@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sat Apr 18 16:47:33 2009
New Revision: 191249
URL: http://svn.freebsd.org/changeset/base/191249

Log:
  Use acl_alloc() and acl_free() instead of using uma(9) directly.
  This will make switching to malloc(9) easier; also, it would be
  neccessary to add these routines if/when we implement variable-size
  ACLs.

Modified:
  head/sys/kern/vfs_acl.c
  head/sys/sys/acl.h
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/kern/vfs_acl.c
==============================================================================
--- head/sys/kern/vfs_acl.c	Sat Apr 18 16:36:27 2009	(r191248)
+++ head/sys/kern/vfs_acl.c	Sat Apr 18 16:47:33 2009	(r191249)
@@ -81,28 +81,31 @@ static int
 vacl_set_acl(struct thread *td, struct vnode *vp, acl_type_t type,
     struct acl *aclp)
 {
-	struct acl inkernacl;
+	struct acl *inkernelacl;
 	struct mount *mp;
 	int error;
 
-	error = copyin(aclp, &inkernacl, sizeof(struct acl));
+	inkernelacl = acl_alloc(M_WAITOK);
+	error = copyin(aclp, inkernelacl, sizeof(struct acl));
 	if (error)
-		return(error);
+		goto out;
 	error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
 	if (error != 0)
-		return (error);
+		goto out;
 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 #ifdef MAC
-	error = mac_vnode_check_setacl(td->td_ucred, vp, type, &inkernacl);
+	error = mac_vnode_check_setacl(td->td_ucred, vp, type, inkernelacl);
 	if (error != 0)
-		goto out;
+		goto out_unlock;
 #endif
-	error = VOP_SETACL(vp, type, &inkernacl, td->td_ucred, td);
+	error = VOP_SETACL(vp, type, inkernelacl, td->td_ucred, td);
 #ifdef MAC
-out:
+out_unlock:
 #endif
 	VOP_UNLOCK(vp, 0);
 	vn_finished_write(mp);
+out:
+	acl_free(inkernelacl);
 	return(error);
 }
 
@@ -113,22 +116,24 @@ static int
 vacl_get_acl(struct thread *td, struct vnode *vp, acl_type_t type,
     struct acl *aclp)
 {
-	struct acl inkernelacl;
+	struct acl *inkernelacl;
 	int error;
 
+	inkernelacl = acl_alloc(M_WAITOK);
 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 #ifdef MAC
 	error = mac_vnode_check_getacl(td->td_ucred, vp, type);
 	if (error != 0)
 		goto out;
 #endif
-	error = VOP_GETACL(vp, type, &inkernelacl, td->td_ucred, td);
+	error = VOP_GETACL(vp, type, inkernelacl, td->td_ucred, td);
 #ifdef MAC
 out:
 #endif
 	VOP_UNLOCK(vp, 0);
 	if (error == 0)
-		error = copyout(&inkernelacl, aclp, sizeof(struct acl));
+		error = copyout(inkernelacl, aclp, sizeof(struct acl));
+	acl_free(inkernelacl);
 	return (error);
 }
 
@@ -166,13 +171,16 @@ static int
 vacl_aclcheck(struct thread *td, struct vnode *vp, acl_type_t type,
     struct acl *aclp)
 {
-	struct acl inkernelacl;
+	struct acl *inkernelacl;
 	int error;
 
-	error = copyin(aclp, &inkernelacl, sizeof(struct acl));
+	inkernelacl = acl_alloc(M_WAITOK);
+	error = copyin(aclp, inkernelacl, sizeof(struct acl));
 	if (error)
-		return(error);
-	error = VOP_ACLCHECK(vp, type, &inkernelacl, td->td_ucred, td);
+		goto out;
+	error = VOP_ACLCHECK(vp, type, inkernelacl, td->td_ucred, td);
+out:
+	acl_free(inkernelacl);
 	return (error);
 }
 
@@ -417,6 +425,23 @@ __acl_aclcheck_fd(struct thread *td, str
 	return (error);
 }
 
+struct acl *
+acl_alloc(int flags)
+{
+	struct acl *aclp;
+
+	aclp = uma_zalloc(acl_zone, flags);
+
+	return (aclp);
+}
+
+void
+acl_free(struct acl *aclp)
+{
+
+	uma_zfree(acl_zone, aclp);
+}
+
 /* ARGUSED */
 
 static void

Modified: head/sys/sys/acl.h
==============================================================================
--- head/sys/sys/acl.h	Sat Apr 18 16:36:27 2009	(r191248)
+++ head/sys/sys/acl.h	Sat Apr 18 16:47:33 2009	(r191249)
@@ -116,8 +116,6 @@ typedef struct acl_t_struct *acl_t;
 
 #ifdef _KERNEL
 
-extern uma_zone_t	acl_zone;
-
 /*
  * POSIX.1e ACLs are capable of expressing the read, write, and execute bits
  * of the POSIX mode field.  We provide two masks: one that defines the bits
@@ -141,6 +139,8 @@ mode_t			acl_posix1e_perms_to_mode(
 mode_t			acl_posix1e_acl_to_mode(struct acl *acl);
 mode_t			acl_posix1e_newfilemode(mode_t cmode,
 			    struct acl *dacl);
+struct acl		*acl_alloc(int flags);
+void			acl_free(struct acl *aclp);
 
 /*
  * File system independent syntax check for a POSIX.1e ACL.

Modified: head/sys/ufs/ufs/ufs_vnops.c
==============================================================================
--- head/sys/ufs/ufs/ufs_vnops.c	Sat Apr 18 16:36:27 2009	(r191248)
+++ head/sys/ufs/ufs/ufs_vnops.c	Sat Apr 18 16:47:33 2009	(r191249)
@@ -374,7 +374,7 @@ relock:
 
 #ifdef UFS_ACL
 	if ((vp->v_mount->mnt_flag & MNT_ACLS) != 0) {
-		acl = uma_zalloc(acl_zone, M_WAITOK);
+		acl = acl_alloc(M_WAITOK);
 		error = VOP_GETACL(vp, ACL_TYPE_ACCESS, acl, ap->a_cred,
 		    ap->a_td);
 		switch (error) {
@@ -398,7 +398,7 @@ relock:
 			error = vaccess(vp->v_type, ip->i_mode, ip->i_uid,
 			    ip->i_gid, ap->a_accmode, ap->a_cred, NULL);
 		}
-		uma_zfree(acl_zone, acl);
+		acl_free(acl);
 	} else
 #endif /* !UFS_ACL */
 		error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid,
@@ -1507,8 +1507,8 @@ ufs_mkdir(ap)
 #ifdef UFS_ACL
 	acl = dacl = NULL;
 	if ((dvp->v_mount->mnt_flag & MNT_ACLS) != 0) {
-		acl = uma_zalloc(acl_zone, M_WAITOK);
-		dacl = uma_zalloc(acl_zone, M_WAITOK);
+		acl = acl_alloc(M_WAITOK);
+		dacl = acl_alloc(M_WAITOK);
 
 		/*
 		 * Retrieve default ACL from parent, if any.
@@ -1538,16 +1538,16 @@ ufs_mkdir(ap)
 			 */
 			ip->i_mode = dmode;
 			DIP_SET(ip, i_mode, dmode);
-			uma_zfree(acl_zone, acl);
-			uma_zfree(acl_zone, dacl);
+			acl_free(acl);
+			acl_free(dacl);
 			dacl = acl = NULL;
 			break;
 		
 		default:
 			UFS_VFREE(tvp, ip->i_number, dmode);
 			vput(tvp);
-			uma_zfree(acl_zone, acl);
-			uma_zfree(acl_zone, dacl);
+			acl_free(acl);
+			acl_free(dacl);
 			return (error);
 		}
 	} else {
@@ -1617,13 +1617,13 @@ ufs_mkdir(ap)
 			break;
 
 		default:
-			uma_zfree(acl_zone, acl);
-			uma_zfree(acl_zone, dacl);
+			acl_free(acl);
+			acl_free(dacl);
 			dacl = acl = NULL;
 			goto bad;
 		}
-		uma_zfree(acl_zone, acl);
-		uma_zfree(acl_zone, dacl);
+		acl_free(acl);
+		acl_free(dacl);
 		dacl = acl = NULL;
 	}
 #endif /* !UFS_ACL */
@@ -1689,9 +1689,9 @@ bad:
 	} else {
 #ifdef UFS_ACL
 		if (acl != NULL)
-			uma_zfree(acl_zone, acl);
+			acl_free(acl);
 		if (dacl != NULL)
-			uma_zfree(acl_zone, dacl);
+			acl_free(dacl);
 #endif
 		dp->i_effnlink--;
 		dp->i_nlink--;
@@ -2325,7 +2325,7 @@ ufs_makeinode(mode, dvp, vpp, cnp)
 #ifdef UFS_ACL
 	acl = NULL;
 	if ((dvp->v_mount->mnt_flag & MNT_ACLS) != 0) {
-		acl = uma_zalloc(acl_zone, M_WAITOK);
+		acl = acl_alloc(M_WAITOK);
 
 		/*
 		 * Retrieve default ACL for parent, if any.
@@ -2360,14 +2360,14 @@ ufs_makeinode(mode, dvp, vpp, cnp)
 			 */
 			ip->i_mode = mode;
 			DIP_SET(ip, i_mode, mode);
-			uma_zfree(acl_zone, acl);
+			acl_free(acl);
 			acl = NULL;
 			break;
 	
 		default:
 			UFS_VFREE(tvp, ip->i_number, mode);
 			vput(tvp);
-			uma_zfree(acl_zone, acl);
+			acl_free(acl);
 			acl = NULL;
 			return (error);
 		}
@@ -2433,10 +2433,10 @@ ufs_makeinode(mode, dvp, vpp, cnp)
 			break;
 
 		default:
-			uma_zfree(acl_zone, acl);
+			acl_free(acl);
 			goto bad;
 		}
-		uma_zfree(acl_zone, acl);
+		acl_free(acl);
 	}
 #endif /* !UFS_ACL */
 	ufs_makedirentry(ip, cnp, &newdir);



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