[Ocfs2-commits] zab commits r1985 - branches/usysfsify/fs/ocfs2/cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Mar 16 15:30:20 CST 2005


Author: zab
Date: 2005-03-16 15:30:19 -0600 (Wed, 16 Mar 2005)
New Revision: 1985

Modified:
   branches/usysfsify/fs/ocfs2/cluster/nodemanager.c
   branches/usysfsify/fs/ocfs2/cluster/nodemanager.h
   branches/usysfsify/fs/ocfs2/cluster/tcp.c
   branches/usysfsify/fs/ocfs2/cluster/tcp.h
Log:
usysfify tcp

o introduce a boolean 'local' node attribute
o bring up the rx thread on a node who gets local set
o only one node can have local set
o look up net_inode_private through nm_node instead of inodes


Modified: branches/usysfsify/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/nodemanager.c	2005-03-16 19:14:57 UTC (rev 1984)
+++ branches/usysfsify/fs/ocfs2/cluster/nodemanager.c	2005-03-16 21:30:19 UTC (rev 1985)
@@ -91,6 +91,8 @@
 	char		cl_name[NM_MAX_NAME_LEN+1];
 	spinlock_t	cl_bitmap_lock;
 	unsigned long	cl_node_bitmap[BITS_TO_LONGS(NM_MAX_NODES)];
+	unsigned	cl_has_local:1;
+	u8		cl_local_node;
 };
 
 static int nm_find_next_slot(spinlock_t *lock, void *bitmap, int max,
@@ -360,7 +362,48 @@
 
 	return count;
 }
+static ssize_t nm_node_local_read(struct nm_node *node, char *page)
+{
+	return sprintf(page, "%u", node->nd_local);
+}
 
+static ssize_t nm_node_local_write(struct nm_node *node,
+					  const char *page,
+					  size_t count)
+{
+	struct nm_cluster *cluster = to_nm_cluster(node->nd_kobj.parent);
+	unsigned long tmp;
+	char *p = (char *)page;
+	ssize_t ret;
+
+	tmp = simple_strtoul(p, &p, 0);
+	if (!p || (*p && (*p != '\n')))
+		return -EINVAL;
+
+	tmp = !!tmp; /* boolean of whether this node wants to be local */
+
+	/* the only failure case is trying to set a new local node
+	 * when a different one is already set */
+	if (tmp && tmp != cluster->cl_has_local &&
+	    cluster->cl_local_node != node->nd_num)
+			return -EBUSY;
+
+	/* XXX make sure port/addr are set */
+	if (tmp && !cluster->cl_has_local) {
+		ret = net_start_rx_thread(node);
+		if (ret)
+			return ret;
+	}
+
+	if (!tmp && cluster->cl_has_local)
+		net_stop_rx_thread(node);
+
+	cluster->cl_has_local = tmp;
+	cluster->cl_local_node = tmp ? node->nd_num : 0;
+
+	return count;
+}
+
 struct nm_node_attribute {
 	struct attribute attr;
 	ssize_t (*show)(struct nm_node *, char *);
@@ -382,10 +425,16 @@
 	.show	= nm_node_ipv4_address_read,
 	.store	= nm_node_ipv4_address_write,
 };
+static struct nm_node_attribute nm_node_attr_local = {
+	.attr	= { .name = "local", .mode = S_IRUGO | S_IWUSR },
+	.show	= nm_node_local_read,
+	.store	= nm_node_local_write,
+};
 static struct attribute *nm_node_default_attrs[] = {
 	&nm_node_attr_num.attr,
 	&nm_node_attr_ipv4_port.attr,
 	&nm_node_attr_ipv4_address.attr,
+	&nm_node_attr_local.attr,
 	NULL,
 };
 
@@ -439,14 +488,15 @@
 	/* some stuff? */
 };
 
+#if 0
 static struct nm_node_set *to_nm_node_set(struct kset *kset)
 {
 	return kset ? 
 		container_of(to_ukset(kset), struct nm_node_set, ns_ukset) 
 		: NULL;
 }
+#endif
 
