Whamcloud - gitweb
LU-7430 mdt: better handle MDT recovery error path 24/17424/2
authorGregoire Pichon <gregoire.pichon@bull.net>
Wed, 2 Dec 2015 10:12:31 +0000 (11:12 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 18 Dec 2015 05:27:33 +0000 (05:27 +0000)
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 <gregoire.pichon@bull.net>
Change-Id: I0559d42f40d4ecc9078717aa07b988be56ce3bc5
Reviewed-on: http://review.whamcloud.com/17424
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/target/tgt_lastrcvd.c
lustre/target/tgt_main.c

index 0c9cc87..1bb9b9b 100644 (file)
@@ -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)) {
index 18574e9..0f0fcd3 100644 (file)
@@ -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;