diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 5e3e9d69ba788a10d560f1dda7f67bbc6bfb4bfd..3431f635692281afa08380e5ca5f821bdf222eb7 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 e5b01f0706ef2ca3f705106f6eff29a7f7aa0279..75bc4b6cec27dd8849d4885cc47134844eb2cd79 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 a00185f085a45aa397760d60957879ae2fa08fa9..299b3c75800ea8f6b05adb7e2f07a3a903043cd3 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 69259bbc436501c241c86e1baa70d1217438a4c5..4ff466555c3b8cecf3cf95e604f0f641ed5a296b 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)); }