Whamcloud - gitweb
b=2321
authorphil <phil>
Mon, 8 Dec 2003 15:22:47 +0000 (15:22 +0000)
committerphil <phil>
Mon, 8 Dec 2003 15:22:47 +0000 (15:22 +0000)
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
lustre/ldlm/ldlm_resource.c

index 9fcdfa8..d6a4618 100644 (file)
@@ -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,
index 5305087..4a5f5e6 100644 (file)
@@ -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);
 }