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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Feb 22 21:12:10 CST 2005


Author: mfasheh
Signed-off-by: manish
Date: 2005-02-22 21:12:09 -0600 (Tue, 22 Feb 2005)
New Revision: 1907

Modified:
   trunk/fs/ocfs2/Makefile
   trunk/fs/ocfs2/ocfs_log.h
   trunk/fs/ocfs2/vote.c
Log:
* add a helper function to tell us whether a vote request is valid 

* properly filter out an invalid vote request before processing any more

* don't error a vote request if we fail to lookup the inode

* get rid of LOG_TRACE_PROCESS_VOTE

* get rid of VERBOSE_PROCESS_VOTE

Signed-off-by: manish



Modified: trunk/fs/ocfs2/Makefile
===================================================================
--- trunk/fs/ocfs2/Makefile	2005-02-23 02:37:23 UTC (rev 1906)
+++ trunk/fs/ocfs2/Makefile	2005-02-23 03:12:09 UTC (rev 1907)
@@ -34,7 +34,6 @@
 EXTRA_CFLAGS += -DVERBOSE_BH_JBD_TRACE
 EXTRA_CFLAGS += -DVERBOSE_LOCKING_TRACE
 EXTRA_CFLAGS += -DVERBOSE_BH_SEQNUM_TRACE
-EXTRA_CFLAGS += -DVERBOSE_PROCESS_VOTE
 EXTRA_CFLAGS += -DVERBOSE_COMMIT_THREAD
 endif
 

Modified: trunk/fs/ocfs2/ocfs_log.h
===================================================================
--- trunk/fs/ocfs2/ocfs_log.h	2005-02-23 02:37:23 UTC (rev 1906)
+++ trunk/fs/ocfs2/ocfs_log.h	2005-02-23 03:12:09 UTC (rev 1907)
@@ -352,12 +352,6 @@
 #define LOG_TRACE_STR(str)     LOG_TRACE_ARGS("%s\n", str)
 #define LOG_TRACE_STATUS(val)  LOG_TRACE_ARGS("%d\n", val);
 
-#ifdef VERBOSE_PROCESS_VOTE
-#define LOG_TRACE_PROCESS_VOTE(fmt, arg...) printk("process_vote: "fmt, ## arg)
-#else
-#define LOG_TRACE_PROCESS_VOTE  LOG_TRACE_ARGS
-#endif
-
 #endif				/* TRACE */
 
 

Modified: trunk/fs/ocfs2/vote.c
===================================================================
--- trunk/fs/ocfs2/vote.c	2005-02-23 02:37:23 UTC (rev 1906)
+++ trunk/fs/ocfs2/vote.c	2005-02-23 03:12:09 UTC (rev 1907)
@@ -91,9 +91,20 @@
 	OCFS2_VOTE_REQ_UNLINK,
 	OCFS2_VOTE_REQ_RENAME,
 	OCFS2_VOTE_REQ_MOUNT,
-	OCFS2_VOTE_REQ_UMOUNT
+	OCFS2_VOTE_REQ_UMOUNT,
+	OCFS2_VOTE_REQ_LAST
 };
 
+static inline int ocfs2_is_valid_vote_request(int request)
+{
+	int i;
+
+	for(i = OCFS2_VOTE_REQ_INVALID + 1; i < OCFS2_VOTE_REQ_LAST; i++)
+		if (i == request)
+			return 1;
+	return 0;
+}
+
 typedef struct _ocfs2_net_wait_ctxt {
 	struct list_head   n_list;
 	u32                n_response_id;
@@ -146,8 +157,8 @@
 	spin_lock(&OCFS_I(inode)->ip_lock);
 	/* vote no if the file is still open. */
 	if (OCFS_I(inode)->ip_open_cnt > 0) {
-		LOG_TRACE_PROCESS_VOTE("open count = %u\n", 
-		       OCFS_I(inode)->ip_open_cnt);
+		LOG_TRACE_ARGS("open count = %u\n", 
+			       OCFS_I(inode)->ip_open_cnt);
 		spin_unlock(&OCFS_I(inode)->ip_lock);
 		goto done;
 	}
@@ -157,8 +168,7 @@
 	 * it? We want to make sure the inode is removed completely as
 	 * a result of the iput in process_vote. */
 	if (S_ISDIR(inode->i_mode) && (atomic_read(&inode->i_count) != 1)) {
-		LOG_TRACE_PROCESS_VOTE("i_count = %u\n", 
-		       atomic_read(&inode->i_count));
+		LOG_TRACE_ARGS("i_count = %u\n", atomic_read(&inode->i_count));
 		goto done;
 	}
 
@@ -225,6 +235,13 @@
 		       "generation = %u, node_num = %u\n", request, blkno,
 		       generation, node_num);
 
+	if (!ocfs2_is_valid_vote_request(request)) {
+		LOG_ERROR_ARGS("Invalid vote request %d from node %u\n",
+			       request, node_num);
+		vote_response = -EINVAL;
+		goto respond;
+	}
+
 	vote_response = 0;
 
 	switch (request) {
@@ -248,10 +265,14 @@
 
 	/* If we get here, then the request is against an inode. */
 	inode = ocfs_ilookup(osb, blkno);
-	if (!inode) {
-		vote_response = -EINVAL;
+
+	/* Not finding the inode is perfectly valid - it means we're
+	 * not interested in what the other node is about to do to it
+	 * so in those cases we automatically respond with an
+	 * affirmative. Cluster locking ensures that we won't race
+	 * interest in the inode with this vote request. */
+	if (!inode)
 		goto respond;
-	}
 
 	OCFS_ASSERT(inode->i_generation == generation);
 
@@ -266,8 +287,8 @@
 		ocfs2_process_dentry_request(inode, rename);
 		break;
 	default:
-		LOG_ERROR_ARGS("node %u, invalid request: %u\n", node_num,
-			       request);
+		LOG_ERROR_ARGS("node %u, invalid request: %u\n",
+			       node_num, request);
 		vote_response = -EINVAL;
 	}
 
@@ -581,11 +602,7 @@
 	ocfs2_vote_msg *request = NULL;
 	ocfs2_msg_hdr *hdr;
 
-	OCFS_ASSERT(type == OCFS2_VOTE_REQ_DELETE ||
-		    type == OCFS2_VOTE_REQ_UNLINK ||
-		    type == OCFS2_VOTE_REQ_RENAME ||
-		    type == OCFS2_VOTE_REQ_UMOUNT ||
-		    type == OCFS2_VOTE_REQ_MOUNT);
+	OCFS_ASSERT(ocfs2_is_valid_vote_request(type));
 
 	request = kmalloc(sizeof(*request), GFP_KERNEL);
 	if (!request) {



More information about the Ocfs2-commits mailing list