}
/**
- * Create sub thandle
- *
- * Create transaction handle for sub_thandle
- *
- * \param[in] env execution environment
- * \param[in] th top thandle
- * \param[in] st sub_thandle
- *
- * \retval 0 if creation succeeds.
- * \retval negative errno if creation fails.
- */
-int sub_thandle_trans_create(const struct lu_env *env,
- struct top_thandle *top_th,
- struct sub_thandle *st)
-{
- struct thandle *sub_th;
-
- sub_th = dt_trans_create(env, st->st_dt);
- if (IS_ERR(sub_th))
- return PTR_ERR(sub_th);
-
- sub_th->th_top = &top_th->tt_super;
- st->st_sub_th = sub_th;
- return 0;
-}
-
-/**
* sub thandle commit callback
*
* Mark the sub thandle to be committed and if all sub thandle are committed
*
* \param[in] sub_th sub thandle being committed.
*/
-static void sub_trans_commit_cb(struct lu_env *env, struct thandle *sub_th,
+static void sub_trans_commit_cb(struct lu_env *env,
+ struct thandle *sub_th,
struct dt_txn_commit_cb *cb, int err)
{
struct sub_thandle *st;
}
/**
+ * Create sub thandle
+ *
+ * Create transaction handle for sub_thandle
+ *
+ * \param[in] env execution environment
+ * \param[in] th top thandle
+ * \param[in] st sub_thandle
+ *
+ * \retval 0 if creation succeeds.
+ * \retval negative errno if creation fails.
+ */
+int sub_thandle_trans_create(const struct lu_env *env,
+ struct top_thandle *top_th,
+ struct sub_thandle *st)
+{
+ struct thandle *sub_th;
+
+ sub_th = dt_trans_create(env, st->st_dt);
+ if (IS_ERR(sub_th))
+ return PTR_ERR(sub_th);
+
+ sub_th->th_top = &top_th->tt_super;
+ st->st_sub_th = sub_th;
+
+ sub_th->th_wait_submit = 1;
+ return 0;
+}
+
+
+/**
* Create the top transaction.
*
* Create the top transaction on the master device. It will create a top
* Assign batchid to the distribute transaction
*
* \param[in] tmt distribute transaction
- *
*/
static void distribute_txn_assign_batchid(struct top_multiple_thandle *new)
{
int rc;
ENTRY;
- /* Prepare the update buffer for recording updates */
- if (tmt->tmt_update_records != NULL)
- RETURN(0);
-
- tur = &update_env_info(env)->uti_tur;
- rc = check_and_prepare_update_record(env, tur);
- if (rc < 0)
- RETURN(rc);
+ if (tmt->tmt_update_records == NULL) {
+ tur = &update_env_info(env)->uti_tur;
+ rc = check_and_prepare_update_record(env, tur);
+ if (rc < 0)
+ RETURN(rc);
- tmt->tmt_update_records = tur;
+ tmt->tmt_update_records = tur;
+ distribute_txn_assign_batchid(tmt);
+ }
- distribute_txn_assign_batchid(tmt);
rc = declare_updates_write(env, tmt);
RETURN(rc);
int rc = 0;
ENTRY;
- /* Walk through all of sub transaction to see if it needs to
- * record updates for this transaction */
if (tmt == NULL) {
rc = dt_trans_start(env, top_th->tt_master_sub_thandle->th_dev,
top_th->tt_master_sub_thandle);
RETURN(rc);
}
+ tmt = top_th->tt_multiple_thandle;
rc = prepare_multiple_node_trans(env, tmt);
if (rc < 0)
RETURN(rc);
rc = dt_trans_start(env, st->st_sub_th->th_dev,
st->st_sub_th);
if (rc != 0)
- RETURN(rc);
+ GOTO(out, rc);
sub_thandle_register_commit_cb(st, tmt);
}
-
+out:
+ th->th_result = rc;
RETURN(rc);
}
EXPORT_SYMBOL(top_trans_start);
ENTRY;
if (likely(top_th->tt_multiple_thandle == NULL)) {
+ LASSERT(master_dev != NULL);
rc = dt_trans_stop(env, master_dev,
top_th->tt_master_sub_thandle);
OBD_FREE_PTR(top_th);
* then these update logs will be sent to other MDTs */
/* get the master sub thandle */
master_st = lookup_sub_thandle(tmt, tmt->tmt_master_sub_dt);
- if (master_st == NULL) {
- top_multiple_thandle_dump(tmt, D_ERROR);
- if (th->th_result == 0)
- LBUG();
- }
-
write_updates = top_check_write_updates(top_th);
/* Step 1: write the updates log on Master MDT */
lur = tur->tur_update_records;
/* Write updates to the master MDT */
- rc = sub_updates_write(env, lur, top_th->tt_master_sub_thandle,
+ rc = sub_updates_write(env, lur, master_st->st_sub_th,
&master_st->st_cookie);
/* Cleanup the common parameters in the update records,
rc = sub_updates_write(env, lur, st->st_sub_th,
&st->st_cookie);
- if (rc < 0)
+ if (rc < 0) {
+ th->th_result = rc;
break;
+ }
}
}
* \retval 0 if creation succeeds
* \retval negative errno if creation fails
*/
-static int top_trans_create_tmt(const struct lu_env *env,
- struct top_thandle *top_th)
+int top_trans_create_tmt(const struct lu_env *env,
+ struct top_thandle *top_th)
{
struct top_multiple_thandle *tmt;
wait_event(lut->lut_tdtd_commit_thread.t_ctl_waitq,
lut->lut_tdtd_commit_thread.t_flags & SVC_STOPPED);
- if (tdtd->tdtd_batchid_obj != NULL)
+ dtrq_list_destroy(tdtd);
+ if (tdtd->tdtd_batchid_obj != NULL) {
lu_object_put(env, &tdtd->tdtd_batchid_obj->do_lu);
+ tdtd->tdtd_batchid_obj = NULL;
+ }
}
EXPORT_SYMBOL(distribute_txn_fini);