[SSI] openssi/kernel/cluster/ssi/vproc dvp_init.c, 1.17, 1.18 nsc_initproc.c, 1.24, 1.25

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

Modified Files:
      Tag: OPENSSI-FC
	dvp_init.c nsc_initproc.c 
Log Message:
- Fix nsc_nodelist struct memory leak in initproc_failover(). CLMS
  architecture expects key_service_info->fail() callback function to
  clean up nsc_nodelist struct pointed to in callback function
  argument.
- Prevent needless vproc_alloc() when raced with another
  VPROC_LOCATE_PID() thread. (#ifdef VPROC_RCU_LIST)


Index: nsc_initproc.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/nsc_initproc.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- nsc_initproc.c	27 Oct 2009 03:18:30 -0000	1.24
+++ nsc_initproc.c	2 Feb 2010 04:32:42 -0000	1.25
@@ -290,6 +290,8 @@
 {
 	int error;
 
+	NSC_NODELIST_FREE(nodelist);
+
 	/*
 	 * We initialize the init_node value now, rather than wait for
 	 * initproc_server_ready() to be called.  This avoids a deadlock

Index: dvp_init.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/dvp_init.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- dvp_init.c	27 Oct 2009 03:18:29 -0000	1.17
+++ dvp_init.c	2 Feb 2010 04:32:42 -0000	1.18
@@ -138,14 +138,14 @@
 	int	flags)
 {
 	register struct vproc *vp;
-	struct vproc *nvp = NULL;
 #ifndef VPROC_HASH_LIST
 	struct vproc *w;
 	int hashidx;
 #else
 #ifdef VPROC_RCU_LIST
-	static DECLARE_MUTEX(mutex);
+static DECLARE_MUTEX(mutex);
 #else
+	struct vproc *nvp = NULL;
 	int exlock = 0;
 #endif
 #endif
@@ -190,11 +190,12 @@
 		 * for all its generated pids.
 		 */
 		if (!(flags & LVP_NOFAIL) &&
-		     ((flags & LVP_ORIGIN) || PID_IS_AT_ORIGIN(pid))) {
-			/* vp = NULL; */
-			goto out;
-		}
+		     ((flags & LVP_ORIGIN) || PID_IS_AT_ORIGIN(pid)))
+			return NULL;
 
+#ifdef VPROC_RCU_LIST
+		down(&mutex);
+#else
 		/*
 		 * Since this is not the origin node of the pid, the process
 		 * could have migrated to a different node.  We create a vproc
@@ -204,45 +205,51 @@
 		if ((nvp = vproc_alloc()) == NULL) {
 			printk("locate_vproc_pid(): "
 			       "vproc_alloc() failure\n");
-			/* vp = NULL; */
-			goto out;
+			return NULL;
 		}
 
-#ifdef VPROC_RCU_LIST
-		down(&mutex);
-#else
 		if (!(flags & LVP_NOLOCK))
 			VPROC_LIST_LOCK();
-#endif
+#endif /* !VPROC_RCU_LIST */
+
 		/*
 		 * Make sure here that during the last vproc_alloc()
 		 * call, nobody has created a new vproc for this pid.
 		 */
 		vp = VPROCPTR_NOLOCK(pid);
 		if (vp == NULL) {
+#ifdef VPROC_RCU_LIST
+			if ((vp = vproc_alloc()) == NULL) {
+				up(&mutex);
+				printk(KERN_ERR "%s: vproc_alloc() failure\n",
+						__FUNCTION__);
+				return NULL;
+			}
+#else
 			vp = nvp;
+#endif
 
 			/*
 			 * Put the vproc on the vproc hash chain.
 			 */
 			vp->vp_pid = pid;
-#ifdef VPROC_HASH_LIST
 #ifdef VPROC_RCU_LIST
 			VPROC_LIST_LOCK();
 			list_add_rcu(&vp->vp_list, &vproc_hash[VPROCPIDHASH(pid)]);
 			VPROC_LIST_UNLOCK();
 #else
+#ifdef VPROC_HASH_LIST
 			list_add(&vp->vp_list, &vproc_hash[VPROCPIDHASH(pid)]);
-#endif
-#else /* !VPROC_HASH_LIST */
+#else
 			w = vproc_hash[hashidx = VPROCPIDHASH(pid)];
 			vp->vp_hashbwd = NULL;
 			vp->vp_hashfwd = w;
 			vproc_hash[hashidx] = vp;
 			if (w)
 				w->vp_hashbwd = vp;
-#endif
+#endif /* !VPROC_HASH_LIST */
 			nvp = NULL;
+#endif /* !VPROC_RCU_LIST */
 		}
 #ifdef VPROC_RCU_LIST
 		up(&mutex);
@@ -263,14 +270,15 @@
 	vproc_db4(vp, "LOCATE HOLD", str, 0);
 #endif
 
+#ifndef VPROC_RCU_LIST
 	/*
 	 * If we ended up allocating a new vproc but not using it,
 	 * it's now safe to de_allocate it (now that the lists are unlocked).
 	 */
 	if (nvp != NULL)
 		free_vproc(nvp);
+#endif
 
-out:
 	return(vp);
 }
 


------------------------------------------------------------------------------
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.