Whamcloud - gitweb
LU-6158 mdt: always shrink_capsule in getxattr_all
[fs/lustre-release.git] / lustre / mdt / mdt_xattr.c
index 7d7e15d..a7c69cf 100644 (file)
@@ -182,10 +182,11 @@ static int mdt_getxattr_all(struct mdt_thread_info *info,
        eadatahead = buf->lb_buf;
 
        /* Fill out EADATA first */
        eadatahead = buf->lb_buf;
 
        /* Fill out EADATA first */
-       eadatasize = mo_xattr_list(env, next, buf);
-       if (eadatasize < 0)
-               GOTO(out, rc = eadatasize);
+       rc = mo_xattr_list(env, next, buf);
+       if (rc < 0)
+               GOTO(out_shrink, rc);
 
 
+       eadatasize = rc;
        eadatatail = eadatahead + eadatasize;
 
        v = req_capsule_server_get(info->mti_pill, &RMF_EAVALS);
        eadatatail = eadatahead + eadatasize;
 
        v = req_capsule_server_get(info->mti_pill, &RMF_EAVALS);
@@ -197,13 +198,19 @@ static int mdt_getxattr_all(struct mdt_thread_info *info,
                buf->lb_len = reqbody->mbo_eadatasize - eavallen;
                rc = mdt_getxattr_one(info, b, next, buf, med, uc);
                if (rc < 0)
                buf->lb_len = reqbody->mbo_eadatasize - eavallen;
                rc = mdt_getxattr_one(info, b, next, buf, med, uc);
                if (rc < 0)
-                       GOTO(out, rc);
+                       GOTO(out_shrink, rc);
 
                sizes[eavallens] = rc;
                eavallens++;
                eavallen += rc;
        }
 
 
                sizes[eavallens] = rc;
                eavallens++;
                eavallen += rc;
        }
 
+out_shrink:
+       if (rc < 0) {
+               eadatasize = 0;
+               eavallens = 0;
+               eavallen = 0;
+       }
        repbody->mbo_aclsize = eavallen;
        repbody->mbo_max_mdsize = eavallens;
 
        repbody->mbo_aclsize = eavallen;
        repbody->mbo_max_mdsize = eavallens;
 
@@ -212,8 +219,8 @@ static int mdt_getxattr_all(struct mdt_thread_info *info,
                           eavallens * sizeof(__u32), RCL_SERVER);
        req_capsule_shrink(info->mti_pill, &RMF_EADATA, eadatasize, RCL_SERVER);
 
                           eavallens * sizeof(__u32), RCL_SERVER);
        req_capsule_shrink(info->mti_pill, &RMF_EADATA, eadatasize, RCL_SERVER);
 
-       GOTO(out, rc = eadatasize);
-out:
+       if (rc >= 0)
+               RETURN(eadatasize);
        return rc;
 }
 
        return rc;
 }