[Ocfs2-commits] khackel commits r2655 - trunk/fs/ocfs2/dlm

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Oct 14 19:51:29 CDT 2005


Author: khackel
Signed-off-by: mfasheh
Date: 2005-10-14 19:51:28 -0500 (Fri, 14 Oct 2005)
New Revision: 2655

Modified:
   trunk/fs/ocfs2/dlm/dlmmaster.c
Log:
* fixes a bad dereference of a master list entry during 
  lock mastery
* bumps the refcount during dlm_get_lock_resource in case another caller
  is asserting simultaneously
* only puts 2 references if the entry is a BLOCK, meaning that the caller
  is the only one that can clean it up

Signed-off-by: mfasheh




Modified: trunk/fs/ocfs2/dlm/dlmmaster.c
===================================================================
--- trunk/fs/ocfs2/dlm/dlmmaster.c	2005-10-15 00:44:19 UTC (rev 2654)
+++ trunk/fs/ocfs2/dlm/dlmmaster.c	2005-10-15 00:51:28 UTC (rev 2655)
@@ -757,6 +757,11 @@
 
 	/* finally add the lockres to its hash bucket */
 	__dlm_insert_lockres(dlm, res);
+	/* get an extra ref on the mle in case this is a BLOCK
+	 * if so, the creator of the BLOCK may try to put the last
+	 * ref at this time in the assert master handler, so we
+	 * need an extra one to keep from a bad ptr deref. */
+	dlm_get_mle(mle);
 	spin_unlock(&dlm->master_lock);
 	spin_unlock(&dlm->spinlock);
 
@@ -803,6 +808,8 @@
 	/* master is known, detach if not already detached */
 	dlm_mle_detach_hb_events(dlm, mle);
 	dlm_put_mle(mle);
+	/* put the extra ref */
+	dlm_put_mle(mle);
 
 wake_waiters:
 	spin_lock(&res->spinlock);
@@ -1588,7 +1595,10 @@
 	// mlog(0, "woo!  got an assert_master from node %u!\n",
 	// 	     assert->node_idx);
 	if (mle) {
+		int block;
+		
 		spin_lock(&mle->spinlock);
+		block = !!(mle->type == DLM_MLE_BLOCK);
 		mle->master = assert->node_idx;
 		atomic_set(&mle->woken, 1);
 		wake_up(&mle->wq);
@@ -1608,11 +1618,14 @@
 		/* master is known, detach if not already detached */
 		dlm_mle_detach_hb_events(dlm, mle);
 		dlm_put_mle(mle);
-		/* the assert master message now balances the extra
-		 * ref given by the master request message.
-		 * if this is the last put, it will be removed
-		 * from the list. */
-		dlm_put_mle(mle);
+		
+		if (block) {
+			/* the assert master message now balances the extra
+		 	 * ref given by the master request message.
+		 	 * if this is the last put, it will be removed
+		 	 * from the list. */
+			dlm_put_mle(mle);
+		}
 	}
 
 done:



More information about the Ocfs2-commits mailing list