Whamcloud - gitweb
* Landing fix on HEAD, originally committed to b_devel
authorphil <phil>
Sun, 3 Aug 2003 21:04:09 +0000 (21:04 +0000)
committerphil <phil>
Sun, 3 Aug 2003 21:04:09 +0000 (21:04 +0000)
b=1625
r=adilger
Avoid dereferencing 'lock' after we LDLM_LOCK_PUT, by saving a copy of
the namespace pointer and using that to unlock.

Alternatively, we could drop the NS lock and then do the PUT, but this
is an equally low-impact fix.

lustre/ldlm/ldlm_lock.c

index 3995e95..ba98b1a 100644 (file)
@@ -330,6 +330,7 @@ void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh)
 
 struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle, int flags)
 {
+        struct ldlm_namespace *ns;
         struct ldlm_lock *lock = NULL, *retval = NULL;
         ENTRY;
 
@@ -340,9 +341,10 @@ struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle, int flags)
                 RETURN(NULL);
 
         LASSERT(lock->l_resource != NULL);
-        LASSERT(lock->l_resource->lr_namespace != NULL);
+        ns = lock->l_resource->lr_namespace;
+        LASSERT(ns != NULL);
 
-        l_lock(&lock->l_resource->lr_namespace->ns_lock);
+        l_lock(&ns->ns_lock);
 
         /* It's unlikely but possible that someone marked the lock as
          * destroyed after we did handle2object on it */
@@ -363,7 +365,7 @@ struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle, int flags)
         retval = lock;
         EXIT;
  out:
-        l_unlock(&lock->l_resource->lr_namespace->ns_lock);
+        l_unlock(&ns->ns_lock);
         return retval;
 }