Whamcloud - gitweb
LU-5223 lmv: build master LMV EA dynamically build via readdir
[fs/lustre-release.git] / lustre / mdt / mdt_handler.c
index 91c2207..f64795f 100644 (file)
@@ -3261,8 +3261,10 @@ static int mdt_intent_layout(enum mdt_it_code opcode,
        if (mdt_object_exists(obj) && !mdt_object_remote(obj)) {
                /* get the length of lsm */
                rc = mdt_attr_get_eabuf_size(info, obj);
-               if (rc < 0)
+               if (rc < 0) {
+                       mdt_object_put(info->mti_env, obj);
                        RETURN(rc);
+               }
 
                if (rc > info->mti_mdt->mdt_max_mdsize)
                        info->mti_mdt->mdt_max_mdsize = rc;
@@ -5329,44 +5331,21 @@ static int mdt_path_current(struct mdt_thread_info *info,
                if (IS_ERR(mdt_obj))
                        GOTO(out, rc = PTR_ERR(mdt_obj));
 
-               if (mdt_object_remote(mdt_obj)) {
+               if (!mdt_object_exists(mdt_obj)) {
                        mdt_object_put(info->mti_env, mdt_obj);
-                       GOTO(remote_out, rc = -EREMOTE);
-               }
-
-               lmv_buf.lb_buf = info->mti_xattr_buf;
-               lmv_buf.lb_len = sizeof(info->mti_xattr_buf);
-
-               /* Check if it is slave stripes */
-               rc = mo_xattr_get(info->mti_env, mdt_object_child(mdt_obj),
-                                 &lmv_buf, XATTR_NAME_LMV);
-               if (rc > 0) {
-                       union lmv_mds_md *lmm = lmv_buf.lb_buf;
-
-                       /* For slave stripes, get its master */
-                       if (le32_to_cpu(lmm->lmv_magic) == LMV_MAGIC_STRIPE) {
-                               struct lmv_mds_md_v1 *lmm1 = &lmm->lmv_md_v1;
-
-                               fid_le_to_cpu(tmpfid, &lmm1->lmv_master_fid);
-                               if (!fid_is_sane(tmpfid)) {
-                                       mdt_object_put(info->mti_env, mdt_obj);
-                                       GOTO(out, rc = -EINVAL);
-                               }
-                               mdt_object_put(info->mti_env, mdt_obj);
-                               pli->pli_fids[pli->pli_fidcount] = *tmpfid;
-                               continue;
-                       }
+                       GOTO(out, rc = -ENOENT);
                }
 
-               if (!mdt_object_exists(mdt_obj)) {
+               if (mdt_object_remote(mdt_obj)) {
                        mdt_object_put(info->mti_env, mdt_obj);
-                       GOTO(out, rc = -ENOENT);
+                       GOTO(remote_out, rc = -EREMOTE);
                }
 
                rc = mdt_links_read(info, mdt_obj, &ldata);
-               mdt_object_put(info->mti_env, mdt_obj);
-               if (rc != 0)
+               if (rc != 0) {
+                       mdt_object_put(info->mti_env, mdt_obj);
                        GOTO(out, rc);
+               }
 
                leh = buf->lb_buf;
                lee = (struct link_ea_entry *)(leh + 1); /* link #0 */
@@ -5387,6 +5366,26 @@ static int mdt_path_current(struct mdt_thread_info *info,
                                pli->pli_linkno++;
                }
 
+               lmv_buf.lb_buf = info->mti_xattr_buf;
+               lmv_buf.lb_len = sizeof(info->mti_xattr_buf);
+               /* Check if it is slave stripes */
+               rc = mo_xattr_get(info->mti_env, mdt_object_child(mdt_obj),
+                                 &lmv_buf, XATTR_NAME_LMV);
+               mdt_object_put(info->mti_env, mdt_obj);
+               if (rc > 0) {
+                       union lmv_mds_md *lmm = lmv_buf.lb_buf;
+
+                       /* For slave stripes, get its master */
+                       if (le32_to_cpu(lmm->lmv_magic) == LMV_MAGIC_STRIPE) {
+                               pli->pli_fids[pli->pli_fidcount] = *tmpfid;
+                               continue;
+                       }
+               } else if (rc < 0 && rc != -ENODATA) {
+                       GOTO(out, rc);
+               }
+
+               rc = 0;
+
                /* Pack the name in the end of the buffer */
                ptr -= tmpname->ln_namelen;
                if (ptr - 1 <= pli->pli_path)