From a612021120d410ecc220f36117fc228aef90482c Mon Sep 17 00:00:00 2001 From: phil Date: Mon, 8 Dec 2003 15:22:47 +0000 Subject: [PATCH] b=2321 Fix two rare exit paths which will leak an l_lock() reference: - an allocation failure in ldlm_server_blocking_ast - an unlikely race condition in ldlm_resource_add_lock I blame the latter for the problem reported in bug 2321. --- lustre/ldlm/ldlm_lockd.c | 5 ++++- lustre/ldlm/ldlm_resource.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 9fcdfa8..d6a4618 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -324,14 +324,17 @@ int ldlm_server_blocking_ast(struct ldlm_lock *lock, #if 0 if (LTIME_S(CURRENT_TIME) - lock->l_export->exp_last_request_time > 30){ ldlm_failed_ast(lock, -ETIMEDOUT, "Not-attempted blocking"); + l_unlock(&lock->l_resource->lr_namespace->ns_lock); RETURN(-ETIMEDOUT); } #endif req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse, LDLM_BL_CALLBACK, 1, &size, NULL); - if (!req) + if (req == NULL) { + l_unlock(&lock->l_resource->lr_namespace->ns_lock); RETURN(-ENOMEM); + } body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body)); memcpy(&body->lock_handle1, &lock->l_remote_handle, diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 5305087..4a5f5e6 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -604,12 +604,13 @@ void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head, if (lock->l_destroyed) { CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n"); - return; + goto out; } LASSERT(list_empty(&lock->l_res_link)); list_add_tail(&lock->l_res_link, head); + out: l_unlock(&res->lr_namespace->ns_lock); } -- 1.8.3.1