Whamcloud - gitweb
LU-7065 lod: Fix free of already added target description 41/16441/4
authorDmitry Eremin <dmitry.eremin@intel.com>
Wed, 16 Sep 2015 12:16:28 +0000 (15:16 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 2 Oct 2015 04:14:19 +0000 (04:14 +0000)
In lod_add_device() we may free tgt_desc after adding it to the ldt
if error happens in lod_sub_init_llog() or lfsck_add_target().

Change-Id: Ifb267378db996ae3a86da75b03427fb01eb0d73a
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-on: http://review.whamcloud.com/16441
Tested-by: Jenkins
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_lov.c

index 4927303..a116ae2 100644 (file)
@@ -388,7 +388,7 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod,
                if (rc != 0) {
                        CERROR("%s: cannot start llog on %s:rc = %d\n",
                               lod2obd(lod)->obd_name, osp, rc);
-                       GOTO(out_pool, rc);
+                       GOTO(out_ltd, rc);
                }
        }
 
@@ -402,6 +402,19 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod,
 out_fini_llog:
        lod_sub_fini_llog(env, tgt_desc->ltd_tgt,
                          tgt_desc->ltd_recovery_thread);
+out_ltd:
+       lod_getref(ltd);
+       mutex_lock(&ltd->ltd_mutex);
+       lock = true;
+       if (!for_ost && LTD_TGT(ltd, index)->ltd_recovery_thread != NULL) {
+               struct ptlrpc_thread *thread;
+
+               thread = LTD_TGT(ltd, index)->ltd_recovery_thread;
+               OBD_FREE_PTR(thread);
+       }
+       ltd->ltd_tgtnr--;
+       cfs_bitmap_clear(ltd->ltd_tgt_bitmap, index);
+       LTD_TGT(ltd, index) = NULL;
 out_pool:
        lod_ost_pool_remove(&lod->lod_pool_info, index);
 out_mutex: