Whamcloud - gitweb
LU-5163 mdd: migrated entry may not exist
[fs/lustre-release.git] / lustre / mdd / mdd_dir.c
index a353f8b..7a49239 100644 (file)
@@ -3887,8 +3887,11 @@ static int mdd_migrate_entries(const struct lu_env *env,
                if (IS_ERR(child))
                        GOTO(out, rc = PTR_ERR(child));
 
+               /* child may not exist, but lu_object_attr will assert this,
+                * get type from loh_attr directly */
+               is_dir = S_ISDIR(child->mod_obj.mo_lu.lo_header->loh_attr);
+
                mdd_write_lock(env, child, MOR_SRC_CHILD);
-               is_dir = S_ISDIR(mdd_object_type(child));
 
                snprintf(name, ent->lde_namelen + 1, "%s", ent->lde_name);
 
@@ -3912,9 +3915,9 @@ static int mdd_migrate_entries(const struct lu_env *env,
                handle->th_local = 1;
                if (likely(!target_exist)) {
                        rc = mdo_declare_index_insert(env, mdd_tobj,
-                                                     &ent->lde_fid,
-                                                     mdd_object_type(child),
-                                                     name, handle);
+                               &ent->lde_fid,
+                               child->mod_obj.mo_lu.lo_header->loh_attr,
+                               name, handle);
                        if (rc != 0)
                                GOTO(out_put, rc);
 
@@ -3963,8 +3966,8 @@ static int mdd_migrate_entries(const struct lu_env *env,
 
                if (likely(!target_exist)) {
                        rc = __mdd_index_insert(env, mdd_tobj, &ent->lde_fid,
-                                               mdd_object_type(child),
-                                               name, handle);
+                               child->mod_obj.mo_lu.lo_header->loh_attr, name,
+                               handle);
                        if (rc != 0)
                                GOTO(out_put, rc);
                }