X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftarget%2Ftgt_main.c;h=4f7cff54270f17aca763c9c91fd0b489c1df654c;hb=bf478fd946d03faf467bb5dbe74c912a753a9d63;hp=876cef2ab693cc77ec98b1be69a27868041d7416;hpb=98060d83459ba10409f295898f0ec917f938b4d3;p=fs%2Flustre-release.git diff --git a/lustre/target/tgt_main.c b/lustre/target/tgt_main.c index 876cef2..4f7cff5 100644 --- a/lustre/target/tgt_main.c +++ b/lustre/target/tgt_main.c @@ -34,17 +34,18 @@ #define DEBUG_SUBSYSTEM S_CLASS #include - #include "tgt_internal.h" int tgt_init(const struct lu_env *env, struct lu_target *lut, - struct obd_device *obd, struct dt_device *dt) + struct obd_device *obd, struct dt_device *dt, + struct tgt_opc_slice *slice, int request_fail_id, + int reply_fail_id) { - struct dt_object_format dof; - struct lu_attr attr; - struct lu_fid fid; - struct dt_object *o; - int rc = 0; + struct dt_object_format dof; + struct lu_attr attr; + struct lu_fid fid; + struct dt_object *o; + int rc = 0; ENTRY; @@ -53,9 +54,28 @@ int tgt_init(const struct lu_env *env, struct lu_target *lut, lut->lut_obd = obd; lut->lut_bottom = dt; lut->lut_last_rcvd = NULL; + lut->lut_client_bitmap = NULL; obd->u.obt.obt_lut = lut; obd->u.obt.obt_magic = OBT_MAGIC; + /* set request handler slice and parameters */ + lut->lut_slice = slice; + lut->lut_reply_fail_id = reply_fail_id; + lut->lut_request_fail_id = request_fail_id; + + /* sptlrcp variables init */ + rwlock_init(&lut->lut_sptlrpc_lock); + sptlrpc_rule_set_init(&lut->lut_sptlrpc_rset); + lut->lut_mds_capa = 1; + lut->lut_oss_capa = 1; + + spin_lock_init(&lut->lut_flags_lock); + lut->lut_sync_lock_cancel = NEVER_SYNC_ON_CANCEL; + + /* last_rcvd initialization is needed by replayable targets only */ + if (!obd->obd_replayable) + RETURN(0); + spin_lock_init(&lut->lut_translock); OBD_ALLOC(lut->lut_client_bitmap, LR_MAX_CLIENTS >> 3); @@ -87,6 +107,8 @@ void tgt_fini(const struct lu_env *env, struct lu_target *lut) { ENTRY; + sptlrpc_rule_set_free(&lut->lut_sptlrpc_rset); + if (lut->lut_client_bitmap) { OBD_FREE(lut->lut_client_bitmap, LR_MAX_CLIENTS >> 3); lut->lut_client_bitmap = NULL; @@ -106,17 +128,51 @@ LU_KEY_INIT_FINI(tgt, struct tgt_thread_info); LU_CONTEXT_KEY_DEFINE(tgt, LCT_MD_THREAD | LCT_DT_THREAD); EXPORT_SYMBOL(tgt_thread_key); -LU_KEY_INIT_GENERIC(tg); +LU_KEY_INIT_GENERIC(tgt); + +/* context key constructor/destructor: tgt_ses_key_init, tgt_ses_key_fini */ +LU_KEY_INIT_FINI(tgt_ses, struct tgt_session_info); + +/* 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, +}; +EXPORT_SYMBOL(tgt_session_key); + +LU_KEY_INIT_GENERIC(tgt_ses); + +/* + * this page is allocated statically when module is initializing + * it is used to simulate data corruptions, see ost_checksum_bulk() + * for details. as the original pages provided by the layers below + * can be remain in the internal cache, we do not want to modify + * them. + */ +struct page *tgt_page_to_corrupt; int tgt_mod_init(void) { - tg_key_init_generic(&tgt_thread_key, NULL); + ENTRY; + + tgt_page_to_corrupt = alloc_page(GFP_IOFS); + + tgt_key_init_generic(&tgt_thread_key, NULL); lu_context_key_register_many(&tgt_thread_key, NULL); - return 0; + + tgt_ses_key_init_generic(&tgt_session_key, NULL); + lu_context_key_register_many(&tgt_session_key, NULL); + + RETURN(0); } void tgt_mod_exit(void) { + if (tgt_page_to_corrupt != NULL) + page_cache_release(tgt_page_to_corrupt); + lu_context_key_degister(&tgt_thread_key); + lu_context_key_degister(&tgt_session_key); }