From dd745f94bf0fac0d4042f46c8faba1b61d3b9fb3 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Wed, 16 Sep 2015 15:16:28 +0300 Subject: [PATCH] LU-7065 lod: Fix free of already added target description 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 Reviewed-on: http://review.whamcloud.com/16441 Tested-by: Jenkins Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/lod/lod_lov.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 4927303..a116ae2 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -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(<d->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: -- 1.8.3.1