__u64 tsi_xid;
__u32 tsi_result;
__u32 tsi_client_gen;
+
+ /* RPC transaction handling */
+ bool tsi_mult_trans;
+ int tsi_has_trans;
};
static inline struct tgt_session_info *tgt_ses_info(const struct lu_env *env)
void mdt_save_lock(struct mdt_thread_info *info, struct lustre_handle *h,
enum ldlm_mode mode, int decref)
{
+ struct tgt_session_info *tsi = info->mti_env->le_ses ?
+ tgt_ses_info(info->mti_env) : NULL;
+
ENTRY;
if (lustre_handle_is_used(h)) {
- if (decref || !info->mti_has_trans ||
- !(mode & (LCK_PW | LCK_EX))) {
+ bool has_trans = tsi && tsi->tsi_has_trans;
+
+ if (decref || !has_trans || !(mode & (LCK_PW | LCK_EX))) {
mdt_fid_unlock(h, mode);
} else {
struct mdt_device *mdt = info->mti_mdt;
} else {
mdt_fid_unlock(h, mode);
}
- if (mdt_is_lock_sync(lock)) {
- CDEBUG(D_HA, "found sync-lock,"
- " async commit started\n");
- mdt_device_commit_async(info->mti_env,
- mdt);
- }
- LDLM_LOCK_PUT(lock);
- }
- h->cookie = 0ull;
- }
- EXIT;
+ if (mdt_is_lock_sync(lock)) {
+ CDEBUG(D_HA, "sync_lock, do async commit\n");
+ mdt_device_commit_async(info->mti_env, mdt);
+ }
+ LDLM_LOCK_PUT(lock);
+ }
+ h->cookie = 0ull;
+ }
+
+ EXIT;
}
/**
(MDS_INODELOCK_XATTR | MDS_INODELOCK_UPDATE)))
mo_invalidate(info->mti_env, mdt_object_child(o));
- if (decref || !info->mti_has_trans || !req ||
- !(mode & (LCK_PW | LCK_EX))) {
+ if (decref || !req || !(mode & (LCK_PW | LCK_EX)) ||
+ !tgt_ses_info(info->mti_env)->tsi_has_trans) {
ldlm_lock_decref_and_cancel(h, mode);
LDLM_LOCK_PUT(lock);
} else {
info->mti_body = NULL;
info->mti_object = NULL;
info->mti_dlm_req = NULL;
- info->mti_has_trans = 0;
info->mti_cross_ref = 0;
info->mti_opdata = 0;
info->mti_big_lmm_used = 0;
upcall_cache_cleanup(m->mdt_identity_cache);
m->mdt_identity_cache = NULL;
- mdt_fs_cleanup(env, m);
-
tgt_fini(env, &m->mdt_lut);
mdt_hsm_cdt_fini(m);
else
m->mdt_brw_size = ONE_MB_BRW_SIZE;
- rc = mdt_fs_setup(env, m, obd, lsi);
- if (rc)
- GOTO(err_tgt, rc);
+ if (OBD_FAIL_CHECK(OBD_FAIL_MDS_FS_SETUP))
+ GOTO(err_tgt, rc = -ENOENT);
fid.f_seq = FID_SEQ_LOCAL_NAME;
fid.f_oid = 1;
fid.f_ver = 0;
rc = local_oid_storage_init(env, m->mdt_bottom, &fid, &m->mdt_los);
if (rc != 0)
- GOTO(err_fs_cleanup, rc);
+ GOTO(err_tgt, rc);
rc = mdt_hsm_cdt_init(m);
if (rc != 0) {
err_los_fini:
local_oid_storage_fini(env, m->mdt_los);
m->mdt_los = NULL;
-err_fs_cleanup:
- mdt_fs_cleanup(env, m);
err_tgt:
/* keep recoverable clients */
obd->obd_fail = 1;
*/
const struct ldlm_request *mti_dlm_req;
- __u32 mti_has_trans:1, /* has txn already? */
- mti_cross_ref:1,
+ __u32 mti_cross_ref:1,
/* big_lmm buffer was used and must be used in reply */
mti_big_lmm_used:1,
mti_big_acl_used:1,
extern void target_recovery_fini(struct obd_device *obd);
extern void target_recovery_init(struct lu_target *lut,
svc_handler_t handler);
-int mdt_fs_setup(const struct lu_env *, struct mdt_device *,
- struct obd_device *, struct lustre_sb_info *lsi);
-void mdt_fs_cleanup(const struct lu_env *, struct mdt_device *);
int mdt_export_stats_init(struct obd_device *obd,
struct obd_export *exp,
return buf;
}
-/* This callback notifies MDT that transaction was done. This is needed by
- * mdt_save_lock() only. It is similar to new target code and will be removed
- * as mdt_save_lock() will be converted to use target structures
- */
-static int mdt_txn_stop_cb(const struct lu_env *env,
- struct thandle *txn, void *cookie)
-{
- struct mdt_thread_info *mti;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- LASSERT(mti);
-
- if (mti->mti_has_trans)
- CDEBUG(D_INFO, "More than one transaction\n");
- else
- mti->mti_has_trans = 1;
- return 0;
-}
-
-int mdt_fs_setup(const struct lu_env *env, struct mdt_device *mdt,
- struct obd_device *obd, struct lustre_sb_info *lsi)
-{
- int rc = 0;
-
- ENTRY;
-
- if (OBD_FAIL_CHECK(OBD_FAIL_MDS_FS_SETUP))
- RETURN(-ENOENT);
-
- /* prepare transactions callbacks */
- mdt->mdt_txn_cb.dtc_txn_start = NULL;
- mdt->mdt_txn_cb.dtc_txn_stop = mdt_txn_stop_cb;
- mdt->mdt_txn_cb.dtc_cookie = NULL;
- mdt->mdt_txn_cb.dtc_tag = LCT_MD_THREAD;
- INIT_LIST_HEAD(&mdt->mdt_txn_cb.dtc_linkage);
-
- dt_txn_callback_add(mdt->mdt_bottom, &mdt->mdt_txn_cb);
-
- RETURN(rc);
-}
-
-void mdt_fs_cleanup(const struct lu_env *env, struct mdt_device *mdt)
-{
- ENTRY;
-
- /* Remove transaction callback */
- dt_txn_callback_del(mdt->mdt_bottom, &mdt->mdt_txn_cb);
- EXIT;
-}
-
/* reconstruction code */
static void mdt_steal_ack_locks(struct ptlrpc_request *req)
{
reply->ourp_magic = UPDATE_REPLY_MAGIC;
reply->ourp_count = updates;
tti->tti_u.update.tti_update_reply = reply;
- tti->tti_mult_trans = !req_is_replay(tgt_ses_req(tsi));
+ tsi->tsi_mult_trans = !req_is_replay(tgt_ses_req(tsi));
OBD_ALLOC_PTR(trd);
if (!trd)
int tgt_brw_write(struct tgt_session_info *tsi)
{
- struct tgt_thread_info *tti = tgt_th_info(tsi->tsi_env);
struct ptlrpc_request *req = tgt_ses_req(tsi);
struct ptlrpc_bulk_desc *desc = NULL;
struct obd_export *exp = req->rq_export;
}
/* multiple transactions can be assigned during write commit */
- tti->tti_mult_trans = 1;
+ tsi->tsi_mult_trans = 1;
/* Must commit after prep above in all cases */
rc = obd_commitrw(tsi->tsi_env, OBD_BRW_WRITE, exp, &repbody->oa,
/* transno storage during last_rcvd update */
__u64 tti_transno;
- __u32 tti_has_trans:1,
- tti_mult_trans:1;
/* Updates data for OUT target */
struct thandle_exec_args tti_tea;
echo_client = (tgt_ses_req(tsi) == NULL && tsi->tsi_xid == 0);
- if (tti->tti_has_trans && !echo_client) {
- if (tti->tti_mult_trans == 0) {
+ if (tsi->tsi_has_trans && !echo_client) {
+ if (!tsi->tsi_mult_trans) {
CDEBUG(D_HA, "More than one transaction %llu\n",
tti->tti_transno);
/**
* data loss.
*/
}
- /* we need another transno to be assigned */
+ /* we need new transno to be assigned */
tti->tti_transno = 0;
- } else if (th->th_result == 0) {
- tti->tti_has_trans = 1;
}
+ if (!th->th_result)
+ tsi->tsi_has_trans++;
+
if (tsi->tsi_vbr_obj != NULL &&
!lu_object_remote(&tsi->tsi_vbr_obj->do_lu)) {
obj = tsi->tsi_vbr_obj;
OBD_SLAB_FREE_PTR(info, tgt_thread_kmem);
}
-static void tgt_key_exit(const struct lu_context *ctx,
- struct lu_context_key *key, void *data)
-{
- struct tgt_thread_info *tti = data;
-
- tti->tti_has_trans = 0;
- tti->tti_mult_trans = 0;
-}
-
/* context key: tg_thread_key */
struct lu_context_key tgt_thread_key = {
.lct_tags = LCT_MD_THREAD | LCT_DT_THREAD,
.lct_init = tgt_key_init,
.lct_fini = tgt_key_fini,
- .lct_exit = tgt_key_exit,
};
LU_KEY_INIT_GENERIC(tgt);
OBD_SLAB_FREE_PTR(session, tgt_session_kmem);
}
+static void tgt_ses_key_exit(const struct lu_context *ctx,
+ struct lu_context_key *key, void *data)
+{
+ struct tgt_session_info *tsi = data;
+
+ if (tsi->tsi_has_trans > 1)
+ CDEBUG(D_WARNING, "total %i transactions per RPC\n",
+ tsi->tsi_has_trans);
+ tsi->tsi_has_trans = 0;
+ tsi->tsi_mult_trans = false;
+}
+
/* context key: tgt_session_key */
struct lu_context_key tgt_session_key = {
.lct_tags = LCT_SERVER_SESSION,
.lct_init = tgt_ses_key_init,
.lct_fini = tgt_ses_key_fini,
+ .lct_exit = tgt_ses_key_exit,
};
EXPORT_SYMBOL(tgt_session_key);