From: tappro Date: Wed, 22 Nov 2006 13:17:03 +0000 (+0000) Subject: - fix objid update call. It should be done before transaction stop. Separate it X-Git-Tag: v1_8_0_110~486^2~97 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=97993e647d97be5cdd10363efa1042b790f47a82;p=fs%2Flustre-release.git - fix objid update call. It should be done before transaction stop. Separate it from freeing lov_create data. - encapsulate checking no_lov_create flag inside mdd_lov_create --- diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index d16d29e..8be0b93 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -904,24 +904,28 @@ static int mdd_create_data(const struct lu_env *env, struct md_object *pobj, */ /* Replay creates has objects already */ +#if 0 if (spec->u.sp_ea.no_lov_create) { CDEBUG(D_INFO, "we already have lov ea\n"); rc = mdd_lov_set_md(env, mdd_pobj, son, (struct lov_mds_md *)spec->u.sp_ea.eadata, spec->u.sp_ea.eadatalen, handle, 0); } else +#endif rc = mdd_lov_set_md(env, mdd_pobj, son, lmm, lmm_size, handle, 0); if (rc == 0) rc = mdd_attr_get_internal_locked(env, son, ma); + /* update lov_objid data, must be before transaction stop! */ + if (rc == 0) + mdd_lov_objid_update(env, mdd); + mdd_trans_stop(env, mdd, rc, handle); out_free: /* Finish mdd_lov_create() stuff. */ - mdd_lov_create_finish(env, mdd, rc); - if (lmm) - OBD_FREE(lmm, lmm_size); + mdd_lov_create_finish(env, mdd, lmm, lmm_size, spec); RETURN(rc); } @@ -1224,12 +1228,14 @@ static int mdd_create(const struct lu_env *env, inserted = 1; /* Replay creates has objects already. */ +#if 0 if (spec->u.sp_ea.no_lov_create) { CDEBUG(D_INFO, "we already have lov ea\n"); LASSERT(lmm == NULL); lmm = (struct lov_mds_md *)spec->u.sp_ea.eadata; lmm_size = spec->u.sp_ea.eadatalen; } +#endif rc = mdd_lov_set_md(env, mdd_pobj, son, lmm, lmm_size, handle, 0); if (rc) { CERROR("error on stripe info copy %d \n", rc); @@ -1287,14 +1293,16 @@ cleanup: } } + /* update lov_objid data, must be before transaction stop! */ + if (rc == 0) + mdd_lov_objid_update(env, mdd); + mdd_pdo_write_unlock(env, mdd_pobj, dlh); out_trans: mdd_trans_stop(env, mdd, rc, handle); out_free: - if (lmm && !spec->u.sp_ea.no_lov_create) - OBD_FREE(lmm, lmm_size); - /* Finish mdd_lov_create() stuff */ - mdd_lov_create_finish(env, mdd, rc); + /* finis lov_create stuff, free all temporary data */ + mdd_lov_create_finish(env, mdd, lmm, lmm_size, spec); mdd_lprocfs_time_end(mdd, &start, LPROC_MDD_CREATE); return rc; } diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index cfcaf24..71db429 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -127,8 +127,10 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, struct mdd_object *parent, struct mdd_object *child, struct lov_mds_md **lmm, int *lmm_size, const struct md_op_spec *spec, struct lu_attr *la); -void mdd_lov_create_finish(const struct lu_env *env, - struct mdd_device *mdd, int rc); +void mdd_lov_objid_update(const struct lu_env *env, struct mdd_device *mdd); +void mdd_lov_create_finish(const struct lu_env *env, struct mdd_device *mdd, + struct lov_mds_md *lmm, int lmm_size, + const struct md_op_spec *spec); int mdd_get_md(const struct lu_env *env, struct mdd_object *obj, void *md, int *md_size, const char *name); int mdd_get_md_locked(const struct lu_env *env, struct mdd_object *obj, diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index d67f4bd..ff1a1e0 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -348,11 +348,12 @@ static int mdd_lov_objid_alloc(const struct lu_env *env, return (info->mti_oti.oti_objid == NULL ? -ENOMEM : 0); } -static void mdd_lov_objid_update(const struct lu_env *env, - struct mdd_device *mdd) +void mdd_lov_objid_update(const struct lu_env *env, struct mdd_device *mdd) { struct mdd_thread_info *info = mdd_env_info(env); - mds_lov_update_objids(mdd->mdd_obd_dev, info->mti_oti.oti_objid); + if (info->mti_oti.oti_objid != NULL) + mds_lov_update_objids(mdd->mdd_obd_dev, + info->mti_oti.oti_objid); } static void mdd_lov_objid_from_lmm(const struct lu_env *env, @@ -375,16 +376,17 @@ static void mdd_lov_objid_free(const struct lu_env *env, info->mti_oti.oti_objid = NULL; } -void mdd_lov_create_finish(const struct lu_env *env, - struct mdd_device *mdd, int rc) +void mdd_lov_create_finish(const struct lu_env *env, struct mdd_device *mdd, + struct lov_mds_md *lmm, int lmm_size, + const struct md_op_spec *spec) { struct mdd_thread_info *info = mdd_env_info(env); - if (info->mti_oti.oti_objid != NULL) { - if (rc == 0) - mdd_lov_objid_update(env, mdd); + if (lmm && !spec->u.sp_ea.no_lov_create) + OBD_FREE(lmm, lmm_size); + + if (info->mti_oti.oti_objid != NULL) mdd_lov_objid_free(env, mdd); - } } int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, @@ -417,7 +419,9 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, /* replay case, should get lov from eadata */ if (spec->u.sp_ea.no_lov_create != 0) { - mdd_lov_objid_from_lmm(env, mdd, (struct lov_mds_md *)eadata); + *lmm = (struct lov_mds_md *)spec->u.sp_ea.eadata; + *lmm_size = spec->u.sp_ea.eadatalen; + mdd_lov_objid_from_lmm(env, mdd, *lmm); RETURN(0); }