-
 static struct kobject *nm_node_set_make_object(struct kset *kset,
 					      const char *name)
 {
@@ -503,9 +553,14 @@
 
 static void nm_node_set_drop_object(struct kset *kset, struct kobject *kobj)
 {
-	struct nm_node_set *ns = to_nm_node_set(kset);
+	struct nm_node *node = to_nm_node(kobj);
+	struct nm_cluster *cluster = to_nm_cluster(node->nd_kobj.parent);
 
-	printk("dropping nm_node_set %p\n", ns);
+	if (cluster->cl_has_local)
+		net_stop_rx_thread(node);
+
+	/* XXX call into net to stop this node from trading messages */
+
 	kobject_put(kobj);
 }
 
@@ -620,6 +675,8 @@
 static void __exit exit_nm(void)
 {
 	nmprintk("unloading nm module\n");
+	/* XXX sync with hb callbacks and shut down hb? */
+	net_unregister_hb_callbacks();
 	usysfs_unregister_subsystem(&nm_cluster_set.cs_ukset.kset);
 }
 
@@ -629,6 +686,9 @@
 	unsigned i;
 
 	hb_init();
+	ret = net_register_hb_callbacks();
+	if (ret)
+		goto out;
 
 	for (i = 0; i <= ARRAY_SIZE(nm_callbacks); i++)
 		INIT_LIST_HEAD(&nm_callbacks[i]);

Modified: branches/usysfsify/fs/ocfs2/cluster/nodemanager.h
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/nodemanager.h	2005-03-16 19:14:57 UTC (rev 1984)
+++ branches/usysfsify/fs/ocfs2/cluster/nodemanager.h	2005-03-16 21:30:19 UTC (rev 1985)
@@ -34,9 +34,21 @@
 
 
 /* TODO: move this */
+/*
+ * this stores the per-socket state for each socket that we associate
+ * with a node.  for remote nodes this is a socket that is established
+ * on demand and trades messages.  For a local node this is just a listening
+ * socket that spawns message sockets from other nodes.
+ */
 struct sock;
+/* this is still called net_inode_private for hysterical raisins.  one
+ * has to draw the cleanup line somewhere.. */
 typedef struct _net_inode_private
 {
+	/* only used by the local node. */
+	struct task_struct	*rx_thread;
+	/* the rest is for remote nodes */
+
 	/* sockets themselves don't seem to have a nice way to refcount them
 	 * above sock_release.  one could use iget/iput, but that seems
 	 * to interact poory with sock_release() itself calling iput. */
@@ -53,6 +65,7 @@
 	struct page 		*page;
 	size_t			page_off;
 
+
 	void			(*orig_state_change)(struct sock *sk);
 	void                    (*orig_error_report)(struct sock *sk);
 	void			(*orig_data_ready)(struct sock *sk, int bytes);
@@ -69,6 +82,8 @@
 	 * in network order */
 	__u32			nd_ipv4_address;
 	__u16			nd_ipv4_port;
+	/* there can be only one local node for now */
+	int			nd_local;
 
 	/* we're making simple assertions that a node can only have one network
 	 * identity and report at one place in a heartbeat */

Modified: branches/usysfsify/fs/ocfs2/cluster/tcp.c
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/tcp.c	2005-03-16 19:14:57 UTC (rev 1984)
+++ branches/usysfsify/fs/ocfs2/cluster/tcp.c	2005-03-16 21:30:19 UTC (rev 1985)
@@ -63,17 +63,22 @@
  *      - handers must be callable from bh context
  * but it really depends on what the semantics and messages are.
  *
- * XXX we should resolve these before release
+ * asap
+ * 	- only have lookup succeed for active nodes (fully configured)
+ * 	- only initiate connections if rx thread is running?
+ * 	- don't allow node rmdir if it has socket and rx thread is running
+ * 	- tear down all node sockets on rx thread exit
+ * 	- have rx thread stop active tx and wait for them
+ * 	- make sure ->net.page gets torn down with net_inode_private
+ * 	- tear down sockets on exit.. via removing their inodes?
+ *
+ * XXX
  * 	- disable preemt before calling rx handler when debugging
  * 	- find explicit stack call to drain rx queue
  * 	- add trivial version trading message at the start of a conn
  * 	- go nuts adding static
  * 	- nsc waiting is buggy, should be on socket.. wake w/err if socket dies
  * 	- compare socks in attach_sock so both size don't close
- * 	- implement net_remove_handlers
- * 	- make sure ->net.page gets torn down with net_inode_private
- * 	- tear down sockets on exit.. via removing their inodes?
- * 	- simplify rx thread exit path (completion, etc)
  */
 
 #include <linux/module.h>
@@ -145,10 +150,6 @@
 #define sk_state_change		state_change
 #endif
 
-static u16 ip_version, ip_port;
-static struct inode *net_inode = NULL;
-static u8 net_node_num;
-
 /* all this state should eventually be brought up by object activation
  * and tied to that object rather than being globally valid at insmod */
 static spinlock_t net_handler_lock = SPIN_LOCK_UNLOCKED;
@@ -159,6 +160,7 @@
 static spinlock_t net_active_lock = SPIN_LOCK_UNLOCKED;
 static LIST_HEAD(net_active_list);
 
+/* XXX someday we'll need better accounting */
 static struct task_struct *net_recv_task = NULL;
 
 static inline void net_abort_status_return(net_status_ctxt *nsc)
@@ -169,25 +171,16 @@
 	spin_unlock(&net_status_lock);
 }
 
-static int net_register_hb_callbacks(void);
-static void net_unregister_hb_callbacks(void);
-
 /////////////////////
-static void net_shutdown(void);
-static int net_startup(void);
-static int net_init_driver(void);
-static void __exit net_driver_exit (void);
 static int net_add_handler(net_msg_handler *nmh);
-static void net_remove_handlers(void);
-static struct socket *net_init_tcp_recv_sock(void);
+static struct socket *net_init_tcp_recv_sock(u16 port);
 static int net_receive_thread(void *data);
 static int net_receive(void);
 static void net_try_accept(struct socket *sock);
 static int net_process_message(struct socket *sock, net_msg *hdr);
-static int net_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
 
 static int net_sock_addref_or_connect(u8 node_num, struct socket **sock_ret);
-static void net_sock_decref(struct inode *inode, int error);
+static void net_sock_decref(struct socket *sock, int error);
 
 //////////////////////
 
@@ -211,155 +204,19 @@
 	spin_unlock(&net_handler_lock);
 }
 
