Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jul 2008 17:32:45 GMT
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 145637 for review
Message-ID:  <200807221732.m6MHWjdP006251@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=145637

Change 145637 by trasz@trasz_traszkan on 2008/07/22 17:32:07

	Get rid of the ae_acl pointers.
	
	Note that this changes on-disk layout.  Before upgrading, do this:
	
	mount -u -o nonfs4acls /filesystem/with/nfs4acls
	find -x /filesystem/with/nfs4acls -print0 | xargs -0 rmextattr -f system nfs4.acl

Affected files ...

.. //depot/projects/soc2008/trasz_nfs4acl/TODO#12 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_branding.c#2 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_delete_entry.c#4 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_entry.c#4 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_get.c#5 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_init.c#3 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support.h#3 edit
.. //depot/projects/soc2008/trasz_nfs4acl/sys/kern/subr_acl_posix1e.c#4 edit
.. //depot/projects/soc2008/trasz_nfs4acl/sys/sys/acl.h#12 edit

Differences ...

==== //depot/projects/soc2008/trasz_nfs4acl/TODO#12 (text+ko) ====

@@ -16,10 +16,6 @@
 
 - Add error checking to acl_to_text_nfs4.c.
 
-- Remove the ae_acl field from "struct acl_entry".  Instead, allocate
-  "struct acl" so that it's page aligned and find the header address
-  by stripping low order bits from the entry adress.
-
 - Either add or extend existing manual pages for new API routines:
   acl_add_flag_np, acl_clear_flags_np, acl_create_entry_np, acl_delete_entry_np,
   acl_delete_flag_np, acl_get_extended_np, acl_get_flag_np, acl_get_flagset_np,

==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_branding.c#2 (text+ko) ====

@@ -42,12 +42,25 @@
  * veryfying acl_set_whatever arguments (checking against setting
  * bits that are valid only for NFS4 in ACL branded as POSIX) etc.
  */
+
+static acl_t
+entry2acl(acl_entry_t entry)
+{
+	acl_t aclp;
+
+	/*
+	 * XXX: This is not a proper way to strip off low order bits.
+	 */
+	aclp = (acl_t)((long)entry - ((long)entry % (long)_ACL_T_ALIGNMENT));
+
+	return (aclp);
+}
+
 static void
 _acl_check_entry(acl_entry_t entry)
 {
 	assert(entry);
-	assert(entry->ae_acl);
-	assert(entry->ae_acl->acl_magic == ACL_MAGIC);
+	assert(entry2acl(entry)->ats_acl.acl_magic == ACL_MAGIC);
 }
 
 int
@@ -82,7 +95,7 @@
 {
 	_acl_check_entry(entry);
 
-	if (entry->ae_acl->acl_brand == ACL_BRAND_NFS4)
+	if (_acl_is_nfs4(entry2acl(entry)))
 		return (1);
 
 	return (0);
@@ -93,7 +106,7 @@
 {
 	_acl_check_entry(entry);
 
-	if (entry->ae_acl->acl_brand == ACL_BRAND_POSIX)
+	if (_acl_is_posix(entry2acl(entry)))
 		return (1);
 
 	return (0);
@@ -104,7 +117,7 @@
 {
 	_acl_check_entry(entry);
 
-	if (entry->ae_acl->acl_brand == ACL_BRAND_UNKNOWN)
+	if (_acl_is_unknown(entry2acl(entry)))
 		return (1);
 
 	return (0);
@@ -154,43 +167,17 @@
 int
 _entry_must_be_posix(acl_entry_t entry)
 {
-	int type;
-
 	_acl_check_entry(entry);
 
-	type = entry->ae_acl->acl_brand;
-
-	if (type == ACL_BRAND_POSIX)
-		return (1);
-
-	if (type == ACL_BRAND_UNKNOWN) {
-		entry->ae_acl->acl_brand = ACL_BRAND_POSIX;
-		return (1);
-	}
-
-	return (0);
-
+	return (_acl_must_be_posix(entry2acl(entry)));
 }
 
 int
 _entry_must_be_nfs4(acl_entry_t entry)
 {
-	int type;
-
 	_acl_check_entry(entry);
 
-	type = entry->ae_acl->acl_brand;
-
-	if (type == ACL_BRAND_NFS4)
-		return (1);
-
-	if (type == ACL_BRAND_UNKNOWN) {
-		entry->ae_acl->acl_brand = ACL_BRAND_NFS4;
-		return (1);
-	}
-
-	return (0);
-
+	return (_acl_must_be_nfs4(entry2acl(entry)));
 }
 
 int
@@ -216,14 +203,3 @@
 	}
 }
 
-void
-_acl_fixup_entry_pointers(acl_t acl)
-{
-	int i;
-
-	acl->ats_acl.acl_magic = ACL_MAGIC;
-
-	for (i = 0; i < ACL_MAX_ENTRIES; i++)
-		acl->ats_acl.acl_entry[i].ae_acl = &(acl->ats_acl);
-}
-

==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_delete_entry.c#4 (text+ko) ====

@@ -105,8 +105,6 @@
 			acl->ats_acl.acl_cnt--;
 			bzero(&acl->ats_acl.acl_entry[i],
 			    sizeof(struct acl_entry));
-			/* XXX: We need this because of the bzero above. */
-			_acl_fixup_entry_pointers(acl);
 			acl->ats_cur_entry = 0;
 			
 			/* Continue with the loop to remove all maching entries. */
@@ -153,8 +151,6 @@
 	acl->ats_acl.acl_cnt--;
 	bzero(&acl->ats_acl.acl_entry[i],
 	    sizeof(struct acl_entry));
-	/* XXX: We need this because of the bzero above. */
-	_acl_fixup_entry_pointers(acl);
 	acl->ats_cur_entry = 0;
 
 	return (0);

==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_entry.c#4 (text+ko) ====

@@ -62,7 +62,6 @@
 	(**entry_p).ae_tag  = ACL_UNDEFINED_TAG;
 	(**entry_p).ae_id   = ACL_UNDEFINED_ID;
 	(**entry_p).ae_perm = ACL_PERM_NONE;
-	(**entry_p).ae_acl  = acl_int;
 	(**entry_p).ae_flags= 0;
 
 	(*acl_p)->ats_cur_entry = 0;
@@ -104,7 +103,6 @@
 	(**entry_p).ae_tag  = ACL_UNDEFINED_TAG;
 	(**entry_p).ae_id   = ACL_UNDEFINED_ID;
 	(**entry_p).ae_perm = ACL_PERM_NONE;
-	(**entry_p).ae_acl  = acl_int;
 	(**entry_p).ae_flags= 0;
 
 	(*acl_p)->ats_cur_entry = 0;
@@ -135,7 +133,6 @@
 		if (acl->ats_cur_entry >= acl->ats_acl.acl_cnt)
 			return 0;
 		*entry_p = &acl_int->acl_entry[acl->ats_cur_entry++];
-		(*entry_p)->ae_acl = acl_int;
 		return (1);
 	}
 

