From: hongchao.zhang Date: Thu, 28 Jul 2011 07:46:47 +0000 (+0800) Subject: LU-327 cleanup the client import of mgc X-Git-Tag: 2.1.0-RC0~35 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=421d8e98f309870475aadc05aa81a60e9acd8e65 LU-327 cleanup the client import of mgc the client import will not have been cleaned if it is setup but never connected, adding such cleanup code in mgc_precleanup. define a new inline function "obd_cleanup_client_import" in "obd_class.h" to be used by mgc, mdc and osc. Change-Id: If033de3fe81b9a565a7af40a7b93e395fb0bd659 Signed-off-by: Hongchao Zhang Reviewed-on: http://review.whamcloud.com/917 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Mikhail Pershin Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index d4cd526..3865358 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -619,6 +619,31 @@ static inline int obd_cleanup(struct obd_device *obd) RETURN(rc); } +static inline void obd_cleanup_client_import(struct obd_device *obd) +{ + ENTRY; + + /* If we set up but never connected, the + client import will not have been cleaned. */ + cfs_down_write(&obd->u.cli.cl_sem); + if (obd->u.cli.cl_import) { + struct obd_import *imp; + imp = obd->u.cli.cl_import; + CDEBUG(D_CONFIG, "%s: client import never connected\n", + obd->obd_name); + ptlrpc_invalidate_import(imp); + if (imp->imp_rq_pool) { + ptlrpc_free_rq_pool(imp->imp_rq_pool); + imp->imp_rq_pool = NULL; + } + class_destroy_import(imp); + obd->u.cli.cl_import = NULL; + } + cfs_up_write(&obd->u.cli.cl_sem); + + EXIT; +} + static inline int obd_process_config(struct obd_device *obd, int datalen, void *data) { diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index a0bb726..3abdd77 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -2060,18 +2060,8 @@ static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) if (obd->obd_type->typ_refcnt <= 1) libcfs_kkuc_group_rem(0, KUC_GRP_HSM); - /* If we set up but never connected, the - client import will not have been cleaned. */ - if (obd->u.cli.cl_import) { - struct obd_import *imp; - cfs_down_write(&obd->u.cli.cl_sem); - imp = obd->u.cli.cl_import; - CERROR("client import never connected\n"); - ptlrpc_invalidate_import(imp); - class_destroy_import(imp); - cfs_up_write(&obd->u.cli.cl_sem); - obd->u.cli.cl_import = NULL; - } + obd_cleanup_client_import(obd); + rc = obd_llog_finish(obd, 0); if (rc != 0) CERROR("failed to cleanup llogging subsystems\n"); diff --git a/lustre/mgc/libmgc.c b/lustre/mgc/libmgc.c index 966f0ec..981b79b 100644 --- a/lustre/mgc/libmgc.c +++ b/lustre/mgc/libmgc.c @@ -93,6 +93,7 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) switch (stage) { case OBD_CLEANUP_EARLY: case OBD_CLEANUP_EXPORTS: + obd_cleanup_client_import(obd); rc = obd_llog_finish(obd, 0); if (rc != 0) CERROR("failed to cleanup llogging subsystems\n"); diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index b4795bd..cfc2797 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -633,6 +633,7 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) cfs_spin_unlock(&config_list_lock); cfs_waitq_signal(&rq_waitq); } + obd_cleanup_client_import(obd); rc = obd_llog_finish(obd, 0); if (rc != 0) CERROR("failed to cleanup llogging subsystems\n"); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 33a0c2c..4b5f2c3 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -4514,23 +4514,7 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) * client_disconnect_export() */ obd_zombie_barrier(); - /* If we set up but never connected, the - client import will not have been cleaned. */ - if (obd->u.cli.cl_import) { - struct obd_import *imp; - cfs_down_write(&obd->u.cli.cl_sem); - imp = obd->u.cli.cl_import; - CDEBUG(D_CONFIG, "%s: client import never connected\n", - obd->obd_name); - ptlrpc_invalidate_import(imp); - if (imp->imp_rq_pool) { - ptlrpc_free_rq_pool(imp->imp_rq_pool); - imp->imp_rq_pool = NULL; - } - class_destroy_import(imp); - cfs_up_write(&obd->u.cli.cl_sem); - obd->u.cli.cl_import = NULL; - } + obd_cleanup_client_import(obd); rc = obd_llog_finish(obd, 0); if (rc != 0) CERROR("failed to cleanup llogging subsystems\n");