From: Swapnil Pimpale Date: Thu, 5 Sep 2013 12:27:00 +0000 (+0530) Subject: LU-3810 obd: Cleanup client import if client_obd_setup fails X-Git-Tag: 2.5.52~81 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=911b6167a37c2dba835baab4e100dcf206c03113 LU-3810 obd: Cleanup client import if client_obd_setup fails client_obd_setup() allocates an obd_import which should be cleaned up if there is any failure afterwards in callers of client_obd_setup(). This patch fixes the bug in osc_setup(), mgc_setup(), mdc_setup() and lwp_setup(). The fix is to call obd_cleanup_client_import() before calling client_obd_cleanup() in case of an error. Signed-off-by: Swapnil Pimpale Change-Id: Ib8c2194d80fd14538d4ca42fb8084c93dd575199 Reviewed-on: http://review.whamcloud.com/7561 Reviewed-by: John L. Hammond Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Andreas Dilger --- diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index facc975..6b18781 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -473,15 +473,16 @@ EXPORT_SYMBOL(client_obd_setup); int client_obd_cleanup(struct obd_device *obddev) { - ENTRY; + ENTRY; - ldlm_namespace_free_post(obddev->obd_namespace); - obddev->obd_namespace = NULL; + ldlm_namespace_free_post(obddev->obd_namespace); + obddev->obd_namespace = NULL; - LASSERT(obddev->u.cli.cl_import == NULL); + obd_cleanup_client_import(obddev); + LASSERT(obddev->u.cli.cl_import == NULL); - ldlm_put_ref(); - RETURN(0); + ldlm_put_ref(); + RETURN(0); } EXPORT_SYMBOL(client_obd_cleanup); diff --git a/lustre/mgc/libmgc.c b/lustre/mgc/libmgc.c index c639da8..bcc3617 100644 --- a/lustre/mgc/libmgc.c +++ b/lustre/mgc/libmgc.c @@ -53,33 +53,33 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - int rc; - ENTRY; + int rc; + ENTRY; rc = ptlrpcd_addref(); if (rc < 0) RETURN(rc); - rc = client_obd_setup(obd, lcfg); - if (rc) - GOTO(err_decref, rc); + rc = client_obd_setup(obd, lcfg); + if (rc) + GOTO(err_decref, rc); - /* liblustre only support null flavor to MGS */ - obd->u.cli.cl_flvr_mgc.sf_rpc = SPTLRPC_FLVR_NULL; + /* liblustre only support null flavor to MGS */ + obd->u.cli.cl_flvr_mgc.sf_rpc = SPTLRPC_FLVR_NULL; - rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL); - if (rc) { - CERROR("failed to setup llogging subsystems\n"); - GOTO(err_cleanup, rc); - } + rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL); + if (rc) { + CERROR("failed to setup llogging subsystems\n"); + GOTO(err_cleanup, rc); + } - RETURN(rc); + RETURN(rc); err_cleanup: - client_obd_cleanup(obd); + client_obd_cleanup(obd); err_decref: - ptlrpcd_decref(); - RETURN(rc); + ptlrpcd_decref(); + RETURN(rc); } static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 94b8d8d..64ab255 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -893,27 +893,27 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lprocfs_static_vars lvars; int rc; - ENTRY; + ENTRY; rc = ptlrpcd_addref(); if (rc < 0) RETURN(rc); - rc = client_obd_setup(obd, lcfg); - if (rc) - GOTO(err_decref, rc); + rc = client_obd_setup(obd, lcfg); + if (rc) + GOTO(err_decref, rc); rc = mgc_llog_init(NULL, obd); - if (rc) { - CERROR("failed to setup llogging subsystems\n"); - GOTO(err_cleanup, rc); - } + if (rc) { + CERROR("failed to setup llogging subsystems\n"); + GOTO(err_cleanup, rc); + } - lprocfs_mgc_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars); - sptlrpc_lprocfs_cliobd_attach(obd); + lprocfs_mgc_init_vars(&lvars); + lprocfs_obd_setup(obd, lvars.obd_vars); + sptlrpc_lprocfs_cliobd_attach(obd); - if (cfs_atomic_inc_return(&mgc_count) == 1) { + if (cfs_atomic_inc_return(&mgc_count) == 1) { rq_state = 0; init_waitqueue_head(&rq_waitq); @@ -928,15 +928,15 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } /* rc is the task_struct pointer of mgc_requeue_thread. */ rc = 0; - } + } - RETURN(rc); + RETURN(rc); err_cleanup: - client_obd_cleanup(obd); + client_obd_cleanup(obd); err_decref: - ptlrpcd_decref(); - RETURN(rc); + ptlrpcd_decref(); + RETURN(rc); } /* based on ll_mdc_blocking_ast */ diff --git a/lustre/osp/lwp_dev.c b/lustre/osp/lwp_dev.c index 8b1653e..fce82a2 100644 --- a/lustre/osp/lwp_dev.c +++ b/lustre/osp/lwp_dev.c @@ -145,6 +145,7 @@ out: lustre_cfg_free(lcfg); if (rc) client_obd_cleanup(lwp->lpd_obd); + RETURN(rc); } @@ -321,8 +322,6 @@ static struct lu_device *lwp_device_fini(const struct lu_env *env, imp->imp_rq_pool = NULL; } - obd_cleanup_client_import(m->lpd_obd); - LASSERT(m->lpd_obd); ptlrpc_lprocfs_unregister_obd(m->lpd_obd); lprocfs_obd_cleanup(m->lpd_obd); diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index 8e71157..1094a65 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -745,7 +745,6 @@ out_last_used: out_proc: ptlrpc_lprocfs_unregister_obd(obd); lprocfs_obd_cleanup(obd); - obd_cleanup_client_import(obd); if (m->opd_symlink) lprocfs_remove(&m->opd_symlink); client_obd_cleanup(obd); @@ -825,8 +824,6 @@ static struct lu_device *osp_device_fini(const struct lu_env *env, imp->imp_rq_pool = NULL; } - obd_cleanup_client_import(m->opd_obd); - if (m->opd_symlink) lprocfs_remove(&m->opd_symlink);