Whamcloud - gitweb
replace alloc memory dynamicly with static buffer for acl check.
authorfanyong <fanyong>
Fri, 29 Sep 2006 09:14:13 +0000 (09:14 +0000)
committerfanyong <fanyong>
Fri, 29 Sep 2006 09:14:13 +0000 (09:14 +0000)
lustre/include/linux/lustre_acl.h
lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h

index eb06205..e028891 100644 (file)
 #  define mds_xattr_acl_size(entry) posix_acl_xattr_size(entry)
 # endif
 # define LUSTRE_POSIX_ACL_MAX_ENTRIES   (32)
-# define LUSTRE_POSIX_ACL_MAX_SIZE      \
-                (mds_xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES))
+# define LUSTRE_POSIX_ACL_MAX_SIZE              \
+                (sizeof(xattr_acl_header) +     \
+                LUSTRE_POSIX_ACL_MAX_ENTRIES *  \
+                sizeof(xattr_acl_entry))
 #else
 # define LUSTRE_POSIX_ACL_MAX_SIZE      0
 #endif
index 5a5a662..003eb75 100644 (file)
@@ -3020,25 +3020,18 @@ static int mdd_check_acl(const struct lu_env *env, struct mdd_object *obj,
         ENTRY;
 
         next = mdd_object_child(obj);
-        buf->lb_len = next->do_ops->do_xattr_get(env, next, &LU_BUF_NULL, "");
-        if (buf->lb_len <= 0)
-                RETURN(buf->lb_len ? : -EACCES);
 
-        OBD_ALLOC(buf->lb_buf, buf->lb_len);
-        if (buf->lb_buf == NULL)
-                RETURN(-ENOMEM);
-
-        rc = next->do_ops->do_xattr_get(env, next, buf, "");
+        buf->lb_buf = mdd_env_info(env)->mti_xattr_buf;
+        buf->lb_len = sizeof(mdd_env_info(env)->mti_xattr_buf);
+        rc = next->do_ops->do_xattr_get(env, next, buf,
+                                        XATTR_NAME_ACL_ACCESS);
         if (rc <= 0)
-                GOTO(out, rc = rc ? : -EACCES);
+                RETURN(rc ? : -EACCES);
 
-        entry = ((posix_acl_xattr_header *)buf)->a_entries;
+        entry = ((posix_acl_xattr_header *)(buf->lb_buf))->a_entries;
         entry_count = (rc - 4) / sizeof(posix_acl_xattr_entry);
 
         rc = mdd_posix_acl_permission(uc, la, mask, entry, entry_count);
-
-out:
-        OBD_FREE(buf->lb_buf, buf->lb_len);
         RETURN(rc);
 #else
         ENTRY;
index 4b8b832..11742e4 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <asm/semaphore.h>
 
+#include <linux/lustre_acl.h>
 #include <md_object.h>
 #include <dt_object.h>
 #include <linux/sched.h>
@@ -82,6 +83,7 @@ struct mdd_thread_info {
         struct orph_key       mti_orph_key;
         struct obd_trans_info mti_oti;
         struct lu_buf         mti_buf;
+        char                  mti_xattr_buf[LUSTRE_POSIX_ACL_MAX_SIZE];
 };
 
 int mdd_init_obd(const struct lu_env *env, struct mdd_device *mdd,