From 90d81cdf95de82302ab5a7f2b0f5968e4ec28306 Mon Sep 17 00:00:00 2001
From: bobijam <bobijam>
Date: Tue, 24 Jun 2008 01:48:38 +0000
Subject: [PATCH] Branch b1_6 b=15924 i=green, johann

Description: do not process already freed flock
Details    : flock can possibly be freed by another thread before it reaches
             to ldlm_flock_completion_ast.
---
 lustre/ChangeLog         | 6 ++++++
 lustre/ldlm/ldlm_flock.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index 7b6315a629..c79cb6a0dd 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -24,6 +24,12 @@ tbd Sun Microsystems, Inc.
 	  	'tunefs.lustre --param="mdt.quota_type=ug1" $MDTDEV'.
 	  For more information, please refer to bugzilla 13904.
 
+Severity   : major
+Bugzilla   : 15924
+Description: do not process already freed flock
+Details    : flock can possibly be freed by another thread before it reaches
+             to ldlm_flock_completion_ast.
+
 Severity   : normal
 Bugzilla   : 14480
 Description: LBUG during stress test
diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c
index 0b9f09b817..dddd257f16 100644
--- a/lustre/ldlm/ldlm_flock.c
+++ b/lustre/ldlm/ldlm_flock.c
@@ -544,6 +544,13 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data)
         RETURN(rc);
  
 granted:
+        /* before flock's complete ast gets here, the flock
+         * can possibly be freed by another thread
+         */
+        if (lock->l_destroyed) {
+                LDLM_DEBUG(lock, "already destroyed by another thread");
+                RETURN(0);
+        }
 
         LDLM_DEBUG(lock, "client-side enqueue granted");
         ns = lock->l_resource->lr_namespace;
-- 
GitLab