[SSI] openssi/kernel/cluster/ssi/ipc namesvr_func.c, 1.13, 1.14 rmtunix.c, 1.25, 1.26 unixnm.c, 1.14, 1.15

Roger Tsang <[email protected]>
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23689/cluster/ssi/ipc

Modified Files:
      Tag: OPENSSI-FC
	namesvr_func.c rmtunix.c unixnm.c 
Log Message:
CFS:
- Fix possible server token table hash key race with PFS file handle data.
- Further avoid ssi_get_super() to reduce contention. We don't cross mount points.
- Switch to Linux get_empty_filp() to get unused file structure for svrcfstok structure.
- Regression:
  - Possible inode leak when out of memory doing export ops get_dentry. (#ifdef CFS_EXPORT_OPS)
  - Possibly missed drop_super() while performing export ops get_dentry. (#ifdef CFS_FH_TO_DENTRY_ANON)

IPC:
- Fix uninitialized spin lock in kern_ipc_perm structure (in SSI context).
- Fix uninitialized linked list pointers in unixnm_svr_entry and unixnm_cache_entry structures.
- SHM dentry lookup bug fixes:
  - Error -ENOENT in CFS (negative dentry) due to not validating against PFS.
  - Fix SHM negative dentry lookup could cause future memory corruption.
    - Did not increment inode count when instantiating dentry.
    - Bad dentry reference count side-effect due to incorrect return value for Linux namespace architecture.

IPVS:
- Fix uninitialized linked list pointers in ipvs_dirinfo and portweight_list structures.

SSI:
- Fix dentry race calling __d_path() outside dcache lock. (#ifdef SSI_DCACHE_RACE_FIX)
- Fix uninitialized linked list pointers in structures rmtfb_cmn, ssidev_hash, fifonm_svr_entry, fifonm_cache_entry, and ssipty_svr_
entry.

VPROC:
- Fix possibly missed drop_super() during process migration exporting of file descriptors.
- Fix partially initialized proc_root_readdir_cookie structure.
- semundo_load_msg() handle process sysvsem.undo_list->proc_list race take two. (#ifdef VPROC_UNLOAD_SETSCHED_SMP)
- Regression:
  - Process migration traversing rmtfb path while importing SHM fd's; caused by fb_svrnode macro. (#ifdef REOP_EXPORT_PATH_SVRNODE)


Index: unixnm.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/unixnm.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- unixnm.c	7 Aug 2007 03:06:09 -0000	1.14
+++ unixnm.c	19 Feb 2009 08:01:02 -0000	1.15
@@ -175,6 +175,7 @@
 		struct unixnm_svr_entry *svrent =
 			kzmalloc_nofail(sizeof(*svrent));
 
+		INIT_LIST_HEAD(&svrent->list);
 		if (rbldent->namelen) {
 			svrent->name = kmalloc_nofail(
 						sizeof(rbldent->name));
@@ -200,8 +201,8 @@
 	int *data_len)
 {
 	struct unixnm_rebuild_entry *entry;
-	struct list_head *cur;
 	int error;
+	struct unixnm_cache_entry *cchent;
 
 	down_write(&unixnm_cache_rebuildlock);
 	*data_len = unixnm_cache_size * sizeof(*entry);
@@ -210,10 +211,7 @@
 		goto out;
 
 	entry = (struct unixnm_rebuild_entry *) buffer;
-	list_for_each(cur, &unixnm_cache_list) {
-		struct unixnm_cache_entry *cchent =
-			list_entry(cur, struct unixnm_cache_entry, list);
-
+	list_for_each_entry(cchent, &unixnm_cache_list, list) {
 		struct inode *inode = cchent->inode;
 		struct sock *sk = SOCKET_I(inode)->sk;
 
@@ -262,10 +260,8 @@
 
 	write_lock(&unixnm_svr_lock);
 	for (hash = 0; hash < UNIX_HASH_SIZE; ++hash) {
-		struct list_head *cur, *next;
-		list_for_each_safe(cur, next, &unixnm_svr_table[hash]) {
-			struct unixnm_svr_entry *entry =
-				list_entry(cur, struct unixnm_svr_entry, list);
+		struct unixnm_svr_entry *entry, *next;
+		list_for_each_entry_safe(entry, next, &unixnm_svr_table[hash], list) {
 			if (entry->socknode == node) {
 				list_del(&entry->list);
 				kfree(entry->name);
@@ -302,10 +298,10 @@
 	dev_t name_ssidev,
 	unsigned long name_ino)
 {
-	struct list_head *cur;
-	list_for_each(cur, &unixnm_svr_table[unixnmsvr_hashino(name_ino)]) {
-		struct unixnm_svr_entry *entry =
-			list_entry(cur, struct unixnm_svr_entry, list);
+	struct unixnm_svr_entry *entry;
+
+	list_for_each_entry(entry,
+			&unixnm_svr_table[unixnmsvr_hashino(name_ino)], list) {
 		if (entry->name)
 			continue;
 		if (entry->name_ino == name_ino &&
@@ -345,10 +341,11 @@
 		goto entry_exists_out;
 
 	*rval = -ENOMEM;
-	newentry = kzmalloc(sizeof(struct unixnm_svr_entry), GFP_USER);
+	newentry = kzmalloc(sizeof(*newentry), GFP_USER);
 	if (!newentry)
 		return 0;
 
+	INIT_LIST_HEAD(&newentry->list);
 	newentry->name_ssidev = name_ssidev;
 	newentry->name_ino = name_ino;
 	newentry->type = type;
@@ -382,10 +379,8 @@
 	int namelen,
 	int hash)
 {
-	struct list_head *cur;
-	list_for_each(cur, &unixnm_svr_table[hash]) {
-		struct unixnm_svr_entry *entry =
-			list_entry(cur, struct unixnm_svr_entry, list);
+	struct unixnm_svr_entry *entry;
+	list_for_each_entry(entry, &unixnm_svr_table[hash], list) {
 		if (!entry->name)
 			continue;
 		if (entry->namelen == namelen &&
@@ -444,10 +439,11 @@
 		goto entry_exists_out;
 
 	*rval = -ENOMEM;
-	newentry = kzmalloc(sizeof(struct unixnm_svr_entry), GFP_USER);
+	newentry = kzmalloc(sizeof(*newentry), GFP_USER);
 	if (!newentry)
 		return 0;
 
+	INIT_LIST_HEAD(&newentry->list);
 	newentry->name = kmalloc(namelen, GFP_USER);
 	if (!newentry->name) {
 		kfree(newentry);
@@ -590,8 +586,7 @@
 	clusternode_t socknode,
 	u_long sockino)
 {
-	struct unixnm_svr_entry *entry = NULL;
-	struct list_head *cur;
+	struct unixnm_svr_entry *tmp, *entry = NULL;
 
 	*rval = -EREMOTE;
 	if (this_node != unixnm_svr)
@@ -610,9 +605,7 @@
 	}
 
 	write_lock(&unixnm_svr_lock);
-	list_for_each(cur, &unixnm_svr_table[hash]) {
-		struct unixnm_svr_entry *tmp =
-			list_entry(cur, struct unixnm_svr_entry, list);
+	list_for_each_entry(tmp, &unixnm_svr_table[hash], list) {
 		if (tmp->socknode == socknode &&
 				tmp->sockino == sockino) {
 			entry = tmp;
@@ -720,7 +713,7 @@
 	struct unixnm_cache_entry *entry;
 	int error, ret;
 
-	entry = kmalloc(sizeof(struct unixnm_cache_entry), GFP_USER);
+	entry = kmalloc(sizeof(*entry), GFP_USER);
 	if (!entry)
 		return -ENOMEM;
 
@@ -739,6 +732,7 @@
 	if (error)
 		goto unlock_out;
 
+	INIT_LIST_HEAD(&entry->list);
 	entry->inode = inode;
 	entry->name_inode = name_inode;
 	entry->name_addr = NULL;
@@ -768,7 +762,7 @@
 	struct unixnm_cache_entry *entry;
 	int error, ret;
 
-	entry = kmalloc(sizeof(struct unixnm_cache_entry), GFP_USER);
+	entry = kmalloc(sizeof(*entry), GFP_USER);
 	if (!entry)
 		return -ENOMEM;
 
@@ -787,6 +781,7 @@
 	if (error)
 		goto unlock_out;
 
+	INIT_LIST_HEAD(&entry->list);
 	entry->inode = inode;
 	entry->name_inode = NULL;
 	entry->name_addr = name_addr;
@@ -877,8 +872,7 @@
 	struct unix_sock *options = unix_sk(sock->sk);
 	int hash;
 
-	struct unixnm_cache_entry *entry = NULL;
-	struct list_head *cur;
+	struct unixnm_cache_entry *tmp, *entry = NULL;
 	int error, ret;
 
 	hash = options->dentry ?
@@ -903,9 +897,7 @@
 	}
 
 	spin_lock(&unixnm_cache_listlock);
-	list_for_each(cur, &unixnm_cache_list) {
-		struct unixnm_cache_entry *tmp =
-			list_entry(cur, struct unixnm_cache_entry, list);
+	list_for_each_entry(tmp, &unixnm_cache_list, list) {
 		if (tmp->inode == inode) {
 			entry = tmp;
 			break;
@@ -990,10 +982,9 @@
 	}
 
 	for (hash = 0; hash < UNIX_HASH_SIZE; ++hash) {
-		struct list_head *cur;
-		list_for_each(cur, &unixnm_svr_table[hash]) {
-			struct unixnm_svr_entry *entry =
-				list_entry(cur, struct unixnm_svr_entry, list);
+		struct unixnm_svr_entry *entry;
+
+		list_for_each_entry(entry, &unixnm_svr_table[hash], list) {
 			printk("entry (0x%p)\n", (void *) entry);
 			printk(TAB "hash = %d\n", hash);
 			if (entry->name) {
@@ -1015,10 +1006,9 @@
 void
 print_unmcache(void)
 {
-	struct list_head *cur;
-	list_for_each(cur, &unixnm_cache_list) {
-		struct unixnm_cache_entry *entry =
-			list_entry(cur, struct unixnm_cache_entry, list);
+	struct unixnm_cache_entry *entry;
+
+	list_for_each_entry(entry, &unixnm_cache_list, list) {
 		printk("entry (0x%p)\n", (void *) entry);
 		printk(TAB "inode = 0x%p", (void *) entry->inode);
 		printk(TAB "socket = 0x%p\n", (void *) SOCKET_I(entry->inode));

Index: namesvr_func.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/namesvr_func.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- namesvr_func.c	20 Apr 2008 05:49:22 -0000	1.13
+++ namesvr_func.c	19 Feb 2009 08:01:02 -0000	1.14
@@ -403,10 +403,13 @@
 	ipc_perm_t *perm;
 
 	/* need to alloc a kern_ipc_perm structure */
-	perm = kmalloc(sizeof(struct kern_ipc_perm), GFP_KERNEL);
-	if (perm < 0)
+	perm = kzmalloc(sizeof(*perm), GFP_KERNEL);
+	if (perm < 0) {
 		*ipcpp = NULL;
-	*ipcpp = perm;
+	} else {
+		spin_lock_init(&perm->lock);
+		*ipcpp = perm;
+	}
 }
 
 

Index: rmtunix.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/rmtunix.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- rmtunix.c	8 Feb 2009 02:44:43 -0000	1.25
+++ rmtunix.c	19 Feb 2009 08:01:02 -0000	1.26
@@ -78,8 +78,19 @@
 module_init(rmtunix_init);
 #endif
 
-static inline void
-_rmtunix_dealloc(struct rmtunix_socket_info *info)
+#ifdef RCU_RMTUNIX_CACHE
+void
+rmtunix_free(struct rcu_head *rhead)
+{
+	struct rmtunix_socket_info *info =
+			container_of(rhead, struct rmtunix_socket_info, rhead);
+
+	kmem_cache_free(rmtunix_socket_info_cachep, info);
+}
+#endif
+
+void
+rmtunix_dealloc(struct rmtunix_socket_info *info)
 {
 #ifdef IPC_STALE_RMTUNIX_CACHE_FIX
 	if (info->sk) {
@@ -94,20 +105,12 @@
 #endif
 	info->magic = 0;
 #ifdef RMTUNIX_SOCK_INFO_CACHE
-	kmem_cache_free(rmtunix_socket_info_cachep, info);
+	call_rcu(&info->rhead, rmtunix_free);
 #else
 	kfree(info);
 #endif
 }
 
-#ifdef RCU_RMTUNIX_CACHE
-void
-rmtunix_dealloc(struct rcu_head *rhead)
-{
-	_rmtunix_dealloc(container_of(rhead, struct rmtunix_socket_info, rhead));
-}
-#endif
-
 void
 rmtunix_nodedown(clusternode_t node)
 {
@@ -121,26 +124,7 @@
 				struct rmtunix_socket_info, list);
 		if (info->node != node)
 			continue;
-		if (!atomic_dec_and_lock(&info->rsk_refcnt, &rmtunix_cache_listlock))
-			continue;
-		if (info->sk) {
-			SSI_ASSERT(info->rsk_cached);
-			LOCK_SPIN_LOCK(&info->rsk_spinlock);
-			if (atomic_read(&info->rsk_refcnt)) {
-				UNLOCK_SPIN_LOCK(&info->rsk_spinlock);
-				spin_unlock(&rmtunix_cache_listlock);
-				continue;
-			}
-			info->rsk_cached = 0;
-			UNLOCK_SPIN_LOCK(&info->rsk_spinlock);
-		} else
-			BUG_ON(info->rsk_cached);
-#ifdef DEBUG
-		--rmtunix_cache_size;
-#endif
-		list_del_rcu(&info->list);
-		spin_unlock(&rmtunix_cache_listlock);
-		call_rcu(&info->rhead, rmtunix_dealloc);
+		__rmtunix_decache_info(info);
 	}
 	rcu_read_unlock();
 #else /* !RCU_RMTUNIX_CACHE */
@@ -171,7 +155,7 @@
 		struct rmtunix_socket_info *info = list_entry(cur,
 				struct rmtunix_socket_info, list);
 
-		_rmtunix_dealloc(info);
+		rmtunix_dealloc(info);
 	}
 #endif /* !RCU_RMTUNIX_CACHE */
 }


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
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.