Whamcloud - gitweb
LU-9202 lfsck: skip unavailable targets when sync failures
[fs/lustre-release.git] / lustre / mdd / mdd_permission.c
index 68ebb7a..5f9eceb 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -58,7 +54,7 @@
 int mdd_acl_chmod(const struct lu_env *env, struct mdd_object *o, __u32 mode,
                  struct thandle *handle)
 {
-       struct lu_buf           *buf;
+       struct lu_buf            buf;
        posix_acl_xattr_header  *head;
        posix_acl_xattr_entry   *entry;
        int                      entry_count;
@@ -66,19 +62,19 @@ int mdd_acl_chmod(const struct lu_env *env, struct mdd_object *o, __u32 mode,
 
        ENTRY;
 
-       buf = mdd_buf_get(env, mdd_env_info(env)->mti_xattr_buf,
-                         sizeof(mdd_env_info(env)->mti_xattr_buf));
-
-       rc = mdo_xattr_get(env, o, buf, XATTR_NAME_ACL_ACCESS);
+       lu_buf_check_and_alloc(&mdd_env_info(env)->mti_xattr_buf,
+                       mdd_obj2mdd_dev(o)->mdd_dt_conf.ddp_max_ea_size);
+       buf = mdd_env_info(env)->mti_xattr_buf;
+       rc = mdo_xattr_get(env, o, &buf, XATTR_NAME_ACL_ACCESS);
        if ((rc == -EOPNOTSUPP) || (rc == -ENODATA))
                RETURN(0);
        else if (rc <= 0)
                RETURN(rc);
 
-       buf->lb_len = rc;
-       head = (posix_acl_xattr_header *)(buf->lb_buf);
+       buf.lb_len = rc;
+       head = (posix_acl_xattr_header *)(buf.lb_buf);
        entry = head->a_entries;
-       entry_count = (buf->lb_len - sizeof(head->a_version)) /
+       entry_count = (buf.lb_len - sizeof(head->a_version)) /
                sizeof(posix_acl_xattr_entry);
        if (entry_count <= 0)
                RETURN(0);
@@ -87,7 +83,7 @@ int mdd_acl_chmod(const struct lu_env *env, struct mdd_object *o, __u32 mode,
        if (rc)
                RETURN(rc);
 
-       rc = mdo_xattr_set(env, o, buf, XATTR_NAME_ACL_ACCESS,
+       rc = mdo_xattr_set(env, o, &buf, XATTR_NAME_ACL_ACCESS,
                           0, handle);
        RETURN(rc);
 }
@@ -209,21 +205,22 @@ static int mdd_check_acl(const struct lu_env *env, struct mdd_object *obj,
        struct lu_ucred  *uc  = lu_ucred_assert(env);
        posix_acl_xattr_header *head;
        posix_acl_xattr_entry *entry;
-       struct lu_buf   *buf;
+       struct lu_buf buf;
        int entry_count;
        int rc;
        ENTRY;
 
-       buf = mdd_buf_get(env, mdd_env_info(env)->mti_xattr_buf,
-                         sizeof(mdd_env_info(env)->mti_xattr_buf));
-       rc = mdo_xattr_get(env, obj, buf, XATTR_NAME_ACL_ACCESS);
+       lu_buf_check_and_alloc(&mdd_env_info(env)->mti_xattr_buf,
+                       mdd_obj2mdd_dev(obj)->mdd_dt_conf.ddp_max_ea_size);
+       buf = mdd_env_info(env)->mti_xattr_buf;
+       rc = mdo_xattr_get(env, obj, &buf, XATTR_NAME_ACL_ACCESS);
        if (rc <= 0)
                RETURN(rc ? : -EACCES);
 
-       buf->lb_len = rc;
-       head = (posix_acl_xattr_header *)(buf->lb_buf);
+       buf.lb_len = rc;
+       head = (posix_acl_xattr_header *)(buf.lb_buf);
        entry = head->a_entries;
-       entry_count = posix_acl_xattr_count(buf->lb_len);
+       entry_count = posix_acl_xattr_count(buf.lb_len);
 
        /* Disregard empty ACLs and fall back to
         * standard UNIX permissions. See LU-5434 */