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 <spimpale@ddn.com>
Change-Id: Ib8c2194d80fd14538d4ca42fb8084c93dd575199
Reviewed-on: http://review.whamcloud.com/7561
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
int client_obd_cleanup(struct obd_device *obddev)
{
int client_obd_cleanup(struct obd_device *obddev)
{
- 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);
}
EXPORT_SYMBOL(client_obd_cleanup);
static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
rc = ptlrpcd_addref();
if (rc < 0)
RETURN(rc);
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);
+ }
- client_obd_cleanup(obd);
+ client_obd_cleanup(obd);
- ptlrpcd_decref();
- RETURN(rc);
+ ptlrpcd_decref();
+ RETURN(rc);
}
static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
}
static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
{
struct lprocfs_static_vars lvars;
int rc;
{
struct lprocfs_static_vars lvars;
int rc;
rc = ptlrpcd_addref();
if (rc < 0)
RETURN(rc);
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);
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);
rq_state = 0;
init_waitqueue_head(&rq_waitq);
}
/* rc is the task_struct pointer of mgc_requeue_thread. */
rc = 0;
}
/* rc is the task_struct pointer of mgc_requeue_thread. */
rc = 0;
- client_obd_cleanup(obd);
+ client_obd_cleanup(obd);
- ptlrpcd_decref();
- RETURN(rc);
+ ptlrpcd_decref();
+ RETURN(rc);
}
/* based on ll_mdc_blocking_ast */
}
/* based on ll_mdc_blocking_ast */
lustre_cfg_free(lcfg);
if (rc)
client_obd_cleanup(lwp->lpd_obd);
lustre_cfg_free(lcfg);
if (rc)
client_obd_cleanup(lwp->lpd_obd);
imp->imp_rq_pool = NULL;
}
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);
LASSERT(m->lpd_obd);
ptlrpc_lprocfs_unregister_obd(m->lpd_obd);
lprocfs_obd_cleanup(m->lpd_obd);
out_proc:
ptlrpc_lprocfs_unregister_obd(obd);
lprocfs_obd_cleanup(obd);
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);
if (m->opd_symlink)
lprocfs_remove(&m->opd_symlink);
client_obd_cleanup(obd);
imp->imp_rq_pool = NULL;
}
imp->imp_rq_pool = NULL;
}
- obd_cleanup_client_import(m->opd_obd);
-
if (m->opd_symlink)
lprocfs_remove(&m->opd_symlink);
if (m->opd_symlink)
lprocfs_remove(&m->opd_symlink);