==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_get.c#5 (text+ko) ====

@@ -71,7 +71,6 @@
 		return (NULL);
 	}
 
-	_acl_fixup_entry_pointers(aclp);
 	_acl_brand_from_type(aclp, type);
 
 	return (aclp);
@@ -95,7 +94,6 @@
 		return (NULL);
 	}
 
-	_acl_fixup_entry_pointers(aclp);
 	_acl_brand_from_type(aclp, type);
 
 	return (aclp);
@@ -128,7 +126,6 @@
 		return (NULL);
 	}
 
-	_acl_fixup_entry_pointers(aclp);
 	_acl_brand_from_type(aclp, type);
 
 	return (aclp);

==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_init.c#3 (text+ko) ====

@@ -38,12 +38,14 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 
 #include "acl_support.h"
 
 acl_t
 acl_init(int count)
 {
+	int error;
 	acl_t acl;
 
 	if (count > ACL_MAX_ENTRIES) {
@@ -55,15 +57,16 @@
 		return (NULL);
 	}
 
-	acl = malloc(sizeof(struct acl_t_struct));
-	if (acl != NULL)
-		bzero(acl, sizeof(struct acl_t_struct));
+	assert(_ACL_T_ALIGNMENT > sizeof(struct acl_t_struct));
+	error = posix_memalign((void *)&acl, _ACL_T_ALIGNMENT, sizeof(struct acl_t_struct));
+	if (error)
+		return (NULL);
+
+	bzero(acl, sizeof(struct acl_t_struct));
 
 	acl->ats_acl.acl_brand = ACL_BRAND_UNKNOWN;
 	acl->ats_acl.acl_magic = ACL_MAGIC;
 
-	_acl_fixup_entry_pointers(acl);
-
 	return (acl);
 }
 
@@ -79,7 +82,5 @@
 		acl_new->ats_cur_entry = 0;
 	}
 
-	_acl_fixup_entry_pointers(acl_new);
-
 	return (acl_new);
 }

==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support.h#3 (text+ko) ====

@@ -33,6 +33,7 @@
 #define _ACL_SUPPORT_H
 
 #define _POSIX1E_ACL_STRING_PERM_MAXSIZE 3       /* read, write, exec */
+#define _ACL_T_ALIGNMENT		(1 << 12)
 
 int	_acl_type_unold(acl_type_t type);
 int	_acl_differs(const acl_t a, const acl_t b);
@@ -48,7 +49,6 @@
 int	_entry_must_be_nfs4(acl_entry_t entry);
 int	_acl_type_not_valid_for_acl(const acl_t acl, acl_type_t type);
 void	_acl_brand_from_type(acl_t acl, acl_type_t type);
-void	_acl_fixup_entry_pointers(acl_t acl);
 int	_posix1e_acl_check(acl_t acl);
 int	_posix1e_acl_sort(acl_t acl);
 int	_posix1e_acl(acl_t acl, acl_type_t type);

==== //depot/projects/soc2008/trasz_nfs4acl/sys/kern/subr_acl_posix1e.c#4 (text+ko) ====

@@ -430,7 +430,6 @@
 		printf("acl_posix1e_mode_to_entry: invalid tag (%d)\n", tag);
 	}
 
-	acl_entry.ae_acl = NULL;
 	acl_entry.ae_extended = ACL_EXTENDED_ALLOW;
 	acl_entry.ae_flags = 0;
 

==== //depot/projects/soc2008/trasz_nfs4acl/sys/sys/acl.h#12 (text+ko) ====

@@ -90,7 +90,6 @@
 	acl_extended_t	ae_extended;
 	/* Flags control inheritance.  Unused in POSIX ACLs. */
 	acl_flag_t	ae_flags;
-	struct acl	*ae_acl; /* XXX: This is ugly. */
 };
 typedef struct acl_entry	*acl_entry_t;
 



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