[Ocfs2-commits] mfasheh commits r2469 - trunk/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Jul 13 18:58:22 CDT 2005


Author: mfasheh
Signed-off-by: zab
Date: 2005-07-13 18:58:20 -0500 (Wed, 13 Jul 2005)
New Revision: 2469

Modified:
   trunk/fs/ocfs2/dlmglue.c
Log:
* in ocfs2_cluster_lock, reload our completion when looping back to wait on the dlm

* don't free a lock callback on -EIOCBQUEUED

Signed-off-by: zab



Modified: trunk/fs/ocfs2/dlmglue.c
===================================================================
--- trunk/fs/ocfs2/dlmglue.c	2005-07-12 23:09:53 UTC (rev 2468)
+++ trunk/fs/ocfs2/dlmglue.c	2005-07-13 23:58:20 UTC (rev 2469)
@@ -869,13 +869,6 @@
 		   !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_BUSY));
 }
 
-static inline void ocfs2_wait_on_blocked_lock(struct ocfs2_lock_res *lockres)
-
-{
-	wait_event(lockres->l_event,
-		   !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_BLOCKED));
-}
-
 static inline void ocfs2_wait_on_refreshing_lock(struct ocfs2_lock_res *lockres)
 
 {
@@ -930,11 +923,12 @@
 			      ocfs2_lock_callback cb,
 			      unsigned long cb_data)
 {
-	struct ocfs2_lockres_flag_callback _fcb, *fcb = &_fcb;
+	struct ocfs2_lockres_flag_callback sync_fcb, *fcb;
 	struct ocfs2_status_completion sc;
 	enum dlm_status status;
 	int ret;
 	int catch_signals = 1;
+	int sync = 1;
 
 	mlog_entry_void();
 
@@ -947,7 +941,19 @@
 		fcb->fc_cb = cb;
 		fcb->fc_data = cb_data;
 		fcb->fc_free_once_called = 1;
+
+		/* A callback passed in means we'll assume async
+		 * behavior - no waiting on dlm operations will be
+		 * done here and the allocated fcb will call the
+		 * callback when done. */
+		sync = 0;
 	} else {
+		/* No callback passed which means the caller wants
+		 * synchronous behavior - we avoid kmalloc and use a
+		 * stack allocated fcb for this. The status completion
+		 * helpers defined above come in handy here. */
+		fcb = &sync_fcb;
+
 		init_completion(&sc.sc_complete);
 		fcb->fc_cb = ocfs2_status_completion_cb;
 		fcb->fc_data = (unsigned long)≻
@@ -1053,15 +1059,25 @@
 unlock:
 	spin_unlock(&lockres->l_lock);
 out:
-	if (ret == -EIOCBQUEUED && fcb->fc_cb == ocfs2_status_completion_cb) {
+	/* Non-async callers will always wait here for dlm operations
+	 * to complete. We must be careful to re-initialize the
+	 * completion before looping back. */
+	if (ret == -EIOCBQUEUED && sync) {
 		wait_for_completion(&sc.sc_complete);
 		ret = sc.sc_status;
-		if (ret == 0)
+		if (ret == 0) {
+			INIT_COMPLETION(sc.sc_complete);
 			goto again;
+		}
 	}
 
-	if (ret && fcb != NULL && fcb != &_fcb)
+	/* Only free the async fcb on error. */
+	if (ret && ret != -EIOCBQUEUED && !sync) {
+		mlog_bug_on_msg(!list_empty(&fcb->fc_lockres_item),
+				"Lockres %s, freeing flag callback in use\n",
+				lockres->l_name);
 		kfree(fcb);
+	}
 
 	mlog_exit(ret);
 	return ret;



More information about the Ocfs2-commits mailing list