X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftarget%2Fupdate_trans.c;h=7a3243b902319cd0f60baa2ea9520c8ba90a413d;hb=af13cfff297d4882de35fb7c11bf5261293b8287;hp=998481e18805c7cca7811b2fc9ecbc3e82af4de5;hpb=42a175ccdd39f164a12c65e9f9cd726bd7a3aaed;p=fs%2Flustre-release.git diff --git a/lustre/target/update_trans.c b/lustre/target/update_trans.c index 998481e..7a3243b 100644 --- a/lustre/target/update_trans.c +++ b/lustre/target/update_trans.c @@ -122,11 +122,12 @@ static int sub_declare_updates_write(const struct lu_env *env, * for example if the the OSP is used to connect to OST */ ctxt = llog_get_context(dt->dd_lu_dev.ld_obd, LLOG_UPDATELOG_ORIG_CTXT); - LASSERT(ctxt != NULL); /* Not ready to record updates yet. */ - if (ctxt->loc_handle == NULL) - GOTO(out_put, rc = 0); + if (ctxt == NULL || ctxt->loc_handle == NULL) { + llog_ctxt_put(ctxt); + return 0; + } rc = llog_declare_add(env, ctxt->loc_handle, &record->lur_hdr, sub_th); @@ -184,12 +185,14 @@ static int sub_updates_write(const struct lu_env *env, ctxt = llog_get_context(dt->dd_lu_dev.ld_obd, LLOG_UPDATELOG_ORIG_CTXT); - LASSERT(ctxt != NULL); - - /* Not ready to record updates yet, usually happens - * in error handler path */ - if (ctxt->loc_handle == NULL) - GOTO(llog_put, rc = 0); + /* If ctxt == NULL, then it means updates on OST (only happens + * during migration), and we do not track those updates for now */ + /* If ctxt->loc_handle == NULL, then it does not need to record + * update, usually happens in error handler path */ + if (ctxt == NULL || ctxt->loc_handle == NULL) { + llog_ctxt_put(ctxt); + RETURN(0); + } /* Since the cross-MDT updates will includes both local * and remote updates, the update ops count must > 1 */ @@ -468,6 +471,7 @@ static void sub_trans_commit_cb(struct lu_env *env, ENTRY; /* Check if all sub thandles are committed */ + spin_lock(&tmt->tmt_sub_lock); list_for_each_entry(st, &tmt->tmt_sub_thandle_list, st_sub_list) { if (st->st_sub_th == sub_th) { st->st_committed = 1; @@ -476,6 +480,7 @@ static void sub_trans_commit_cb(struct lu_env *env, if (!st->st_committed) all_committed = false; } + spin_unlock(&tmt->tmt_sub_lock); if (tmt->tmt_result == 0) tmt->tmt_result = err; @@ -1075,8 +1080,9 @@ int top_trans_create_tmt(const struct lu_env *env, INIT_LIST_HEAD(&tmt->tmt_sub_thandle_list); INIT_LIST_HEAD(&tmt->tmt_commit_list); atomic_set(&tmt->tmt_refcount, 1); - + spin_lock_init(&tmt->tmt_sub_lock); init_waitqueue_head(&tmt->tmt_stop_waitq); + top_th->tt_multiple_thandle = tmt; return 0; @@ -1231,7 +1237,8 @@ static int distribute_txn_cancel_records(const struct lu_env *env, obd = st->st_dt->dd_lu_dev.ld_obd; ctxt = llog_get_context(obd, LLOG_UPDATELOG_ORIG_CTXT); - LASSERT(ctxt); + if (ctxt == NULL) + continue; list_for_each_entry(stc, &st->st_cookie_list, stc_list) { cookie = &stc->stc_cookie; if (fid_is_zero(&cookie->lgc_lgl.lgl_oi.oi_fid)) @@ -1559,23 +1566,10 @@ static int distribute_txn_commit_thread(void *_arg) tdtd->tdtd_committed_batchid); /* update globally committed on a storage */ if (batchid > tdtd->tdtd_committed_batchid) { - distribute_txn_commit_batchid_update(&env, tdtd, + rc = distribute_txn_commit_batchid_update(&env, tdtd, batchid); - spin_lock(&tdtd->tdtd_batchid_lock); - if (batchid > tdtd->tdtd_batchid) { - /* This might happen during recovery, - * batchid is initialized as last transno, - * and the batchid in the update records - * on other MDTs might be bigger than - * the batchid, so we need update it to - * avoid duplicate batchid. */ - CDEBUG(D_HA, "%s update batchid from "LPU64 - " to "LPU64"\n", - tdtd->tdtd_lut->lut_obd->obd_name, - tdtd->tdtd_batchid, batchid); - tdtd->tdtd_batchid = batchid; - } - spin_unlock(&tdtd->tdtd_batchid_lock); + if (rc == 0) + batchid = 0; } /* cancel the records for committed batchid's */ /* XXX: should we postpone cancel's till the end of recovery? */