- int op, credits;
- for (op = 0; op < DTO_NR; op++) {
- credits = mdd_child_ops(mdd)->dt_credit_get(env, mdd->mdd_child,
- op);
- LASSERT(credits > 0);
- dto_txn_credits[op] = credits;
- }
-}
-
-int mdd_txn_init_credits(const struct lu_env *env, struct mdd_device *mdd)
-{
- int op;
-
- /* Init credits for each ops. */
- mdd_txn_init_dto_credits(env, mdd, dto_txn_credits);
-
- /* Calculate the mdd credits. */
- for (op = MDD_TXN_OBJECT_DESTROY_OP; op < MDD_TXN_LAST_OP; op++) {
- int *c = &mdd->mdd_tod[op].mod_credits;
- int *dt = dto_txn_credits;
- mdd->mdd_tod[op].mod_op = op;
- switch(op) {
- case MDD_TXN_OBJECT_DESTROY_OP:
- *c = dt[DTO_OBJECT_DELETE];
- break;
- case MDD_TXN_OBJECT_CREATE_OP:
- /* OI_INSERT + CREATE OBJECT */
- *c = dt[DTO_INDEX_INSERT] +
- dt[DTO_OBJECT_CREATE];
- break;
- case MDD_TXN_ATTR_SET_OP:
- /* ATTR set + XATTR(lsm, lmv) set */
- *c = dt[DTO_ATTR_SET] + dt[DTO_XATTR_SET];
- break;
- case MDD_TXN_XATTR_SET_OP:
- *c = dt[DTO_XATTR_SET];
- break;
- case MDD_TXN_INDEX_INSERT_OP:
- *c = dt[DTO_INDEX_INSERT];
- break;
- case MDD_TXN_INDEX_DELETE_OP:
- *c = dt[DTO_INDEX_DELETE];
- break;
- case MDD_TXN_LINK_OP:
- *c = dt[DTO_INDEX_INSERT];
- break;
- case MDD_TXN_UNLINK_OP:
- /* delete index + Unlink log */
- *c = dt[DTO_INDEX_DELETE];
- break;
- case MDD_TXN_RENAME_OP:
- /* 2 delete index + 1 insert + Unlink log */
- *c = 2 * dt[DTO_INDEX_DELETE] +
- dt[DTO_INDEX_INSERT];
- break;
- case MDD_TXN_RENAME_TGT_OP:
- /* index insert + index delete */
- *c = dt[DTO_INDEX_DELETE] +
- dt[DTO_INDEX_INSERT];
- break;
- case MDD_TXN_CREATE_DATA_OP:
- /* same as set xattr(lsm) */
- *c = dt[DTO_XATTR_SET];
- break;
- case MDD_TXN_MKDIR_OP:
- /* INDEX INSERT + OI INSERT +
- * CREATE_OBJECT_CREDITS
- * SET_MD CREDITS is already counted in
- * CREATE_OBJECT CREDITS
- */
- *c = 2 * dt[DTO_INDEX_INSERT] +
- dt[DTO_OBJECT_CREATE];
- break;
- default:
- CERROR("Invalid op %d init its credit\n", op);
- LBUG();
- }
- }
- RETURN(0);
-}
-
-struct thandle* mdd_trans_start(const struct lu_env *env,
- struct mdd_device *mdd)
-{
- struct txn_param *p = &mdd_env_info(env)->mti_param;
- struct thandle *th;
-
- th = mdd_child_ops(mdd)->dt_trans_start(env, mdd->mdd_child, p);
- return th;