[rds-devel] [PATCH 05/19] Start to introduce RDS on network namespace. - Make struct net aware of RDS structure. - Add rds.h under include/net/netns/ - Only move rds_conn_count to be netns based for now.

Jie Liu jeff.liu at oracle.com
Sun Oct 7 05:14:04 PDT 2012


Signed-off-by: Jie Liu <jeff.liu at oracle.com>
---
 include/net/net_namespace.h |    6 ++++++
 include/net/netns/rds.h     |    9 +++++++++
 net/rds/connection.c        |    7 +++----
 3 files changed, 18 insertions(+), 4 deletions(-)
 create mode 100644 include/net/netns/rds.h

diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index fd87963..829c27e 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -21,6 +21,9 @@
 #include <net/netns/conntrack.h>
 #endif
 #include <net/netns/xfrm.h>
+#if defined(CONFIG_RDS) || defined(CONFIG_RDS_MODULE)
+#include <net/netns/rds.h>
+#endif
 
 struct proc_dir_entry;
 struct net_device;
@@ -100,6 +103,9 @@ struct net {
 #ifdef CONFIG_XFRM
 	struct netns_xfrm	xfrm;
 #endif
+#if defined(CONFIG_RDS) || defined(CONFIG_RDS_MODULE)
+	struct netns_rds	rds;
+#endif
 	struct netns_ipvs	*ipvs;
 	struct sock		*diag_nlsk;
 	atomic_t		rt_genid;
diff --git a/include/net/netns/rds.h b/include/net/netns/rds.h
new file mode 100644
index 0000000..12eec99
--- /dev/null
+++ b/include/net/netns/rds.h
@@ -0,0 +1,9 @@
+#ifndef __NETNS_RDS_H
+#define __NETNS_RDS_H
+
+struct netns_rds {
+	/* connection count */
+	unsigned long rds_conn_count;
+};
+
+#endif
diff --git a/net/rds/connection.c b/net/rds/connection.c
index d477916..6a6fccd 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -45,7 +45,6 @@
 
 /* converting this to RCU is a chore for another day.. */
 static DEFINE_SPINLOCK(rds_conn_lock);
-static unsigned long rds_conn_count;
 static struct hlist_head rds_conn_hash[RDS_CONNECTION_HASH_ENTRIES];
 static struct kmem_cache *rds_conn_slab;
 
@@ -222,7 +221,7 @@ static struct rds_connection *__rds_conn_create(struct net *net,
 		} else {
 			parent->c_passive = conn;
 			rds_cong_add_conn(conn);
-			rds_conn_count++;
+			net->rds.rds_conn_count++;
 		}
 	} else {
 		/* Creating normal conn */
@@ -236,7 +235,7 @@ static struct rds_connection *__rds_conn_create(struct net *net,
 		} else {
 			hlist_add_head_rcu(&conn->c_hash_node, head);
 			rds_cong_add_conn(conn);
-			rds_conn_count++;
+			net->rds.rds_conn_count++;
 		}
 	}
 	spin_unlock_irqrestore(&rds_conn_lock, flags);
@@ -373,7 +372,7 @@ void rds_conn_destroy(struct rds_connection *conn)
 	kmem_cache_free(rds_conn_slab, conn);
 
 	spin_lock_irqsave(&rds_conn_lock, flags);
-	rds_conn_count--;
+	net->rds.rds_conn_count--;
 	spin_unlock_irqrestore(&rds_conn_lock, flags);
 }
 EXPORT_SYMBOL_GPL(rds_conn_destroy);
-- 
1.7.4.1




More information about the rds-devel mailing list