[SSI] openssi/kernel/cluster/ssi/ipc ipcshm_svr.c, 1.20, 1.21 namesvr_func.c, 1.19, 1.20

Roger Tsang <[email protected]> Fri, 05 Mar 2010 06:30:23 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv9483/kernel/cluster/ssi/ipc

Modified Files:
      Tag: OPENSSI-FC
	ipcshm_svr.c namesvr_func.c 
Log Message:
IPC:
- Fix partially initialized shmid_kernel_svr.shm_perm structure.
- Fix ipc/sem.c:exit_sem() GCC warning: ISO C90 forbids mixed declarations and
  code.
- Split ssi_shm_setup() into separate functions ssi_shm_setup_client/new() to
  reduce stack usage in some paths.

IPC (#ifdef IPC_SHM_RACE_FIX):
- Fix shm_svr_rmid() called without spinlock for the ID.
- Fix race deferencing invalid struct shmid_kernel, shmid_kernel_svr.
- Enable lockfree shmid_kernel_svr IPC id lookup. Use ipc_rcu_alloc and IPC
  reference counting.
- Reduce contention. Avoid the ipc_ids mutex. Use per IPC id spinlock.
- Fix cli_ipcname_findid() race with cli_ipcname_getid() could overwrite
  existing IPC segment.
- Fix non-critical section under shm_ids.sem lock in shm_create_cli_entry().
- Prevent re-acquire shm_ids.sem in shm_destroy() path. ripc_shm_rmid() no
  longer returns with shm_ids.sem unlocked.
- Remove contention in shmem_svr_lookup(); no longer acquire shm_ids_svr.sem.
- Fix do_shmat() possible hang calling dput() while holding spinlock.
- Fix cfs_shm_node_mnts[] race.
- Fix inode leak in ssi_shm_setup() error path when do_shm_register() fails.

IPC (#ifdef IPC_SHM_LOCK_DEST_FIX):
- Fix [ ssic-linux-Bug 2838006 ] Corrupt SHM_LOCK_DEST flag.
- Refactor ipc_shm_nodedown() for SHM_LOCK_DEST flag. Use SHM_LOCK_DEST flag.
- Fix ripc_drop_locks() error path dereferencing NULL pointer in
  ipc_drop_locks().

IPC (#ifdef CFS_IPCSHM_DENTRY):
- ssi_shm_setup_client() use d_instantiate_unique() to prevent duplicate
  entries.

 cluster/ssi/cfs/cfs_ipcshm.c     |  422 ++++++++++++++++++-----------
 cluster/ssi/cfs/cfsproc.c        |    6 
 cluster/ssi/ipc/ipcshm_svr.c     |  280 +++++++++++--------
 cluster/ssi/ipc/namesvr_func.c   |   12 
 cluster/ssi/vproc/reopen.c       |   30 +-
 include/cluster/ssi/cfs/cfs_fs.h |   16 +
 include/cluster/ssi/ipc/shm.h    |   13 
 include/linux/shm.h              |    7 
 ipc/msg.c                        |    6 
 ipc/sem.c                        |   17 -
 ipc/shm.c                        |  450 ++++++++++++++++++++-----------
 ipc/util.c                       |   18 -
 ipc/util.h                       |    5 
 mm/shmem.c                       |    9 
 14 files changed, 845 insertions(+), 446 deletions(-)


Index: ipcshm_svr.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/ipcshm_svr.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- ipcshm_svr.c	2 Feb 2010 05:19:30 -0000	1.20
+++ ipcshm_svr.c	5 Mar 2010 06:30:21 -0000	1.21
@@ -48,19 +48,21 @@
 #define shm_flags	shm_perm.mode
 
 extern struct super_block *cfs_shm_sb;
+extern int cli_ipcname_rmid(int, global_id_t);
+
 extern int shm_tot;
 extern struct ipc_ids shm_ids;
 extern struct ipc_ids shm_ids_svr;
-
-extern int cli_ipcname_rmid(int, global_id_t);
 extern void ipc_rcu_putref(void *ptr);
 extern void ipc_drop_locks(int, struct kern_ipc_perm *, struct ipc_ids *, int);
-#ifdef IPC_SHM_LOCK_DEST_FIX
-void ipc_lock_dest_id(struct ipc_ids *ids, int id);
-#endif
 extern struct kern_ipc_perm * ipc_get_locks(int, struct ipc_ids *, int);
+#ifdef IPC_SHM_RACE_FIX
+extern void ipc_rcu_getref(void *ptr);
+extern void ipc_lock_by_ptr(struct kern_ipc_perm *);
+#endif
 extern int shm_get_segsize(struct shmid_kernel *);
 extern int shm_get_cpid(struct shmid_kernel *);
+
 static int do_ssi_shm_noclients(int, clusternode_t, int);
 
 int
@@ -177,6 +179,7 @@
 	}
 
 	if (dest) {
+		/* Do not find it any more */
 		shp->shm_perm.key = IPC_PRIVATE;
 		shp->shm_flags |= SHM_DEST;
 	}
@@ -185,18 +188,15 @@
 	if (dest != 2)
 		ipc_drop_locks(shmid, (struct kern_ipc_perm *)shp, &shm_ids, 1);
 	else {
-#ifdef IPC_SHM_LOCK_DEST_FIX
-		ipc_lock_dest_id(&shm_ids, shmid);
-#else
 		shp->shm_flags |= SHM_LOCK_DEST;
-#endif
 		ipc_drop_locks(shmid, (struct kern_ipc_perm *)shp, &shm_ids, 0);
-		/* shm_ids.sem held */
+		/* shm_ids.sem still held */
 	}
 		
         return 0;
 }
 
+#ifdef SSI_NOTUSED
 void
 shm_set_destroy(int shmid)
 {
@@ -207,6 +207,7 @@
         	return;
 	shp->shm_flags |= SHM_DEST;
 }
+#endif
 
 int
 ripc_shm_noclients(
@@ -219,7 +220,11 @@
 	return 0;
 }
 
-
+/*
+ * Locking:
+ * shm_ids.sem	ssi_shm_cleanup()
+ *		do_ssi_shm_noclients(..., this_node, 2)
+ */
 int
 do_ssi_shm_noclients(int id, clusternode_t svrnode, int dest)
 {
@@ -228,10 +233,9 @@
 	nsc_nodelist_t *nl;
 #endif
 	clusternode_t node;
-	int ret;
 	nsc_nlcookie_t cookie;
+	int ret, cnt;
 	int nattch = 0;
-	int cnt;
 	int rval = 0;
 	int nm_svr_num = 0;
 
@@ -243,6 +247,9 @@
 			ipc_get_locks(0, &shm_ids, 1);
 			cli_ipcname_rmid(NAME_SERVICE_SHM, id);
 			rval = ripc_shm_rmid(this_node, &rval, id, 1);
+#ifdef IPC_SHM_RACE_FIX
+			ipc_drop_locks(0, NULL, &shm_ids, 1);
+#endif
 		}
 
 		return rval;
@@ -252,31 +259,38 @@
 		ripc_shm_get_nattchs(this_node, &rval, id, &nattch, dest);
 	nm_svr_num = nattch;
 
-try_again:
-	cnt = nm_svr_num;
 #ifdef IPC_SHM_RACE_FIX
-	ipc_get_locks(0, &shm_ids_svr, 1);
-#endif
-	svp = (struct shmid_kernel_svr *)shm_svr_get(id);
+	nl = NSC_NODELIST_ALLOC();
+try_again:
+	if (dest == 2) {
+		WARN_ON(!shm_sem_owned());
+		svp = shm_svr_get(id);
+		if (svp)
+			ipc_lock_by_ptr(&svp->shm_perm);
+	} else
+		svp = shm_svr_lock(id);
+
 	if (!svp) {
-#ifdef IPC_SHM_RACE_FIX
-		ipc_drop_locks(0, NULL, &shm_ids_svr, 1);
-#endif
+		NSC_NODELIST_FREE(nl);
 		return -EIDRM;
 	}
+	memcpy(nl, svp->shm_nodelist, sizeof(*nl));
+	shm_svr_unlock(svp);
 
-#ifdef IPC_SHM_RACE_FIX
-	nl = NSC_NODELIST_COPY(svp->shm_nodelist);
-	ipc_drop_locks(0, NULL, &shm_ids_svr, 1);
-#endif
+	cnt = nm_svr_num;
 	cookie = CLUSTERNODE_INVAL;
-#ifdef IPC_SHM_RACE_FIX
 	while ((node = NSC_NODELIST_GET_NEXT(&cookie, nl))
 							!= CLUSTERNODE_INVAL) {
-#else
+#else /* IPC_SHM_RACE_FIX */
+try_again:
+	cnt = nm_svr_num;
+	svp = (struct shmid_kernel_svr *)shm_svr_get(id);
+	if (!svp)
+		return -EIDRM;
+	cookie = CLUSTERNODE_INVAL;
 	while ((node = NSC_NODELIST_GET_NEXT(&cookie, svp->shm_nodelist))
 							!= CLUSTERNODE_INVAL) {
-#endif
+#endif /* !IPC_SHM_RACE_FIX */
 		if (node == this_node)
 			continue;
 
@@ -284,9 +298,6 @@
 
 		/* if error should get cleaned up by nodedown */
 		if (ret) {
-#ifdef IPC_SHM_RACE_FIX
-			NSC_NODELIST_FREE(nl);
-#endif
 			idelay(HZ);
 			goto try_again;
 		}
@@ -314,11 +325,14 @@
 
 	ret = do_ssi_shm_noclients(id, svrnode, dest);
 
-	ipc_get_locks((lck ? id : 0), &shm_ids, tbl);
+	shp = (struct shmid_kernel *)ipc_get_locks(
+					(lck ? id : 0), &shm_ids, tbl);
+	WARN_ON(lck && !shp);
 
 	return ret;
 }
 
+#ifdef SSI_NOTUSED
 void
 shm_inform_clients(struct shmid_kernel *shp)
 {
@@ -328,23 +342,18 @@
 	nsc_nlcookie_t cookie;
 
 #ifdef IPC_SHM_RACE_FIX
-	ipc_get_locks(0, &shm_ids_svr, 1);
-#endif
+#error not yet
+	svr = shm_svr_lock(shp->id);
+#else
 	svr = (struct shmid_kernel_svr *)shm_svr_get(shp->id);
-	if (!svr) {
-#ifdef IPC_SHM_RACE_FIX
-		ipc_drop_locks(0, NULL, &shm_ids_svr, 1);
 #endif
+	if (!svr)
 		return;
-	}
 
 	/* Tell namesvr that shp is being destroyed */
 
 	/* Tell clients that shp is being destroyed */
 	nl = NSC_NODELIST_COPY(svr->shm_nodelist);
-#ifdef IPC_SHM_RACE_FIX
-	ipc_drop_locks(0, NULL, &shm_ids_svr, 1);
-#endif
 	cookie = CLUSTERNODE_INVAL;
 	while ((node = NSC_NODELIST_GET_NEXT(&cookie, nl))
 							!= CLUSTERNODE_INVAL) {
@@ -357,6 +366,7 @@
 	}
 	NSC_NODELIST_FREE(nl);
 }
+#endif /* SSI_NOTUSED */
 
 int
 ripc_shm_server_mount(
@@ -371,13 +381,14 @@
 
 	*rval = cfs_shm_notify(cfs_shm_sb, clinode, 0);
 #ifdef IPC_SHM_RACE_FIX
-	ipc_get_locks(0, &shm_ids_svr, 1);
-#endif
+	shp = shm_svr_lock(id);
+#else
 	shp = (struct shmid_kernel_svr *)shm_svr_get(id);
+#endif
 	*key = shp->shm_perm.key;
 	*size = shp->shm_segsz;
 #ifdef IPC_SHM_RACE_FIX
-	ipc_drop_locks(0, NULL, &shm_ids_svr, 1);
+	shm_svr_unlock(shp);
 #endif
 	return 0;
 }
@@ -393,15 +404,13 @@
 	struct shmid_kernel_svr *shmp;
 
 #ifdef IPC_SHM_RACE_FIX
-	ipc_get_locks(0, &shm_ids_svr, 1);
+	shmp = shm_svr_lock(id);
 #else
 	ipc_get_locks(0, &shm_ids, 1);
-#endif
 	shmp = (struct shmid_kernel_svr *)shm_svr_get(id);
+#endif
 	if (shmp == NULL) {
-#ifdef IPC_SHM_RACE_FIX
-		ipc_drop_locks(0, NULL, &shm_ids_svr, 1);
-#else
+#ifndef IPC_SHM_RACE_FIX
 		ipc_drop_locks(0, NULL, &shm_ids, 1);
 #endif
 		*rval = -EINVAL;
@@ -410,7 +419,7 @@
 	NSC_NODELIST_SET1(shmp->shm_nodelist, clinode);
 	*size = shmp->shm_segsz;
 #ifdef IPC_SHM_RACE_FIX
-	ipc_drop_locks(0, NULL, &shm_ids_svr, 1);
+	shm_svr_unlock(shmp);
 #else
 	ipc_drop_locks(0, NULL, &shm_ids, 1);
 #endif
@@ -419,7 +428,7 @@
 }
 
 /* Caller must assure shm_ids.sem is held.
- * Returns with shm_ids.sem unheld.
+ * Returns with shm_ids.sem released.
  */
 int
 ripc_shm_rmid(
@@ -429,37 +438,31 @@
 	int 	size)
 {
 	struct shmid_kernel *shp;
-	int sz;
 
 	shp = (struct shmid_kernel *)ipc_get_locks(id, &shm_ids, 0);
 	if (!shp) {
+#ifdef IPC_SHM_RACE_FIX
+		/* Drop the lock acquired during ripc_shm_get_nattchs() */
+		if (ssi_isremote())
+			ipc_drop_locks(0, NULL, &shm_ids, 1);
+#else
 		/* Drop the locks acquired by caller */
 		ipc_drop_locks(0, NULL, &shm_ids, 1);
+#endif
 		*rval = -EIDRM;
 		return 0;
 	}
+	shp->shm_flags &= ~SHM_LOCK_DEST;
 
-	if (size) {
+	BUG_ON(!size);
+	ssi_local_destroy(shp);
 #ifdef IPC_SHM_RACE_FIX
-		sz = (int) i_size_read(shp->shm_file->f_dentry->d_inode);
-#else
-		sz = shp->shm_file->f_dentry->d_inode->i_size;
-#endif
-		shm_tot -= (sz + PAGE_SIZE - 1) >> PAGE_SHIFT;
-	}
-	shm_rmid(id);
-
-#ifdef IPC_SHM_LOCK_DEST_FIX
-	ipc_lock_dest_id(&shm_ids, -1);
+	/* Drop the lock acquired during ripc_shm_get_nattchs() */
+	if (ssi_isremote())
+		ipc_drop_locks(0, NULL, &shm_ids, 1);
 #else
-	shp->shm_flags &= ~SHM_LOCK_DEST;
-#endif
-	/* Drop the locks acquired above */
 	ipc_drop_locks(id, (struct kern_ipc_perm *)shp, &shm_ids, 1);
-
-	fput(shp->shm_file);
-	security_shm_free(shp);
-	ipc_rcu_putref(shp);
+#endif
 	*rval = 0;
 	return 0;
 }
@@ -470,34 +473,43 @@
 	struct shmid_kernel_svr *svp;
 
 #ifdef IPC_SHM_RACE_FIX
-	ipc_get_locks(0, &shm_ids_svr, 1);
-#endif
+	svp = shm_svr_lock(id);
+	if (!svp)
+		return;
+	if (NSC_NODELIST_TEST1(svp->shm_nodelist, node))
+		NSC_NODELIST_CLR1(svp->shm_nodelist, node);
+	shm_svr_unlock(svp);
+#else
 	svp = (struct shmid_kernel_svr *)shm_svr_get(id);
 	if (svp) {
 		if (NSC_NODELIST_TEST1(svp->shm_nodelist, node))
 			NSC_NODELIST_CLR1(svp->shm_nodelist, node);
 	}
-#ifdef IPC_SHM_RACE_FIX
-	ipc_drop_locks(0, NULL, &shm_ids_svr, 1);
-#endif
+#endif /* !IPC_SHM_RACE_FIX */
 }
 
+/*
+ * - Reverse SHM_LOCK_DEST flag.
+ * - Unlock shm_ids.sem held in ripc_shm_get_nattchs().
+ */
+/* Caller holds no IPC locks */
 int
-ripc_drop_locks(
-	clusternode_t node,
-	int *rval,
-	int id)
-
+ripc_drop_locks(clusternode_t node, int *rval, int id)
 {
-	struct shmid_kernel *shp = shm_cli_get(id);
 #ifdef IPC_SHM_LOCK_DEST_FIX
-	if (shp)
-		ipc_lock_dest_id(&shm_ids, -1);
-#else
+	struct shmid_kernel *shp = shm_cli_lock(id);
+	if (!shp) {
+		ipc_drop_locks(0, NULL, &shm_ids, 1);
+		*rval = -EIDRM;
+		return 0;
+	}
+	shp->shm_flags &= ~SHM_LOCK_DEST;
+#else /* IPC_SHM_LOCK_DEST_FIX */
+	struct shmid_kernel *shp = shm_cli_get(id);
 	if (shp)
 		shp->shm_flags &= ~SHM_LOCK_DEST;
-#endif
-	ipc_drop_locks(id, (struct kern_ipc_perm *)shp, &shm_ids, 1); 
+#endif /* !IPC_SHM_LOCK_DEST_FIX */
+	ipc_drop_locks(id, (struct kern_ipc_perm *)shp, &shm_ids, 1);
 	*rval = 0;
 	return 0;
 }
@@ -505,12 +517,23 @@
 void
 abort_rmid(int id)
 {
-	struct shmid_kernel_svr *svp = NULL;
+	struct shmid_kernel_svr *svp;
 	clusternode_t node;
 	nsc_nlcookie_t cookie;
 	nsc_nodelist_t *nl;
 	int ret, rval = 0;
 
+#ifdef IPC_SHM_RACE_FIX
+	nl = NSC_NODELIST_ALLOC();
+
+	svp = shm_svr_lock(id);
+	if (!svp) {
+		NSC_NODELIST_FREE(nl);
+		return;
+	}
+	memcpy(nl, svp->shm_nodelist, sizeof(*nl));
+	shm_svr_unlock(svp);
+#else
 	ipc_get_locks(0, &shm_ids_svr, 1);
 	svp = (struct shmid_kernel_svr *)shm_svr_get(id);
 	if (!svp) {
@@ -520,6 +543,7 @@
 	
 	nl = NSC_NODELIST_COPY(svp->shm_nodelist);
 	ipc_drop_locks(0, (struct kern_ipc_perm *)svp, &shm_ids_svr, 1);
+#endif /* !IPC_SHM_RACE_FIX */
 
 	cookie = CLUSTERNODE_INVAL;
 	while ((node = NSC_NODELIST_GET_NEXT(&cookie, nl))
@@ -528,6 +552,7 @@
 			continue;
 
 		ret = RIPC_DROP_LOCKS(node, &rval, id);
+		(void) rval;
 	}
 	NSC_NODELIST_FREE(nl);
 	return;
@@ -545,13 +570,12 @@
 	return 0;
 }
 
-/* Local path called with shm_ids.sem held */
+/* Called with shp and shm_ids.sem held in shm_destroy() path */
 int
 ssi_shm_cleanup(clusternode_t svrnode, int id, clusternode_t clinode)
 {
-	int ret = 0;
-	int rval;
-	struct shmid_kernel *shp = NULL;
+	struct shmid_kernel *shp;
+	int rval, ret = 0;
 
 	if (svrnode == this_node) {
 		struct shmid_kernel_svr *svp;
@@ -561,12 +585,14 @@
 		int do_locks = (svrnode == clinode);
 
 		if (do_locks) {
-			shp = (struct shmid_kernel *)shm_cli_get(id);
-			ipc_drop_locks(id, (struct kern_ipc_perm *)shp,
-					&shm_ids, 0);
-		}
-		else /* caller is remote */
+			shp = shm_cli_get(id);
+			shm_cli_unlock(shp);
+		} else {
+			/* caller is remote. Called with no locks held */
+			shp = NULL;
 			ipc_get_locks(0, &shm_ids, 1);
+		}
+		/* shm_ids.sem held */
 
 		ret = do_ssi_shm_noclients(id, svrnode, 2);
 		if (ret) {
@@ -574,7 +600,9 @@
 				ipc_drop_locks(0, NULL, &shm_ids, 1);
 
 #ifdef IPC_SHM_DESTROY_FIX
-			/* [ ssic-linux-Bugs-1944781 ] unlocking unlocked lock in ripc_drop_locks. */
+			/* [ ssic-linux-Bugs-1944781 ]
+			 * unlocking unlocked lock in ripc_drop_locks.
+			 */
 			/* -EIDRM ? No. */
 			if (ret > 0)
 #endif
@@ -584,7 +612,7 @@
 			return ((ret < 0) ? ret : -EBUSY);
 		}
 
-		shp = (struct shmid_kernel *)ipc_get_locks(id, &shm_ids, 0);
+		shp = shm_cli_lock(id);
 		svp = (struct shmid_kernel_svr *)shm_svr_get(id);
 		if (!svp || shp->shm_nattch) {
 			ipc_drop_locks(id, (struct kern_ipc_perm *)shp,
@@ -601,27 +629,44 @@
 		 */
 		ssi_local_destroy(shp);
 
+#ifdef IPC_SHM_RACE_FIX
+		/*
+		 * Destroy shmid_kernel_svr (while holding shm_ids.sem)
+		 */
+		(void) ipc_get_locks(id, &shm_ids_svr, 1);
+		svp = shm_svr_rmid(id);
+		ipc_rcu_getref(svp);
+		ipc_drop_locks(id, (struct kern_ipc_perm *)svp, &shm_ids_svr, 1);
+
+		nl = svp->shm_nodelist;
+		shm_svr_cleanup(svp); /* might sleep */
+
+		ipc_lock_by_ptr(&svp->shm_perm);
+		ipc_rcu_putref(svp);
+		ipc_rcu_putref(svp); /* active */
+		shm_svr_unlock(svp);
+#else /* IPC_SHM_RACE_FIX */
 		ipc_get_locks(0, &shm_ids_svr, 1);
 		shm_svr_rmid(id);
 		ipc_drop_locks(0, NULL, &shm_ids_svr, 1);
-#if 0
-		nl = NSC_NODELIST_COPY(svp->shm_nodelist);
-		NSC_NODELIST_FREE(svp->shm_nodelist);
-#endif
+
 		nl = svp->shm_nodelist;
-		NSC_NODELIST_CLR1(nl, svrnode);
 		shm_svr_cleanup(svp);
 		kfree(svp);
-		/* ipc_drop_locks(0, NULL, &shm_ids_svr, 1); */
+#endif /* !IPC_SHM_RACE_FIX */
 
 		cli_ipcname_rmid(NAME_SERVICE_SHM, id);
+
+		NSC_NODELIST_CLR1(nl, svrnode);
 		cookie = CLUSTERNODE_INVAL;
 		while ((node = NSC_NODELIST_GET_NEXT(&cookie, nl))
 							!= CLUSTERNODE_INVAL) {
 			ret = RIPC_SHM_RMID(node, &rval, id, 1);
+			(void) rval;
+#if 0
 			if (ret)
 				NSC_NODELIST_CLR1(svp->shm_nodelist, node);
-
+#endif
 		}
 		NSC_NODELIST_FREE(nl); /* svp->shm_nodelist */
 		if (!do_locks)
@@ -629,13 +674,20 @@
 	}
 	else {
 		/* Drop the locks since will be going remote */
-		shp = (struct shmid_kernel *)shm_cli_get(id);
+		shp = shm_cli_get(id);
+#ifdef IPC_SHM_RACE_FIX
+		shm_cli_unlock(shp);
+		/* shm_ids.sem held */
+#else
 		ipc_drop_locks(id, (struct kern_ipc_perm *)shp, &shm_ids, 1);
+#endif
 
 		ret = RIPC_SHM_CLEANUP(svrnode, &rval, id, clinode);
 
+#ifndef IPC_SHM_RACE_FIX
 		/* Reacquire the locks */
 		ipc_get_locks(0, &shm_ids, 1);
+#endif
 
 #ifdef IPC_SHM_DESTROY_FIX
 		/* Ignore -EIDRM already removed at server */
@@ -644,17 +696,17 @@
 		if (ret == -EREMOTE || ret == -EIDRM) {
 #endif
 			cli_ipcname_rmid(NAME_SERVICE_SHM, id);
-			ret = ripc_shm_rmid(this_node, &rval, id, 1); 
-
+			ret = ripc_shm_rmid(this_node, &rval, id, 1);
+#ifndef IPC_SHM_RACE_FIX
 			/* ripc_shm_rmid() returns with shm_ids.sem unlocked */
 			ipc_get_locks(0, &shm_ids, 1);
+#endif
 		}
-		if (ret || rval) {
-			if (ret)
-				rval = ret;
-			if (rval != -EBUSY && rval != -ESRCH)
-				printk("Failed to cleanup IPC shm structures %d\n", rval);
-		}
+		if (ret)
+			rval = ret;
+		if (rval && rval != -EBUSY && rval != -ESRCH)
+			printk(KERN_WARNING "%s: Failed to cleanup IPC shm "
+				"structures %d\n", __FUNCTION__, rval);
 	}
 	return 0;
 }

Index: namesvr_func.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/namesvr_func.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- namesvr_func.c	5 Mar 2010 06:25:36 -0000	1.19
+++ namesvr_func.c	5 Mar 2010 06:30:21 -0000	1.20
@@ -1137,8 +1137,12 @@
 	for (i = 0; i < NAME_SERVICE_MAX; i++) {
 #ifdef IPC_SHM_RACE_FIX
 		ipc_get_locks(0, ipcname_svc_dbs[i], 1);
-#endif
 		num_objects[i] = ipc_get_inuse(ipcname_svc_dbs[i]);
+		if (num_objects[i] == 0)
+			ipc_drop_locks(0, NULL, ipcname_svc_dbs[i], 1);
+#else
+		num_objects[i] = ipc_get_inuse(ipcname_svc_dbs[i]);
+#endif
 	}
 	printk("passed the first scan in ipcname_pull_data\n");
 	len = sizeof(int) * 6	/* Lengths for each section. */
@@ -1167,12 +1171,8 @@
 		int id, maxid;
 		*((int *)buf) = num_objects[i];
 		buf += sizeof(int);
-		if (num_objects[i] == 0) {
-#ifdef IPC_SHM_RACE_FIX
-			ipc_drop_locks(0, NULL, ipcname_svc_dbs[i], 1);
-#endif
+		if (num_objects[i] == 0)
 			continue;
-		}
 		cur_object = 0;
 		maxid = ipc_get_maxid(ipcname_svc_dbs[i]);
 		for (id = 0; id <= maxid; id++) {


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev