From: Gregoire Pichon Date: Wed, 2 Dec 2015 10:12:31 +0000 (+0100) Subject: LU-7430 mdt: better handle MDT recovery error path X-Git-Tag: 2.7.65~60 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=0d3a07a8aa46bd190813b6e6e3da0e12c61a9d09;p=fs%2Flustre-release.git LU-7430 mdt: better handle MDT recovery error path This fix ensures the lu_target structure is still valid before updating export related data in tgt_client_free(). In case of recovery error, it may happen that lu_target and mdt_device structures are freed before exports are destroyed. Signed-off-by: Gregoire Pichon Change-Id: I0559d42f40d4ecc9078717aa07b988be56ce3bc5 Reviewed-on: http://review.whamcloud.com/17424 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- diff --git a/lustre/target/tgt_lastrcvd.c b/lustre/target/tgt_lastrcvd.c index 0c9cc87..1bb9b9b 100644 --- a/lustre/target/tgt_lastrcvd.c +++ b/lustre/target/tgt_lastrcvd.c @@ -308,7 +308,7 @@ static void tgt_free_reply_data(struct lu_target *lut, { CDEBUG(D_TRACE, "%s: free reply data %p: xid %llu, transno %llu, " "client gen %u, slot idx %d\n", - tgt_name(lut), trd, trd->trd_reply.lrd_xid, + lut == NULL ? "" : tgt_name(lut), trd, trd->trd_reply.lrd_xid, trd->trd_reply.lrd_transno, trd->trd_reply.lrd_client_gen, trd->trd_index); @@ -316,7 +316,8 @@ static void tgt_free_reply_data(struct lu_target *lut, list_del(&trd->trd_list); ted->ted_reply_cnt--; - tgt_clear_reply_slot(lut, trd->trd_index); + if (lut != NULL) + tgt_clear_reply_slot(lut, trd->trd_index); OBD_FREE_PTR(trd); } @@ -331,7 +332,7 @@ static void tgt_release_reply_data(struct lu_target *lut, { CDEBUG(D_TRACE, "%s: release reply data %p: xid %llu, transno %llu, " "client gen %u, slot idx %d\n", - tgt_name(lut), trd, trd->trd_reply.lrd_xid, + lut == NULL ? "" : tgt_name(lut), trd, trd->trd_reply.lrd_xid, trd->trd_reply.lrd_transno, trd->trd_reply.lrd_client_gen, trd->trd_index); @@ -418,9 +419,12 @@ void tgt_client_free(struct obd_export *exp) OBD_FREE_PTR(ted->ted_lcd); ted->ted_lcd = NULL; - /* Slot may be not yet assigned */ - if (ted->ted_lr_idx < 0) + /* Target may have been freed (see LU-7430) + * Slot may be not yet assigned */ + if (exp->exp_obd->u.obt.obt_magic != OBT_MAGIC || + ted->ted_lr_idx < 0) return; + /* Clear bit when lcd is freed */ LASSERT(lut && lut->lut_client_bitmap); if (!test_and_clear_bit(ted->ted_lr_idx, lut->lut_client_bitmap)) { diff --git a/lustre/target/tgt_main.c b/lustre/target/tgt_main.c index 18574e9..0f0fcd3 100644 --- a/lustre/target/tgt_main.c +++ b/lustre/target/tgt_main.c @@ -151,6 +151,8 @@ int tgt_init(const struct lu_env *env, struct lu_target *lut, out: dt_txn_callback_del(lut->lut_bottom, &lut->lut_txn_cb); out_put: + obd->u.obt.obt_magic = 0; + obd->u.obt.obt_lut = NULL; if (lut->lut_last_rcvd != NULL) { lu_object_put(env, &lut->lut_last_rcvd->do_lu); lut->lut_last_rcvd = NULL;