[Ocfs2-commits] rev 753 - trunk/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Mar 3 19:12:47 CST 2004


Author: mfasheh
Date: 2004-03-03 19:12:45 -0600 (Wed, 03 Mar 2004)
New Revision: 753

Modified:
   trunk/src/nm.c
Log:
* Take inode->i_sem if we can in process_vote. For now we only really hold it for DELETE_RENAME votes.


Modified: trunk/src/nm.c
===================================================================
--- trunk/src/nm.c	2004-03-03 23:33:37 UTC (rev 752)
+++ trunk/src/nm.c	2004-03-04 01:12:45 UTC (rev 753)
@@ -741,6 +741,7 @@
 	bool disk_vote = (ctxt->request_method == DISK_VOTE);
 	bool comm_vote = (ctxt->request_method == COMM_VOTE);
 	bool have_trans_lock = false;
+	bool have_i_sem = false;
 	ocfs_publish *publish = (disk_vote ? ctxt->u.publish : NULL);
 	ocfs_dlm_msg *dlm_msg = (comm_vote ? ctxt->u.dlm_msg : NULL);
 	__u32 node_num = ctxt->node_num;
@@ -783,6 +784,14 @@
 	}
 
 	inode = ocfs_inode_hash_lookup(osb, lock_id, false);
+	if (inode) {
+		/* we only need i_sem for some of the operations
+		 * below, but due to lock ordering, we want to take it
+		 * before we acquire_lockres. */
+		down(&inode->i_sem);
+		have_i_sem = true;
+	}
+
 	status = ocfs_find_update_res (osb, lock_id, &lockres, NULL, NULL,
 					(OCFS_NM_HEARTBEAT_TIME/2), inode);
 	if (status < 0) {
@@ -809,6 +818,13 @@
 	       process_vote_strings[vote_type], disk_vote ? "disk vote" : "net vote" );
 #endif
 
+	if (inode && (vote_type != DELETE_RENAME)) {
+		/* Ok, for all operations where we no longer need
+		 * isem, drop it now. */
+		up(&inode->i_sem);
+		have_i_sem = false;
+	}
+
 	if (disk_vote) {
 		/* Zero out the vote for everybody, if any already set and hung */
 		vote = (ocfs_vote *) OCFS_BH_GET_DATA_WRITE(vote_bh); /* write */
@@ -930,10 +946,17 @@
 #else
 						fsync_inode_buffers (inode);
 #endif
+					up(&inode->i_sem);
+					have_i_sem = false;
 				}
 				break;
 			}
 
+			if (inode) {
+				up(&inode->i_sem);
+				have_i_sem = false;
+			}
+
 			/* Set the always update master on open flag */
 			lockres->lock_state |= FLAG_ALWAYS_UPDATE_OPEN;
 			lockres->last_upd_seq_num = seq_num;
@@ -1239,18 +1262,19 @@
 	if (status < 0)
 		LOG_ERROR_STATUS (status);
 
-	if (inode) {
-		if (inc_inode_seq)
-			ocfs_inc_inode_seq(osb, inode, true);
-		iput(inode);
-	}
-
 	if (lockres) {
 		ocfs_release_lockres (lockres);
 		ocfs_put_lockres(lockres);
 	}
 
 leave:
+	if (inode) {
+		if (inc_inode_seq)
+			ocfs_inc_inode_seq(osb, inode, true);
+		if (have_i_sem)
+			up(&inode->i_sem);
+		iput(inode);
+	}
 
 	LOG_EXIT_STATUS (status);
 	return status;



More information about the Ocfs2-commits mailing list