From c2b64c9918cbee42b264db39c36ac6ab3c9f6a38 Mon Sep 17 00:00:00 2001 From: yury <yury> Date: Fri, 7 Nov 2008 15:14:29 +0000 Subject: [PATCH] b=17445 r=tappro,johann - proper locking in rq pool freeing time --- lustre/ldlm/ldlm_lib.c | 5 ++++- lustre/mdc/mdc_request.c | 3 ++- lustre/osc/osc_request.c | 7 ++++++- lustre/ptlrpc/client.c | 5 +++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 5e3e9d69ba..3431f63569 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -518,7 +518,10 @@ int client_disconnect_export(struct obd_export *exp) * in obd_namespace. bug 14260 */ obd->obd_namespace = NULL; - ptlrpc_free_rq_pool(imp->imp_rq_pool); + if (imp->imp_rq_pool) { + ptlrpc_free_rq_pool(imp->imp_rq_pool); + imp->imp_rq_pool = NULL; + } destroy_import(imp); cli->cl_import = NULL; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index e5b01f0706..75bc4b6cec 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1610,11 +1610,12 @@ static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) client import will not have been cleaned. */ if (obd->u.cli.cl_import) { struct obd_import *imp; + down_write(&obd->u.cli.cl_sem); imp = obd->u.cli.cl_import; CERROR("client import never connected\n"); ptlrpc_invalidate_import(imp); - ptlrpc_free_rq_pool(imp->imp_rq_pool); class_destroy_import(imp); + up_write(&obd->u.cli.cl_sem); obd->u.cli.cl_import = NULL; } rc = obd_llog_finish(obd, 0); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index a00185f085..299b3c7580 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -4091,12 +4091,17 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) client import will not have been cleaned. */ if (obd->u.cli.cl_import) { struct obd_import *imp; + 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); - ptlrpc_free_rq_pool(imp->imp_rq_pool); + if (imp->imp_rq_pool) { + ptlrpc_free_rq_pool(imp->imp_rq_pool); + imp->imp_rq_pool = NULL; + } class_destroy_import(imp); + up_write(&obd->u.cli.cl_sem); obd->u.cli.cl_import = NULL; } rc = obd_llog_finish(obd, 0); diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 69259bbc43..4ff466555c 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -356,9 +356,9 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool) struct list_head *l, *tmp; struct ptlrpc_request *req; - if (!pool) - return; + LASSERT(pool != NULL); + spin_lock(&pool->prp_lock); list_for_each_safe(l, tmp, &pool->prp_req_list) { req = list_entry(l, struct ptlrpc_request, rq_list); list_del(&req->rq_list); @@ -367,6 +367,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool) OBD_FREE(req->rq_reqbuf, pool->prp_rq_size); OBD_FREE(req, sizeof(*req)); } + spin_unlock(&pool->prp_lock); OBD_FREE(pool, sizeof(*pool)); } -- GitLab