Whamcloud - gitweb
b22078 wrong value is used by parse_net
[fs/lustre-release.git] / lustre / mdt / mdt_xattr.c
index 561a395..5fd6ffc 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
 #endif
 #define DEBUG_SUBSYSTEM S_MDS
 
-/* prerequisite for linux/xattr.h */
-#include <linux/types.h>
-/* prerequisite for linux/xattr.h */
-#include <linux/fs.h>
-/* XATTR_{REPLACE,CREATE} */
-#include <linux/xattr.h>
-
+#include <lustre_acl.h>
 #include "mdt_internal.h"
 
 
@@ -68,7 +62,7 @@ static int mdt_getxattr_pack_reply(struct mdt_thread_info * info)
         static const char       user_string[] = "user.";
         int                     size, rc;
         ENTRY;
-        
+
         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETXATTR_PACK))
                 RETURN(-ENOMEM);
 
@@ -81,7 +75,7 @@ static int mdt_getxattr_pack_reply(struct mdt_thread_info * info)
                 if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_XATTR) &&
                     !strncmp(xattr_name, user_string, sizeof(user_string) - 1))
                         RETURN(-EOPNOTSUPP);
-                
+
                 size = mo_xattr_get(info->mti_env,
                                     mdt_object_child(info->mti_object),
                                     &LU_BUF_NULL, xattr_name);
@@ -330,18 +324,22 @@ int mdt_reint_setxattr(struct mdt_thread_info *info,
 
         if (strncmp(xattr_name, XATTR_USER_PREFIX,
                     sizeof(XATTR_USER_PREFIX) - 1) == 0) {
+                if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_XATTR))
+                        GOTO(out, rc = -EOPNOTSUPP);
                 if (strcmp(xattr_name, XATTR_NAME_LOV) == 0)
                         GOTO(out, rc = -EACCES);
                 if (strcmp(xattr_name, XATTR_NAME_LMA) == 0)
                         GOTO(out, rc = 0);
                 if (strcmp(xattr_name, XATTR_NAME_LINK) == 0)
                         GOTO(out, rc = 0);
-        }
+        } else if ((valid & OBD_MD_FLXATTR) &&
+                   (strncmp(xattr_name, XATTR_NAME_ACL_ACCESS,
+                             sizeof(XATTR_NAME_ACL_ACCESS) - 1) == 0)) {
+                /* currently lustre limit acl access size */
+                xattr_len = req_capsule_get_size(pill, &RMF_EADATA, RCL_CLIENT);
 
-        if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_XATTR) &&
-            (strncmp(xattr_name, XATTR_USER_PREFIX,
-                     sizeof(XATTR_USER_PREFIX) - 1) == 0)) {
-                GOTO(out, rc = -EOPNOTSUPP);
+                if (xattr_len > LUSTRE_POSIX_ACL_MAX_SIZE)
+                        GOTO(out, -ERANGE);
         }
 
         lockpart = MDS_INODELOCK_UPDATE;
@@ -354,9 +352,14 @@ int mdt_reint_setxattr(struct mdt_thread_info *info,
         if (IS_ERR(obj))
                 GOTO(out, rc =  PTR_ERR(obj));
 
+        info->mti_mos = obj;
+        rc = mdt_version_get_check_save(info, obj, 0);
+        if (rc)
+                GOTO(out_unlock, rc);
+
         if (unlikely(!(valid & OBD_MD_FLCTIME))) {
                 CWARN("client miss to set OBD_MD_FLCTIME when "
-                      "setxattr: [object "DFID"] [valid %llu]\n",
+                      "setxattr: [object "DFID"] [valid "LPU64"]\n",
                       PFID(rr->rr_fid1), valid);
                 attr->la_ctime = cfs_time_current_sec();
         }