Whamcloud - gitweb
b=22187 Handle the NULL pointer as legal value.
[fs/lustre-release.git] / lustre / llite / xattr.c
index 0957d09..eecff63 100644 (file)
@@ -219,7 +219,13 @@ int ll_setxattr(struct dentry *dentry, const char *name,
                 struct lov_user_md *lump = (struct lov_user_md *)value;
                 int rc = 0;
 
-                if (S_ISREG(inode->i_mode)) {
+                /* Attributes that are saved via getxattr will always have
+                 * the stripe_offset as 0.  Instead, the MDS should be
+                 * allowed to pick the starting OST index.   b=17846 */
+                if (lump != NULL && lump->lmm_stripe_offset == 0)
+                        lump->lmm_stripe_offset = -1;
+
+                if (lump != NULL && S_ISREG(inode->i_mode)) {
                         struct file f;
                         int flags = FMODE_WRITE;
 
@@ -299,21 +305,19 @@ int ll_getxattr_common(struct inode *inode, const char *name,
                     rce->rce_ops != RMT_RGETFACL))
                         RETURN(-EOPNOTSUPP);
         }
-#endif
 
         /* posix acl is under protection of LOOKUP lock. when calling to this,
          * we just have path resolution to the target inode, so we have great
          * chance that cached ACL is uptodate.
          */
-#ifdef CONFIG_FS_POSIX_ACL
         if (xattr_type == XATTR_ACL_ACCESS_T &&
             !(sbi->ll_flags & LL_SBI_RMT_CLIENT)) {
                 struct ll_inode_info *lli = ll_i2info(inode);
                 struct posix_acl *acl;
 
-                spin_lock(&lli->lli_lock);
+                cfs_spin_lock(&lli->lli_lock);
                 acl = posix_acl_dup(lli->lli_posix_acl);
-                spin_unlock(&lli->lli_lock);
+                cfs_spin_unlock(&lli->lli_lock);
 
                 if (!acl)
                         RETURN(-ENODATA);
@@ -354,6 +358,9 @@ do_getxattr:
                 GOTO(out, rc = -ERANGE);
         }
 
+        if (body->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);
@@ -376,13 +383,15 @@ do_getxattr:
                         GOTO(out, rc);
                 }
         }
-
-        if (xattr_type == XATTR_ACL_ACCESS_T && !body->eadatasize)
-                GOTO(out, rc = -ENODATA);
 #endif
-        LASSERT(buffer);
-        memcpy(buffer, xdata, body->eadatasize);
-        rc = body->eadatasize;
+
+        if (body->eadatasize == 0) {
+                rc = -ENODATA;
+        } else {
+                LASSERT(buffer);
+                memcpy(buffer, xdata, body->eadatasize);
+                rc = body->eadatasize;
+        }
         EXIT;
 out:
         ptlrpc_req_finished(req);