From: wang di Date: Thu, 23 Jul 2015 11:24:30 +0000 (-0700) Subject: LU-6896 llog: update log initialization needs to be sync X-Git-Tag: 2.7.58~23 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=42a175ccdd39f164a12c65e9f9cd726bd7a3aaed LU-6896 llog: update log initialization needs to be sync During initialization, update llog catlist and cat file creation needs to be synchronized, because the following update records will be written to these files, if these files are missing during update recovery, then update recovery will fail. Because update llog is initialized in a separate thread, it should set loc_handle until the catlog is written to catlist to make sure the udpate llog is fully initialized because MDT can handle cross MDT operation. see lod_obd_get_info() to check the healthy of the target. Signed-off-by: wang di Change-Id: Iccd09749bedde46c01ff89b5be4fa6f4327ec9b9 Reviewed-on: http://review.whamcloud.com/15721 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/lod/lod_sub_object.c b/lustre/lod/lod_sub_object.c index 6c46520..cb4f8fd 100644 --- a/lustre/lod/lod_sub_object.c +++ b/lustre/lod/lod_sub_object.c @@ -983,7 +983,6 @@ int lod_sub_prep_llog(const struct lu_env *env, struct lod_device *lod, } LASSERT(lgh != NULL); - ctxt->loc_handle = lgh; rc = llog_cat_init_and_process(env, lgh); if (rc != 0) @@ -995,15 +994,14 @@ int lod_sub_prep_llog(const struct lu_env *env, struct lod_device *lod, GOTO(out_close, rc); } + ctxt->loc_handle = lgh; + CDEBUG(D_INFO, "%s: Init llog for %d - catid "DOSTID":%x\n", obd->obd_name, index, POSTID(&cid->lci_logid.lgl_oi), cid->lci_logid.lgl_ogen); out_close: - if (rc != 0) { - llog_cat_close(env, ctxt->loc_handle); - ctxt->loc_handle = NULL; - } - + if (rc != 0) + llog_cat_close(env, lgh); out_put: llog_ctxt_put(ctxt); RETURN(rc); diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 489e851..334f752 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -870,11 +870,12 @@ int llog_open_create(const struct lu_env *env, struct llog_ctxt *ctxt, if (IS_ERR(th)) GOTO(out, rc = PTR_ERR(th)); - /* Create the remote update llog object synchronously, which - * happens during inialization process see lod_sub_prep_llog(), - * to make sure the update llog object is created before - * corss-MDT writing updates into the llog object */ - if (dt_object_remote((*res)->lgh_obj)) + /* Create update llog object synchronously, which + * happens during inialization process see + * lod_sub_prep_llog(), to make sure the update + * llog object is created before corss-MDT writing + * updates into the llog object */ + if (ctxt->loc_flags & LLOG_CTXT_FLAG_NORMAL_FID) th->th_sync = 1; th->th_wait_submit = 1; diff --git a/lustre/obdclass/llog_osd.c b/lustre/obdclass/llog_osd.c index b823185..b820139 100644 --- a/lustre/obdclass/llog_osd.c +++ b/lustre/obdclass/llog_osd.c @@ -1900,6 +1900,15 @@ int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d, if (rc) GOTO(out, rc); + /* For update log, this happens during initialization, + * see lod_sub_prep_llog(), and we need make sure catlog + * file ID is written to catlist file(committed) before + * cross-MDT operation write update records to catlog FILE, + * otherwise, during failover these update records might + * missing */ + if (fid_is_update_log(fid)) + th->th_sync = 1; + rc = dt_trans_start_local(env, d, th); if (rc) GOTO(out_trans, rc); diff --git a/lustre/osp/osp_trans.c b/lustre/osp/osp_trans.c index bcedee5..df648fc 100644 --- a/lustre/osp/osp_trans.c +++ b/lustre/osp/osp_trans.c @@ -730,9 +730,6 @@ int osp_trans_update_request_create(struct thandle *th) oth->ot_our = our; our->our_th = oth; - if (oth->ot_super.th_sync) - oth->ot_our->our_flags |= UPDATE_FL_SYNC; - return 0; } @@ -1273,6 +1270,8 @@ int osp_trans_start(const struct lu_env *env, struct dt_device *dt, { struct osp_thandle *oth = thandle_to_osp_thandle(th); + if (oth->ot_super.th_sync) + oth->ot_our->our_flags |= UPDATE_FL_SYNC; /* For remote thandle, if there are local thandle, start it here*/ if (is_only_remote_trans(th) && oth->ot_storage_th != NULL) return dt_trans_start(env, oth->ot_storage_th->th_dev, diff --git a/lustre/target/update_trans.c b/lustre/target/update_trans.c index 001f21d..998481e 100644 --- a/lustre/target/update_trans.c +++ b/lustre/target/update_trans.c @@ -781,7 +781,8 @@ int top_trans_start(const struct lu_env *env, struct dt_device *master_dev, list_for_each_entry(st, &tmt->tmt_sub_thandle_list, st_sub_list) { if (st->st_sub_th == NULL) continue; - st->st_sub_th->th_sync = th->th_sync; + if (th->th_sync) + st->st_sub_th->th_sync = th->th_sync; st->st_sub_th->th_local = th->th_local; st->st_sub_th->th_tags = th->th_tags; rc = dt_trans_start(env, st->st_sub_th->th_dev, @@ -970,7 +971,8 @@ stop_master_trans: * master transno in the update logs to other MDT. */ if (master_st != NULL && master_st->st_sub_th != NULL) { master_st->st_sub_th->th_local = th->th_local; - master_st->st_sub_th->th_sync = th->th_sync; + if (th->th_sync) + master_st->st_sub_th->th_sync = th->th_sync; master_st->st_sub_th->th_tags = th->th_tags; master_st->st_sub_th->th_result = th->th_result; rc = dt_trans_stop(env, master_st->st_dt, master_st->st_sub_th); @@ -1024,7 +1026,8 @@ stop_other_trans: if (st == master_st || st->st_sub_th == NULL) continue; - st->st_sub_th->th_sync = th->th_sync; + if (th->th_sync) + st->st_sub_th->th_sync = th->th_sync; st->st_sub_th->th_local = th->th_local; st->st_sub_th->th_tags = th->th_tags; st->st_sub_th->th_result = th->th_result;