[Ocfs2-commits] mfasheh commits r1380 - trunk/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Aug 24 18:56:19 CDT 2004


Author: mfasheh
Date: 2004-08-24 18:56:18 -0500 (Tue, 24 Aug 2004)
New Revision: 1380

Modified:
   trunk/src/dlm.c
   trunk/src/ocfs.h
   trunk/src/vote.c
Log:
* In dlm.c, check for signals before calling new_lock_function, rather than after.

* In vote.c do an uninterruptible wait instead of breaking on signals.

The old behavior was causing us to abort on signals, but after we'd
sent the lock request to the other nodes where it would've been
processed, resulting in lock state being inconsistent among the
nodes. This should fix bugzilla bug 128 for the case that you ctrl-c a
process when it's in voting.



Modified: trunk/src/dlm.c
===================================================================
--- trunk/src/dlm.c	2004-08-24 21:54:42 UTC (rev 1379)
+++ trunk/src/dlm.c	2004-08-24 23:56:18 UTC (rev 1380)
@@ -450,6 +450,14 @@
 		if (ocfs_inode_is_new(osb, inode))
 			flags |= FLAG_FAST_PATH_LOCK;
 
+		if (ocfs_task_interruptible ()) {
+			ocfs_release_lockres (lockres);
+			LOG_TRACE_ARGS("interrupted... inode = %llu\n",
+				       OCFS_I(inode)->ip_blkno);
+			status = -EINTR;
+			goto bail;
+		}
+
 		status = new_lock_function(osb, lockres->lock_type, 
 					   flags, NULL, &disk_vote, inode);
 		if (status < 0) {
@@ -457,12 +465,6 @@
 				LOG_ERROR_STATUS (status);
 			ocfs_release_lockres (lockres); // ocfs_file_open ocfs_symlink
 			if (status == -EAGAIN || status == -ETIMEDOUT) {
-				if (ocfs_task_interruptible ()) {
-					LOG_TRACE_ARGS("interrupted... lockid=%llu\n",
-					OCFS_I(inode)->ip_blkno << inode->i_sb->s_blocksize_bits);
-					status = -EINTR;
-					goto bail;
-				}
 				ocfs_sleep (50);
 				status = -EAGAIN;
 				continue;
@@ -682,6 +684,13 @@
 		}
 	}
 
+	if (ocfs_task_interruptible ()) {
+		ocfs_release_lockres (lockres);
+		LOG_TRACE_ARGS("interrupted... inode %llu\n",
+			       OCFS_I(inode)->ip_blkno);
+		status = -EINTR;
+		goto finally;
+	}
 	status = new_lock_function(osb, lock_type, flags|extra_lock_flags, 
 				   *b, &disk_vote, inode);
 	if (status < 0) {
@@ -693,13 +702,6 @@
 					       "retrying...\n", 
 					       OCFS_I(inode)->ip_blkno, 
 					       lock_id);
-
-			if (ocfs_task_interruptible ()) {
-				LOG_TRACE_ARGS("interrupted... lockid=%llu\n",
-					OCFS_I(inode)->ip_blkno << inode->i_sb->s_blocksize_bits);
-				status = -EINTR;
-				goto finally;
-			}
 			ocfs_sleep (50);
 			ocfs_acquire_lockres(lockres, 0);
 			/* if we're going to jump back up, we want to update
@@ -794,10 +796,6 @@
 				ocfs_sleep(200);
 				ocfs_acquire_lockres(lockres, 0);
 				continue;
-			}
-			else if (status == -EINTR && ocfs_task_interruptible ()) {
-				LOG_ERROR_STR("interrupted!\n");
-				goto finally;
 			} else 
 				LOG_ERROR_STATUS (status);
 		}
@@ -1050,14 +1048,6 @@
 		lockres->readonly_node = lockres->master_node_num;
 	}
 
-	if (status == -EAGAIN) {
-		if (ocfs_task_interruptible ()) {
-			LOG_TRACE_ARGS("interrupted.... lockid=%llu\n",
-				OCFS_I(inode)->ip_blkno << inode->i_sb->s_blocksize_bits);
-			status = -EINTR;
-		}
-	}
-
 	LOG_EXIT_STATUS (status);
 	return status;
 }

Modified: trunk/src/ocfs.h
===================================================================
--- trunk/src/ocfs.h	2004-08-24 21:54:42 UTC (rev 1379)
+++ trunk/src/ocfs.h	2004-08-24 23:56:18 UTC (rev 1380)
@@ -944,6 +944,44 @@
 								\
 } while(0)
 
+#define __ocfs_wait_uninterruptible(wq, condition, timeo, ret)	\
+do {								\
+	ocfs_timeout __to;					\
+								\
+	DECLARE_WAITQUEUE(__wait, current);			\
+	DECLARE_WAITQUEUE(__to_wait, current);			\
+								\
+	ocfs_init_timeout(&__to);				\
+								\
+	if (timeo) {						\
+		ocfs_set_timeout(&__to, timeo);			\
+		if (__to.timed_out) {				\
+			ocfs_clear_timeout(&__to);		\
+		}						\
+	}							\
+								\
+	add_wait_queue(&wq, &__wait);				\
+	add_wait_queue(&__to.wait, &__to_wait);			\
+	do {							\
+		ret = 0;					\
+		set_current_state(TASK_UNINTERRUPTIBLE);	\
+		if (condition)					\
+			break;					\
+		ret = -ETIMEDOUT;				\
+		if (__to.timed_out)				\
+			break;					\
+		schedule();					\
+	} while (1);						\
+								\
+	set_current_state(TASK_RUNNING);			\
+	remove_wait_queue(&wq, &__wait);			\
+	remove_wait_queue(&__to.wait, &__to_wait);		\
+								\
+	if (timeo)						\
+		ocfs_clear_timeout(&__to);			\
+								\
+} while(0)
+
 #define ocfs_wait(wq, condition, timeout)			\
 ({								\
 	int __ret = 0;						\
@@ -952,6 +990,13 @@
 	__ret;							\
 })
 
+#define ocfs_wait_uninterruptible(wq, condition, timeout)		      \
+({									      \
+	int __ret = 0;							      \
+	if (!(condition))						      \
+		__ocfs_wait_uninterruptible(wq, condition, timeout, __ret);   \
+	__ret;								      \
+})
 
 static inline unsigned long ino_from_blkno(struct super_block *sb,
 					   u64 blkno)

Modified: trunk/src/vote.c
===================================================================
--- trunk/src/vote.c	2004-08-24 21:54:42 UTC (rev 1379)
+++ trunk/src/vote.c	2004-08-24 23:56:18 UTC (rev 1380)
@@ -891,7 +891,7 @@
 	spin_lock (&obj->lock);
 	obj->vote_state = VOTE_OBJ_STATE_SENT;
 	spin_unlock (&obj->lock);
-	status = ocfs_wait (obj->voted_event,
+	status = ocfs_wait_uninterruptible(obj->voted_event,
 			    atomic_read (&obj->voted_event_woken), 
 			    OCFS_DLM_NET_TIMEOUT);
 



More information about the Ocfs2-commits mailing list