diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index ae38782bfa3063ff970f9713eea1ae3d62324e7e..4417b6792bc2d799b9261ad0e145fabebb0f10c7 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -504,8 +504,11 @@ int client_disconnect_export(struct obd_export *exp) * some connect requests in flight, and his need store a connect flags * 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; + } class_destroy_import(imp); cli->cl_import = NULL; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 4613655efdb4c9e625e8096129eb16530b5ba8c4..5702dd758b46e9e791dba7d37bc8784a14f4ef6e 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1306,11 +1306,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 9c6665495a5f4c5d7cadbcd1515146c8d0bc8af6..3151dcd9fd085751a7fff4e9345512d2e7868376 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -3885,12 +3885,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 5211006733d901c58837bead4672a96b06242392..40603b3416b1d5cc170c75e5bf0d0395bc35d5fc 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -419,16 +419,17 @@ 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); - LASSERT (req->rq_reqmsg); + LASSERT(req->rq_reqmsg); OBD_FREE(req->rq_reqmsg, pool->prp_rq_size); OBD_FREE(req, sizeof(*req)); } + spin_unlock(&pool->prp_lock); OBD_FREE(pool, sizeof(*pool)); }