-
-DECLARE_MUTEX(net_state_lock);
-u32 net_driver_state = NET_DRIVER_UNINITED;
-u32 net_num_dispatched = 0;
-
-static int __init net_driver_entry (void)
+int net_start_rx_thread(struct nm_node *node)
 {
-	struct proc_dir_entry *de;
-	de = proc_mkdir("cluster/net", 0);
-	if (!de)
-		return -1;
-	de->proc_fops->ioctl = net_ioctl;
-
-	if (net_register_hb_callbacks())
-		return -1;
-
-	netprintk0("Loaded net Driver module\n");
-	return 0;
-}				/* net_driver_entry */
-
-static int net_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
-		     unsigned long arg)
-{
-	net_ioc data;
-	int ret = 0;
-	struct file *file = NULL;
-
-	if (_IOC_TYPE (cmd) != NET_IOC_MAGIC) {
-		ret = -ENOTTY;
-		goto exit_ioctl;
-	}
-
-	switch (cmd) {
-	    case NET_IOC_ACTIVATE:
-		    memset(&data, 0, sizeof(net_ioc));
-		    down(&net_state_lock);
-		    data.status = net_driver_state;
-		    if (net_driver_state == NET_DRIVER_UNINITED) {
-			    ret = net_init_driver();
-			    if (ret < 0) {
-				    netprintk("error trying to activate net driver: %d\n", ret);
-				    data.status = NET_DRIVER_UNINITED;
-			    } else {
-				    netprintk0("activated net driver!\n");
-				    net_driver_state = data.status = NET_DRIVER_READY;
-			    }
-		    }
-		    up(&net_state_lock);
-
-		    ret = copy_to_user ((net_ioc *) arg, &data,
-					sizeof (net_ioc));
-		    break;
-	    case NET_IOC_GETSTATE:
-		    memset(&data, 0, sizeof(net_ioc));
-		    down(&net_state_lock);
-		    data.status = net_driver_state;
-		    up(&net_state_lock);
-		    ret = copy_to_user ((net_ioc *) arg, &data,
-					sizeof (net_ioc));
-		    break;
-		    
-	    case GSD_IOC_CREATE_GROUP:
-	    case GSD_IOC_ADD_GROUP_NODE:
-		    ret = gsd_ioctl(inode, filp, cmd, arg);
-		    break;
-	    default:
-		    ret = -ENOTTY;
-		    break;
-	}
-
-exit_ioctl:
-
-	if (file)
-		fput(file);
-
-	return ret;
-}				/* net_ioctl */
-
-static int net_init_driver(void)
-{
-	nm_node_info *info;
-	nm_node_inode_private *priv;
-
-	/* get the global node number for this node */
-	net_node_num = nm_this_node(NULL);
-	if (net_node_num >= NM_MAX_NODES) {
-		netprintk0("local nm node number not initialized!\n");
-		return -1;
-	}
-	net_inode = nm_get_node_by_num(net_node_num);
-	if (!net_inode) {
-		netprintk0("local nm node inode not initialized!\n");
-		return -1;
-	}
-	priv = (nm_node_inode_private *)net_inode->u.generic_ip;
-	if (!priv) {
-		iput(net_inode);
-		netprintk0("local nm node info not initialized!\n");
-		return -1;
-	}
-	info = &priv->node;
-	ip_version = info->ifaces[0].ip_version;
-	ip_port = info->ifaces[0].ip_port;
-
-	if (net_startup() < 0)
-		return -1;
-
-	if (gsd_setup() < 0)
-		return -1;
-
-	return 0;
-}				/* net_init_driver*/
-
-
-/*
- * net_driver_exit()
- *
- * Called on rmmod
- */
-static void __exit net_driver_exit (void)
-{
-	down(&net_state_lock);
-	if (net_driver_state == NET_DRIVER_READY) {
-		netprintk0("shutting down network\n");
-		net_shutdown();
-		netprintk0("removing all net driver handlers\n");
-		net_remove_handlers();
-		gsd_teardown();
-		if (net_inode)
-			iput(net_inode);
-		net_driver_state = NET_DRIVER_UNINITED;
-	}
-	up(&net_state_lock);
-	remove_proc_entry("cluster/net", NULL);
-	net_unregister_hb_callbacks();
-	netprintk0("Unloading net driver module\n");
-	return;
-}				/* net_driver_exit */
-
-
-static int net_startup(void)
-{
 	struct socket *sock;
+	net_inode_private *net = &node->nd_net_inode_private;
 	int ret = 0;
 
+	BUG_ON(net->rx_thread != NULL);
+	BUG_ON(net_recv_task != NULL);
+
 	/* if the thread was setting up the rx socket we'd like to have it
 	 * communicate errors back to us here.  us setting up the socket
 	 * and passing it to the thread is easier */
-	sock = net_init_tcp_recv_sock();
+	sock = net_init_tcp_recv_sock(node->nd_ipv4_port);
 	if (IS_ERR(sock)) {
 		ret = PTR_ERR(sock);
 		goto out;
@@ -367,10 +224,11 @@
 
 	netprintk0("starting net receive thread...\n");
 
-	net_recv_task = kthread_run(net_receive_thread, sock, "netrecv");
-	if (IS_ERR(net_recv_task)) {
-		ret = PTR_ERR(net_recv_task);
-		net_recv_task = NULL;
+	net->rx_thread = kthread_run(net_receive_thread, sock,
+				     "netrecv-%s", node->nd_name);
+	if (IS_ERR(net->rx_thread)) {
+		ret = PTR_ERR(net->rx_thread);
+		net->rx_thread = NULL;
 		netprintk("unable to launch net receive thread, error=%ld\n",
 			  (long)ret);
 		goto out;
@@ -378,6 +236,7 @@
 
 	/* once the thread is running it has ownership of the sock */
 	sock = NULL;
+	net_recv_task = net->rx_thread;
 
 out:
 	if (sock)
@@ -385,12 +244,21 @@
 	return 0;
 }
 
-static void net_shutdown(void)
+void net_stop_rx_thread(struct nm_node *node)
 {
-	if (net_recv_task) {
+	net_inode_private *net = &node->nd_net_inode_private;
+	if (net->rx_thread) {
 		netprintk("waiting for net thread to exit....\n");
-		kthread_stop(net_recv_task);
+		kthread_stop(net->rx_thread);
+		net->rx_thread = NULL;
+		net_recv_task = NULL;
 	}
+
+	/* XXX if we stop the thread we've cut off the rx path for all the
+	 * nodes.. we should walk their net_inode_privates and tear down their
+	 * sockets.   tx shouldn't bring up a conn if there is no
+	 * rx thread and rmdir should sync with the rx therad and tx 
+	 * references.. ugh. */
 }
 
 static int net_rx_should_wake(struct socket *sock)
@@ -526,16 +394,6 @@
 	return ret;
 }	      
 
-
-/* TODO Fix */
-static void net_remove_handlers(void)
-{
-	/* TODO: make an iterator in nm for running over each global inode
-	 * do I have this already?  then call destroy on each.  last put
-	 * will do the work.  doesnt matter if it's slow.  this is only
-	 * on shutdown... */
-}
-
 static int net_recv_tcp_msg(struct socket *sock, void *data, size_t len)
 {
 	int ret;
@@ -617,7 +475,7 @@
 	struct iovec *iov = NULL;
 	struct socket *sock = NULL;
 
-	BUG_ON(current == net_recv_task);
+	BUG_ON(net_recv_task && (current == net_recv_task));
 
 	if (caller_iovlen == 0) {
 		netprintk0("bad iovec array length\n");
@@ -674,8 +532,7 @@
 	nsc.msg_num = msg->msg_num;
 	nsc.sys_status = NET_ERR_NONE;
 	nsc.status = 0;
-	/* XXX: Should be using group index here. */
-	nsc.target_node = nm_get_node_global_index(inode);
+	nsc.target_node = target_node;
 
 	init_waitqueue_entry(&sleep, current);
 	add_wait_queue(&nsc.wq, &sleep);
@@ -715,7 +572,7 @@
 	if (cleanup_wq)
 		remove_wait_queue(&nsc.wq, &sleep);
 	if (sock)
-		net_sock_decref(inode, ret);
+		net_sock_decref(sock, ret);
 	if (iov)
 		kfree(iov);
 	if (msg)
@@ -871,9 +728,7 @@
 
 static int net_receive(void)
 {
-	struct inode *inode;
 	LIST_HEAD(snapshot_list);
-	nm_node_inode_private *priv;
 	net_inode_private *net;
 	struct socket *sock;
 	net_msg *hdr;
@@ -899,14 +754,13 @@
 		list_del_init(&net->active_item);
 		spin_unlock_bh(&net_active_lock);
 
-		priv = container_of(net, nm_node_inode_private, net);
-	       	inode = priv->inode;
 		sock = NULL;
 
 		err = 0;
 		read_eagain = 0;
 		read_some = 0;
 
+		/* basically a manual addref that doesn't connect :/ */
 		spin_lock_bh(&net->sock_lock);
 		if (net->sock && !net->sock_pending) {
 			sock = net->sock;
@@ -993,9 +847,9 @@
 		spin_unlock_bh(&net_active_lock);
 
 		netprintk("net %p finished reading with %d\n", net, err);
-		if (err < 0 && err != -EAGAIN) {
+		if (sock && err < 0 && err != -EAGAIN) {
 			netprintk("socket saw err %d, closing\n", err);
-			net_sock_decref(inode, err);
+			net_sock_decref(sock, err);
 		}
 	}
 
@@ -1048,8 +902,11 @@
 	netprintk("node %u died, killed %d messages\n", node, num_kills);
 }
 
-static void net_hb_node_down_cb(struct inode *group,
-				struct inode *node,
+/* this callback is registered on insmod and torn down on rmmod.  
+ * the list and locks that it uses to kill messages are statically
+ * defined so it should be ok.. it just has to carefully be called
+ * after hb is ready and before hb is torn down */
+static void net_hb_node_down_cb(struct nm_node *node,
 				int node_num,
 				void *data)
 {
@@ -1059,7 +916,7 @@
 static struct hb_callback_func	*net_hb_down = NULL;
 #define NET_HB_NODE_DOWN_PRI     (0x1)
 
-static int net_register_hb_callbacks(void)
+int net_register_hb_callbacks(void)
 {
 	net_hb_down = kmalloc(sizeof(*net_hb_down), GFP_KERNEL);
 	if (!net_hb_down)
@@ -1071,7 +928,7 @@
 	return hb_register_callback(net_hb_down);
 }
 
-static void net_unregister_hb_callbacks(void)
+void net_unregister_hb_callbacks(void)
 {
 	int status;
 
@@ -1136,7 +993,6 @@
 	if (syserr != NET_ERR_NONE)
 		goto out_respond;
 
-	net_num_dispatched++;
 	ret = (hnd->func)(hdr, sizeof(net_msg) + hdr->data_len, hnd->data);
 
 out_respond:
@@ -1284,7 +1140,7 @@
 	state_change(sk);
 }	
 
-static int net_start_connect(net_inode_private *net, nm_node_info *node)
+static int net_start_connect(net_inode_private *net, u32 addr, u16 port)
 {
 	struct socket *sock = NULL;
 	struct sock *sk;
@@ -1308,9 +1164,9 @@
 	}
 	
 	memset (&remoteaddr, 0, sizeof (remoteaddr));
-	remoteaddr.sin_family = net_ip_version_to_family(node->ifaces[0].ip_version);
-	remoteaddr.sin_addr.s_addr = node->ifaces[0].addr_u.ip_addr4;
-	remoteaddr.sin_port = node->ifaces[0].ip_port;
+	remoteaddr.sin_family = AF_INET;
+	remoteaddr.sin_addr.s_addr = addr;
+	remoteaddr.sin_port = port;
 
 	net->sock = sock;
 
@@ -1363,19 +1219,14 @@
 	set_fs(oldfs);
 }
 
-static void net_sock_decref(struct inode *inode, int error)
+static void net_sock_decref(struct socket *sock, int error)
 {
 	net_inode_private *net = NULL;
-	nm_node_inode_private *priv;
-	struct socket *sock = NULL;
 	int release = 0;
 
-	priv = inode->u.generic_ip;
-	if (!priv) {
-		netprintk("bad inode %p\n", inode);
-		return;
-	}
-	net = &priv->net;
+	/* we hold a ref, this should be stable */
+	net = sock->sk->sk_user_data;
+	BUG_ON(net == NULL);
 
 	spin_lock_bh(&net->sock_lock); 
 
@@ -1426,7 +1277,6 @@
 
 static int net_sock_addref_or_connect(u8 target_node, struct socket **sock_ret)
 {
-	nm_node_inode_private *priv;
 	struct nm_node *node = NULL;
 	net_inode_private *net = NULL;
 	struct socket *sock = NULL;
@@ -1434,12 +1284,13 @@
 	struct waiting_for_sock wfs;
 
 	/* XXX think about passing refs around.. */
-	node = get_node_by_num(target_node);
+	node = nm_get_node_by_num(target_node);
 	if (node == NULL) {
 		netprintk("node %u unknown\n", target_node);
 		ret = -EINVAL;
 		goto out;
 	}
+	/* XXX verify that node is fully configured, rx thread is going */
 	net = &node->nd_net_inode_private;
 
 	spin_lock_bh(&net->sock_lock); 
@@ -1463,7 +1314,8 @@
 	spin_unlock_bh(&net->sock_lock); 
 
 	if (set_pending) {
-		ret = net_start_connect(net, node);
+		ret = net_start_connect(net, node->nd_ipv4_address,
+					node->nd_ipv4_port);
 		if (ret)
 			goto out;
 	}
@@ -1513,8 +1365,7 @@
 	int error, slen;
 	struct sockaddr_in sin;
 	struct socket *new_sock = NULL;
-	struct inode *inode = NULL;
-	nm_node_inode_private *priv;
+	struct nm_node *node = NULL;
 
 	BUG_ON(sock == NULL);
 	error = sock_create_lite(sock->sk->sk_family,
@@ -1539,24 +1390,21 @@
 	netprintk("attempt to connect from %u.%u.%u.%u:%04x\n", 
 		NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port));
 
-	inode = nm_get_node_by_ip(sin.sin_addr.s_addr);
-	if (inode == NULL) {
+	node = nm_get_node_by_ip(sin.sin_addr.s_addr);
+	if (node == NULL) {
 		netprintk0("connect from unknown host...\n");
 		net_send_error(new_sock, NET_UNKNOWN_HOST);
 		goto out;
 	}
 
-	priv = inode->u.generic_ip;
-	BUG_ON(priv == NULL);
+	netprintk("connect from known host: %s\n", node->nd_name);
 
-	netprintk("connect from known host: %s\n", priv->node.node_name);
-
 	if (ntohs(sin.sin_port) >= 1024)
 		netprintk("warning: connect from unprivileged port: "
 			  "%u.%u.%u.%u:%d\n", NIPQUAD(sin.sin_addr.s_addr),
 			  ntohs(sin.sin_port));
 
-	error = net_attach_sock(&priv->net, new_sock);
+	error = net_attach_sock(&node->nd_net_inode_private, new_sock);
 	if (error == -EEXIST)
 		net_send_error(new_sock, NET_ALREADY_CONNECTED);
 
@@ -1566,36 +1414,33 @@
 			net_sock_drain(new_sock);
 			sock_release(new_sock);
 		}
-		if (inode)
-			iput(inode);
 	}
+	if (node)
+		nm_node_put(node);
 	return;
 }
 
-static struct socket *net_init_tcp_recv_sock(void)
+static struct socket *net_init_tcp_recv_sock(u16 port)
 {
 	struct sockaddr_in sin;
 	struct socket *sock;
 	int error;
 
-	error = sock_create(net_ip_version_to_family(ip_version),
-			     SOCK_STREAM, IPPROTO_TCP,
-			     &sock);
+	error = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
 	if (error < 0) {
 		netprintk("unable to create socket, error=%d\n", error);
 		goto bail;
 	}
 
 	memset(&sin, 0, sizeof(sin));
-	sin.sin_family = net_ip_version_to_family(ip_version);
+	sin.sin_family = PF_INET;
 	sin.sin_addr.s_addr = htonl(INADDR_ANY);
-	sin.sin_port = ip_port;
+	sin.sin_port = port;
 
-	error = sock->ops->bind(sock, (struct sockaddr *)&sin,
-				sizeof(sin));
+	error = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin));
 	if (error < 0) {
 		netprintk ("unable to bind socket to port %d, error=%d\n", 
-			ntohs(ip_port), error);
+			ntohs(port), error);
 		goto bail;
 	}
 

Modified: branches/usysfsify/fs/ocfs2/cluster/tcp.h
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/tcp.h	2005-03-16 19:14:57 UTC (rev 1984)
+++ branches/usysfsify/fs/ocfs2/cluster/tcp.h	2005-03-16 21:30:19 UTC (rev 1985)
@@ -48,9 +48,6 @@
 #include "ocfs2_tcp.h"
 
 
-#define NET_DISP_THREAD_MS   5000   /* TODO */
-#define NET_RECV_THREAD_MS   5000   /* TODO */
-
 enum net_system_error {
 	NET_ERR_NONE = 0,
 	NET_ERR_NO_HNDLR,
@@ -154,24 +151,6 @@
 }
 
 
-static inline int net_ip_version_to_family(u16 ip_version)
-{
-	printk("ip_version passed: %u, host byteorder: %u\n", ip_version, ntohs(ip_version));
-	return PF_INET;
-	switch (ntohs(ip_version)) {
-		case 4:
-			return PF_INET;
-		case 6:
-			return PF_INET6;
-		default:
-			BUG();
-	}
-
-	return 4;
-}
-
-
-
 /* TODO: figure this out.... */
 static inline int net_link_down(int err, struct socket *sock)
 {
@@ -215,10 +194,15 @@
 int net_send_message(u32 msg_type, u32 key, void *data, u32 len,
 		     u8 target_node, int *status);
 int net_send_message_iov(u32 msg_type, u32 key, struct iovec *iov,
-			 size_t iovlen, struct inode *inode, int *status);
+			 size_t iovlen, u8 target_node, int *status);
 int net_broadcast_message(u32 msg_type, u32 key, void *data, u32 len, struct inode *group);
 net_msg_handler * net_lookup_handler(u32 msg_type, u32 key);
 
+int net_register_hb_callbacks(void);
+void net_unregister_hb_callbacks(void);
+int net_start_rx_thread(struct nm_node *node);
+void net_stop_rx_thread(struct nm_node *node);
+
 #define GSD_MESSAGE   130
 #define GSD_ACTION_ADD_GROUP        (0x01)
 #define GSD_ACTION_ADD_GROUP_NODE   (0x02)



More information about the Ocfs2-commits mailing list