[SSI] openssi/kernel/cluster/ssi/token msgsup.c,1.9,1.10

Roger Tsang <[email protected]>
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/token
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv14589/cluster/ssi/token

Modified Files:
      Tag: OPENSSI-FC
	msgsup.c 
Log Message:
* CFS:
- Disable sharing mode detection flags. They were never used.

* CFS Token Architecture (#ifdef RCU_MSGSUP_HASH):
- In process_msgs() function 
  - Fix did not handle -EREMOTE from TRANSPORT(); error was discarded
    and token never got to server.
  - Remove "goto" statements.
- cfstok_send() optimize away RPC if server is down; just return
  -EREMOTE.


Index: msgsup.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/token/msgsup.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- msgsup.c	27 Oct 2009 03:18:29 -0000	1.9
+++ msgsup.c	2 Feb 2010 04:31:45 -0000	1.10
@@ -127,7 +127,7 @@
 	long id;
 #endif
 #ifdef RCU_MSGSUP_HASH
-	int in_process_msgs; /* non-zero: being processed by process_msgs() */
+	unsigned int in_process_msgs; /* non-zero: in process_msgs() */
 #endif
 	object_t obj;
 	int op;
@@ -491,14 +491,68 @@
 process_msgs(int force)
 {
 	struct msg *save;
+#ifdef RCU_MSGSUP
 #ifdef RCU_MSGSUP_HASH
 	unsigned long hashval = MSG_HASH;
+#ifdef DEBUG
 	int recurse = FALSE;
-#else
+#endif
+	int error;
+
+	for (;;) {
+		error = -ENOENT;
+		rcu_read_lock();
+		list_for_each_entry_rcu(save,
+					&msgsup_hashtable[hashval], msg_list) {
+			if (save->id != NSC_UNIQUE_ID)
+				continue;
+			/* Linux: No race because NSC_UNIQUE_ID == current */
+			if (!save->in_process_msgs) {
+				save->in_process_msgs = 1;
+				error = 0;
+				break;
+			}
+			/* Called from process_msgs() path. */
+			if (!force)
+				break; /* Skip recursive process_msgs() */
+#ifdef DEBUG
+			WARN_ON(save->in_process_msgs++ > 16);
+			recurse = TRUE;
+#endif
+			continue;
+		}
+		rcu_read_unlock();
+		if (error)
+			return;
+#ifdef DEBUG
+		if (recurse)
+			printk(KERN_WARNING
+			    "%s: forced recursive processing\n", __FUNCTION__);
+#endif
+
+		error = TRANSPORT(&save->obj)(&save->obj, save->seq, save->op,
+				save->oldmode, save->newmode, save->agent,
+				save->start, save->len);
+		if (error == -EREMOTE) {
+			save->in_process_msgs = 0;
+			idelay(HZ);
+			continue;
+		}
+		SSI_ASSERT(!error);
+
+		/* Remove from list only after successful TRANSPORT()
+		 * so that process_msgs() can detect recursive processing.
+		 */
+		MSG_LOCK(msg_lock);
+		list_del_rcu(&save->msg_list);
+		MSG_UNLOCK(msg_lock);
+
+		call_rcu(&save->msg_rcu, msgsup_free);
+	}
+#else /* RCU_MSGSUP_HASH */
 	int recurse;
 
 	/* PERF: Optimize NOOP case */
-#ifdef RCU_MSGSUP
 	rcu_read_lock();
 	list_for_each_entry_rcu(save, &msgsup_head, msg_list) {
 		if (save->id == NSC_UNIQUE_ID)
@@ -512,70 +566,14 @@
 	if (recurse) {
 		if (!force)
 			return;
-#else /* !RCU_MSGSUP */
-	if (msgsup_head == NULL)
-		return;
-
-	MSG_LOCK(msg_lock);
-
-	recurse = FALSE;
-	if (msgsup_findid(NSC_UNIQUE_ID)) {
-		if (!force) {
-			MSG_UNLOCK(msg_lock);
-			return;
-		}
-
-		recurse = TRUE;
-#endif /* !RCU_MSGSUP */
 #ifdef DEBUG
 		printk(KERN_WARNING
 		    "process_msgs: forced recursive processing\n");
 #endif
 	} else
 		msgsup_addid(NSC_UNIQUE_ID);
-#endif /* !RCU_MSGSUP_HASH */
 
 restart:
-#ifdef RCU_MSGSUP
-#ifdef RCU_MSGSUP_HASH
-	rcu_read_lock();
-	list_for_each_entry_rcu(save, &msgsup_hashtable[hashval], msg_list) {
-		if (save->id != NSC_UNIQUE_ID)
-			continue;
-		/* SSI: No race. NSC_UNIQUE_ID == current */
-		if (save->in_process_msgs) {
-			if (!recurse) {
-				if (!force)
-					break;
-				WARN_ON(save->in_process_msgs++ > 16);
-				recurse = TRUE;
-			}
-			/* already being processed */
-			continue;
-		}
-		save->in_process_msgs = 1;
-		rcu_read_unlock();
-
-#ifdef DEBUG
-		if (recurse)
-			printk(KERN_WARNING
-			    "%s: forced recursive processing\n", __FUNCTION__);
-#endif
-
-		TRANSPORT((&(save->obj)))(&(save->obj), save->seq,
-			save->op, save->oldmode, save->newmode, save->agent,
-			save->start, save->len);
-
-		/* Only remove from list after recursive processing. */
-		MSG_LOCK(msg_lock);
-		list_del_rcu(&save->msg_list);
-		MSG_UNLOCK(msg_lock);
-
-		call_rcu(&save->msg_rcu, msgsup_free);
-		goto restart;
-	}
-	rcu_read_unlock();
-#else /* !RCU_MSGSUP_HASH */
 	rcu_read_lock();
 	list_for_each_entry_rcu(save, &msgsup_head, msg_list) {
 		if (save->id != NSC_UNIQUE_ID)
@@ -606,7 +604,31 @@
 	}
 	rcu_read_unlock();
 #endif /* !RCU_MSGSUP_HASH */
-#else /* !RCU_MSGSUP */
+#else /* RCU_MSGSUP */
+	int recurse;
+
+	/* PERF: Optimize NOOP case */
+	if (msgsup_head == NULL)
+		return;
+
+	MSG_LOCK(msg_lock);
+
+	recurse = FALSE;
+	if (msgsup_findid(NSC_UNIQUE_ID)) {
+		if (!force) {
+			MSG_UNLOCK(msg_lock);
+			return;
+		}
+
+		recurse = TRUE;
+#ifdef DEBUG
+		printk(KERN_WARNING
+		    "process_msgs: forced recursive processing\n");
+#endif
+	} else
+		msgsup_addid(NSC_UNIQUE_ID);
+
+restart:
 	for (save = msgsup_head ; save ; save = save->next) {
 
 		if (save->id != NSC_UNIQUE_ID) {


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.