From 542b76d142c491a0a1bf8a2f4fd22af4733f59cb Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Thu, 13 Apr 2017 17:54:53 +0800 Subject: [PATCH] LU-5163 mdd: migrated entry may not exist During dirent migration, we shouldn't assert file exists. Signed-off-by: Lai Siyao Change-Id: I11bbc5556007ec045b7a5d57a250981082ef6d70 Reviewed-on: https://review.whamcloud.com/26620 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/mdd/mdd_dir.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index a353f8b..7a49239 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -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); } -- 1.8.3.1