[SSI] openssi/kernel/cluster/ssi/ipc rmtunix.c,1.29,1.30

Roger Tsang <[email protected]> Sun, 08 Aug 2010 02:28:04 +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-serv3491/cluster/ssi/ipc

Modified Files:
      Tag: OPENSSI-FC
	rmtunix.c 
Log Message:
IPC:
- Move rmtunix_make_info(), rmtunix_cache_lookup(), and rmtunix_decache_info() into cluster/ssi/ipc/rmtunix.c

 cluster/ssi/ipc/rmtunix.c        |   91 ++++++++
 include/cluster/ssi/ipc/unixnm.h |   97 --------


Index: rmtunix.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/rmtunix.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- rmtunix.c	5 Mar 2010 06:20:46 -0000	1.29
+++ rmtunix.c	8 Aug 2010 02:28:02 -0000	1.30
@@ -111,6 +111,97 @@
 #endif
 }
 
+struct rmtunix_socket_info *
+rmtunix_make_info(void)
+{
+	struct rmtunix_socket_info *info;
+
+#ifdef RMTUNIX_SOCK_INFO_CACHE
+	info = kmem_cache_alloc(rmtunix_socket_info_cachep, SLAB_KERNEL);
+	memset(info, 0, sizeof(*info));
+#else
+	info = kzmalloc(sizeof(*info), GFP_USER);
+#endif
+	if (!info)
+		goto out;
+
+#ifdef IPC_STALE_RMTUNIX_CACHE_FIX
+	INIT_LIST_HEAD(&info->list);
+	atomic_set(&info->rsk_refcnt, 1);
+#endif
+#ifdef RCU_RMTUNIX_CACHE
+	INIT_RCU_HEAD(&info->rhead);
+#endif
+out:
+	return info;
+}
+
+static inline struct rmtunix_socket_info *
+rmtunix_cache_lookup(unix_socket *s)
+{
+#ifdef RCU_RMTUNIX_CACHE
+	struct rmtunix_socket_info *info;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(info, &rmtunix_cache_list, list) {
+		if (info->sk == s &&
+		    atomic_test_and_add(1, &info->rsk_refcnt))
+			goto found;
+	}
+	info = NULL;
+found:
+	rcu_read_unlock();
+	return info;
+#else /* RCU_RMTUNIX_CACHE */
+	struct list_head *cur;
+
+	/* Caller must hold rmtunix_cache_listlock */
+	list_for_each(cur, &rmtunix_cache_list) {
+		struct rmtunix_socket_info *tmp = list_entry(cur,
+				struct rmtunix_socket_info, list);
+		if (tmp->sk == s)
+			return tmp;
+	}
+	return NULL;
+#endif /* !RCU_RMTUNIX_CACHE */
+}
+
+static inline void
+rmtunix_decache_info(unix_socket *s)
+{
+	struct rmtunix_socket_info *info =
+			(struct rmtunix_socket_info *)(unix_peer(s));
+#ifndef RCU_RMTUNIX_CACHE
+	int orphan = 0;
+
+	spin_lock(&rmtunix_cache_listlock);
+	if (!info) {
+		orphan = 1;
+#else
+	if (!info) {
+#endif
+		info = rmtunix_cache_lookup(s);
+#ifdef IPC_STALE_RMTUNIX_CACHE_FIX
+		if (!info)
+			return;
+		/* SSI_XXX: expect orphans? */
+		printk(KERN_DEBUG "%s: orphan rmtunix socket info found.\n",
+				__FUNCTION__);
+#else
+		SSI_ASSERT(info);
+#endif
+	}
+
+	(void) __rmtunix_decache_info(info);
+
+#ifndef RCU_RMTUNIX_CACHE
+	if (orphan) {
+		info->magic = 0;
+		kfree(info);
+	}
+#endif
+}
+
 void
 rmtunix_nodedown(clusternode_t node)
 {


------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev