[Ocfs2-commits] smushran commits r2905 - branches/ocfs2-1.2/fs/ocfs2/cluster

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Thu Apr 20 17:43:39 CDT 2006


Author: smushran
Signed-off-by: mfasheh
Signed-off-by: zab
Date: 2006-04-20 17:43:38 -0500 (Thu, 20 Apr 2006)
New Revision: 2905

Modified:
   branches/ocfs2-1.2/fs/ocfs2/cluster/net_proc.c
   branches/ocfs2-1.2/fs/ocfs2/cluster/tcp.c
   branches/ocfs2-1.2/fs/ocfs2/cluster/tcp_internal.h
Log:
Replace idr with u32 in tcp
Signed-off-by: mfasheh
Signed-off-by: zab

Modified: branches/ocfs2-1.2/fs/ocfs2/cluster/net_proc.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/cluster/net_proc.c	2006-04-20 20:23:26 UTC (rev 2904)
+++ branches/ocfs2-1.2/fs/ocfs2/cluster/net_proc.c	2006-04-20 22:43:38 UTC (rev 2905)
@@ -117,6 +117,7 @@
 			   "  process name: %s\n"
 			   "  node:         %u\n"
 			   "  sc:           %p\n"
+			   "  message id:   %d\n"
 			   "  message type: %u\n"
 			   "  message key:  0x%08x\n"
 			   "  sock acquiry: %lu.%lu\n"
@@ -125,7 +126,8 @@
 			   nst, (unsigned long)nst->st_task->pid,
 			   (unsigned long)nst->st_task->tgid,
 			   nst->st_task->comm, nst->st_node,
-			   nst->st_sc, nst->st_msg_type, nst->st_msg_key,
+			   nst->st_sc, nst->st_id, nst->st_msg_type,
+			   nst->st_msg_key,
 			   nst->st_sock_time.tv_sec, nst->st_sock_time.tv_usec,
 			   nst->st_send_time.tv_sec, nst->st_send_time.tv_usec,
 			   nst->st_status_time.tv_sec,
@@ -253,6 +255,8 @@
 	return sc; /* unused, just needs to be null when done */
 }
 
+#define TV_SEC_USEC(TV) TV.tv_sec, TV.tv_usec
+
 static int sc_seq_show(struct seq_file *seq, void *v)
 {
 	struct o2net_sock_container *sc, *dummy_sc = seq->private;
@@ -285,11 +289,31 @@
 			   "  krefs:           %d\n"
 			   "  sock:            %u.%u.%u.%u:%u -> %u.%u.%u.%u:%u\n"
 			   "  remote node:     %s\n"
-			   "  page off:        %zu\n",
-			   sc, atomic_read(&sc->sc_kref.refcount),
+			   "  page off:        %zu\n"
+			   "  handshake ok:    %u\n"
+			   "  timer:           %lu.%lu\n"
+			   "  data ready:      %lu.%lu\n"
+			   "  advance start:   %lu.%lu\n"
+			   "  advance stop:    %lu.%lu\n"
+			   "  func start:      %lu.%lu\n"
+			   "  func stop:       %lu.%lu\n"
+			   "  func key:        %u\n"
+			   "  func type:       %u\n",
+			   sc,
+			   atomic_read(&sc->sc_kref.refcount),
 			   NIPQUAD(saddr), inet ? ntohs(sport) : 0,
-			   NIPQUAD(daddr), inet ? ntohs(dport) : 0,
-			   sc->sc_node->nd_name, sc->sc_page_off);
+			   	NIPQUAD(daddr), inet ? ntohs(dport) : 0,
+			   sc->sc_node->nd_name,
+			   sc->sc_page_off,
+			   sc->sc_handshake_ok,
+			   TV_SEC_USEC(sc->sc_tv_timer),
+			   TV_SEC_USEC(sc->sc_tv_data_ready),
+			   TV_SEC_USEC(sc->sc_tv_advance_start),
+			   TV_SEC_USEC(sc->sc_tv_advance_stop),
+			   TV_SEC_USEC(sc->sc_tv_func_start),
+			   TV_SEC_USEC(sc->sc_tv_func_stop),
+			   sc->sc_msg_key,
+			   sc->sc_msg_type);
 	}
 
 

Modified: branches/ocfs2-1.2/fs/ocfs2/cluster/tcp.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/cluster/tcp.c	2006-04-20 20:23:26 UTC (rev 2904)
+++ branches/ocfs2-1.2/fs/ocfs2/cluster/tcp.c	2006-04-20 22:43:38 UTC (rev 2905)
@@ -56,7 +56,6 @@
 #include <linux/kernel.h>
 #include <linux/jiffies.h>
 #include <linux/slab.h>
-#include <linux/idr.h>
 #include <linux/kref.h>
 #include <net/tcp.h>
 
@@ -173,39 +172,18 @@
 
 /* ------------------------------------------------------------ */
 
-static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw)
+static void o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw)
 {
-	int ret = 0;
+	spin_lock(&nn->nn_lock);
 
-	do {
-		if (!idr_pre_get(&nn->nn_status_idr, GFP_ATOMIC)) {
-			ret = -EAGAIN;
-			break;
-		}
-		spin_lock(&nn->nn_lock);
-#ifndef IDR_GET_NEW_RETURNS_ID
-		ret = idr_get_new(&nn->nn_status_idr, nsw, &nsw->ns_id);
-#else
-		/* old semantics */
-		nsw->ns_id = idr_get_new(&nn->nn_status_idr, nsw);
-		if (nsw->ns_id < 0)
-			ret = -EAGAIN;
-		else
-			ret = 0;
-#endif
-		if (ret == 0)
-			list_add_tail(&nsw->ns_node_item,
-				      &nn->nn_status_list);
-		spin_unlock(&nn->nn_lock);
-	} while (ret == -EAGAIN);
+	nsw->ns_id = nn->nn_status_next_id++;
+	list_add_tail(&nsw->ns_node_item, &nn->nn_status_list);
 
-	if (ret == 0)  {
-		init_waitqueue_head(&nsw->ns_wq);
-		nsw->ns_sys_status = O2NET_ERR_NONE;
-		nsw->ns_status = 0;
-	}
+	spin_unlock(&nn->nn_lock);
 
-	return ret;
+	init_waitqueue_head(&nsw->ns_wq);
+	nsw->ns_sys_status = O2NET_ERR_NONE;
+	nsw->ns_status = 0;
 }
 
 static void o2net_complete_nsw_locked(struct o2net_node *nn,
@@ -219,31 +197,43 @@
 		list_del_init(&nsw->ns_node_item);
 		nsw->ns_sys_status = sys_status;
 		nsw->ns_status = status;
-		idr_remove(&nn->nn_status_idr, nsw->ns_id);
 		wake_up(&nsw->ns_wq);
 	}
 }
 
-static void o2net_complete_nsw(struct o2net_node *nn,
-			       struct o2net_status_wait *nsw,
-			       u64 id, enum o2net_system_error sys_status,
-			       s32 status)
+static void o2net_complete_nsw_id(struct o2net_node *nn, u32 id,
+				  enum o2net_system_error sys_status,
+				  s32 status)
 {
+	struct list_head *iter, *tmp;
+	struct o2net_status_wait *nsw;
+	int killed = 0;
+
 	spin_lock(&nn->nn_lock);
-	if (nsw == NULL) {
-		if (id > INT_MAX)
-			goto out;
 
-		nsw = idr_find(&nn->nn_status_idr, id);
-		if (nsw == NULL)
-			goto out;
+	list_for_each_safe(iter, tmp, &nn->nn_status_list) {
+		nsw = list_entry(iter, struct o2net_status_wait, ns_node_item);
+		if (id == nsw->ns_id) {
+			o2net_complete_nsw_locked(nn, nsw, sys_status, status);
+			killed = 1;
+			break;
+		}
 	}
 
-	o2net_complete_nsw_locked(nn, nsw, sys_status, status);
+	spin_unlock(&nn->nn_lock);
 
-out:
+	if (!killed)
+		mlog(ML_ERROR, "didn't find nsw for id %u\n", id);
+}
+
+static void o2net_complete_nsw(struct o2net_node *nn,
+			       struct o2net_status_wait *nsw,
+			       enum o2net_system_error sys_status,
+			       s32 status)
+{
+	spin_lock(&nn->nn_lock);
+	o2net_complete_nsw_locked(nn, nsw, sys_status, status);
 	spin_unlock(&nn->nn_lock);
-	return;
 }
 
 static void o2net_complete_nodes_nsw(struct o2net_node *nn)
@@ -951,11 +941,10 @@
 	vec[0].iov_base = msg;
 	memcpy(&vec[1], caller_vec, caller_veclen * sizeof(struct kvec));
 
-	ret = o2net_prep_nsw(nn, &nsw);
-	if (ret)
-		goto out;
+	o2net_prep_nsw(nn, &nsw);
 
 	msg->msg_num = cpu_to_be32(nsw.ns_id);
+	nst.st_id = nsw.ns_id;
 
 	do_gettimeofday(&nst.st_send_time);
 	/* finally, convert the message header to network byte-order
@@ -989,7 +978,7 @@
 		kfree(vec);
 	if (msg)
 		kfree(msg);
-	o2net_complete_nsw(nn, &nsw, 0, 0, 0);
+	o2net_complete_nsw(nn, &nsw, 0, 0);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(o2net_send_message_vec);
@@ -1045,10 +1034,9 @@
 	switch(be16_to_cpu(hdr->magic)) {
 		case O2NET_MSG_STATUS_MAGIC:
 			/* special type for returning message status */
-			o2net_complete_nsw(nn, NULL,
-					   be32_to_cpu(hdr->msg_num),
-					   be32_to_cpu(hdr->sys_status),
-					   be32_to_cpu(hdr->status));
+			o2net_complete_nsw_id(nn, be32_to_cpu(hdr->msg_num),
+					      be32_to_cpu(hdr->sys_status),
+					      be32_to_cpu(hdr->status));
 			goto out;
 		case O2NET_MSG_KEEP_REQ_MAGIC:
 			o2net_sendpage(sc, o2net_keep_resp,
@@ -1865,7 +1853,6 @@
 		/* until we see hb from a node we'll return einval */
 		nn->nn_persistent_error = -ENOTCONN;
 		init_waitqueue_head(&nn->nn_sc_wq);
-		idr_init(&nn->nn_status_idr);
 		INIT_LIST_HEAD(&nn->nn_status_list);
 	}
 

Modified: branches/ocfs2-1.2/fs/ocfs2/cluster/tcp_internal.h
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/cluster/tcp_internal.h	2006-04-20 20:23:26 UTC (rev 2904)
+++ branches/ocfs2-1.2/fs/ocfs2/cluster/tcp_internal.h	2006-04-20 22:43:38 UTC (rev 2905)
@@ -62,7 +62,7 @@
 	 * or fails or when an accepted socket is attached. */
 	wait_queue_head_t		nn_sc_wq;
 
-	struct idr			nn_status_idr;
+	u32				nn_status_next_id;
 	struct list_head		nn_status_list;
 
 	/* connects are attempted from when heartbeat comes up until either hb
@@ -160,7 +160,7 @@
 struct o2net_status_wait {
 	enum o2net_system_error	ns_sys_status;
 	s32			ns_status;
-	int			ns_id;
+	u32			ns_id;
 	wait_queue_head_t	ns_wq;
 	struct list_head	ns_node_item;
 };
@@ -170,6 +170,7 @@
 	struct list_head		st_net_proc_item;
 	struct task_struct		*st_task;
 	struct o2net_sock_container	*st_sc;
+	u32				st_id;
 	u32				st_msg_type;
 	u32				st_msg_key;
 	u8				st_node;




More information about the Ocfs2-commits mailing list