From e87e848d83a45d8bc981670e888772c0b7be94fd Mon Sep 17 00:00:00 2001 From: bwzhou Date: Fri, 9 May 2008 17:25:50 +0000 Subject: [PATCH] Branch HEAD b=14034 r=adilger, bobijam error handling for the ENOMEM case when failing to allocate ldlm resource --- lustre/ldlm/ldlm_lock.c | 4 +--- lustre/ldlm/ldlm_lockd.c | 9 +++++++-- lustre/ldlm/ldlm_request.c | 8 +++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index a6d5b55..606a8fe 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -380,10 +380,8 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, unlock_res_and_lock(lock); newres = ldlm_resource_get(ns, NULL, new_resid, type, 1); - if (newres == NULL) { - LBUG(); + if (newres == NULL) RETURN(-ENOMEM); - } lock_res_and_lock(lock); LASSERT(memcmp(new_resid, &lock->l_resource->lr_name, diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index cc7fc39..36a1c80 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -1378,8 +1378,13 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, &lock->l_resource->lr_name, sizeof(lock->l_resource->lr_name)) != 0) { unlock_res_and_lock(lock); - ldlm_lock_change_resource(ns, lock, - &dlm_req->lock_desc.l_resource.lr_name); + if (ldlm_lock_change_resource(ns, lock, + &dlm_req->lock_desc.l_resource.lr_name) != 0) { + LDLM_ERROR(lock, "Failed to allocate resource"); + LDLM_LOCK_PUT(lock); + EXIT; + return; + } LDLM_DEBUG(lock, "completion AST, new resource"); CERROR("change resource!\n"); lock_res_and_lock(lock); diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 5d0c289..b0f9ced 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -412,12 +412,10 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, (long)lock->l_resource->lr_name.name[1], (long)lock->l_resource->lr_name.name[2]); - ldlm_lock_change_resource(ns, lock, - &reply->lock_desc.l_resource.lr_name); - if (lock->l_resource == NULL) { - LBUG(); + rc = ldlm_lock_change_resource(ns, lock, + &reply->lock_desc.l_resource.lr_name); + if (rc || lock->l_resource == NULL) GOTO(cleanup, rc = -ENOMEM); - } LDLM_DEBUG(lock, "client-side enqueue, new resource"); } if (with_policy) -- 1.8.3.1