From 0b83275f42d6253fabe46e3b1e8b8a4dee87012c Mon Sep 17 00:00:00 2001 From: fanyong Date: Fri, 29 Sep 2006 09:14:13 +0000 Subject: [PATCH] replace alloc memory dynamicly with static buffer for acl check. --- lustre/include/linux/lustre_acl.h | 6 ++++-- lustre/mdd/mdd_handler.c | 19 ++++++------------- lustre/mdd/mdd_internal.h | 2 ++ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lustre/include/linux/lustre_acl.h b/lustre/include/linux/lustre_acl.h index eb06205..e028891 100644 --- a/lustre/include/linux/lustre_acl.h +++ b/lustre/include/linux/lustre_acl.h @@ -28,8 +28,10 @@ # 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 diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 5a5a662..003eb75 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -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; diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 4b8b832..11742e4 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -29,6 +29,7 @@ #include +#include #include #include #include @@ -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, -- 1.8.3.1