Whamcloud - gitweb
LU-5523 mdt: add --index option to default dir stripe
[fs/lustre-release.git] / lustre / llite / xattr.c
index effdd01..18429ab 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -42,7 +42,6 @@
 #define DEBUG_SUBSYSTEM S_LLITE
 
 #include <obd_support.h>
-#include <lustre_lite.h>
 #include <lustre_dlm.h>
 #include <lustre_ver.h>
 #include <lustre_eacl.h>
@@ -235,8 +234,8 @@ int ll_setxattr(struct dentry *dentry, const char *name,
             (strncmp(name, XATTR_LUSTRE_PREFIX,
                      sizeof(XATTR_LUSTRE_PREFIX) - 1) == 0 &&
              strcmp(name + sizeof(XATTR_LUSTRE_PREFIX) - 1, "lov") == 0)) {
-                struct lov_user_md *lump = (struct lov_user_md *)value;
-                int rc = 0;
+               struct lov_user_md *lump = (struct lov_user_md *)value;
+               int                 rc = 0;
 
                 /* Attributes that are saved via getxattr will always have
                  * the stripe_offset as 0.  Instead, the MDS should be
@@ -247,13 +246,17 @@ int ll_setxattr(struct dentry *dentry, const char *name,
                if (lump != NULL && S_ISREG(inode->i_mode)) {
                        struct file     f;
                        __u64           it_flags = FMODE_WRITE;
-                       int lum_size = (lump->lmm_magic == LOV_USER_MAGIC_V1) ?
-                               sizeof(*lump) : sizeof(struct lov_user_md_v3);
+                       int             lum_size;
 
+                       lum_size = ll_lov_user_md_size(lump);
+                       if (lum_size < 0 || size < lum_size)
+                               return 0; /* b=10667: ignore error */
+
+                       memset(&f, 0, sizeof(f)); /* f.f_flags is used below */
                        f.f_dentry = dentry;
                        rc = ll_lov_setstripe_ea_info(inode, &f, it_flags, lump,
                                                      lum_size);
-                       /* b10667: rc always be 0 here for now */
+                       /* b=10667: rc always be 0 here for now */
                        rc = 0;
                 } else if (S_ISDIR(inode->i_mode)) {
                         rc = ll_dir_setstripe(inode, lump, 0);
@@ -284,7 +287,6 @@ int ll_removexattr(struct dentry *dentry, const char *name)
                                   OBD_MD_FLXATTRRM);
 }
 
-static
 int ll_getxattr_common(struct inode *inode, const char *name,
                        void *buffer, size_t size, __u64 valid)
 {
@@ -398,25 +400,25 @@ getxattr_nocache:
 
                /* only detect the xattr size */
                if (size == 0)
-                       GOTO(out, rc = body->eadatasize);
+                       GOTO(out, rc = body->mbo_eadatasize);
 
-               if (size < body->eadatasize) {
+               if (size < body->mbo_eadatasize) {
                        CERROR("server bug: replied size %u > %u\n",
-                               body->eadatasize, (int)size);
+                               body->mbo_eadatasize, (int)size);
                        GOTO(out, rc = -ERANGE);
                }
 
-               if (body->eadatasize == 0)
+               if (body->mbo_eadatasize == 0)
                        GOTO(out, rc = -ENODATA);
 
                /* do not need swab xattr data */
                xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
-                                                       body->eadatasize);
+                                                       body->mbo_eadatasize);
                if (!xdata)
                        GOTO(out, rc = -EFAULT);
 
-               memcpy(buffer, xdata, body->eadatasize);
-               rc = body->eadatasize;
+               memcpy(buffer, xdata, body->mbo_eadatasize);
+               rc = body->mbo_eadatasize;
        }
 
 #ifdef CONFIG_FS_POSIX_ACL