Skip to contentSkip to conversation

ocfs2/net: Add debug interface to o2net

PATCH New Sunil Mushran 1 participant 1 message Apr 14, 2008 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2/net: Add debug interface to o2net

This patch exposes o2net information via debugfs. The information includes the list of sockets (sock_containers) as well as the list of outstanding messages (send_tracking). Useful for o2dlm debugging.

(This patch is derived from an earlier one written by Zach Brown that exposed the same information via /proc.)

[Mark: checkpatch fixes]

---
 fs/ocfs2/cluster/Makefile       |    2 +-
 fs/ocfs2/cluster/netdebug.c     |  441 +++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/cluster/nodemanager.c  |    5 +-
 fs/ocfs2/cluster/tcp.c          |   68 ++++++
 fs/ocfs2/cluster/tcp.h          |   32 +++
 fs/ocfs2/cluster/tcp_internal.h |   24 ++-
 6 files changed, 569 insertions(+), 3 deletions(-)
 create mode 100644 fs/ocfs2/cluster/netdebug.c
fs/ocfs2/cluster/Makefile +1 -1
index cdd162f..bc8c5e7 100644
@@ -1,4 +1,4 @@
 obj-$(CONFIG_OCFS2_FS) += ocfs2_nodemanager.o
 
 ocfs2_nodemanager-objs := heartbeat.o masklog.o sys.o nodemanager.o \
-	quorum.o tcp.o ver.o
+	quorum.o tcp.o netdebug.o ver.o
fs/ocfs2/cluster/netdebug.c new file +441 -0

441 lines not on this page · raw message

fs/ocfs2/cluster/nodemanager.c +4 -1
index 709fba2..cf9401e 100644
@@ -959,7 +959,10 @@ static int __init init_o2nm(void)
 	cluster_print_version();
 
 	o2hb_init();
-	o2net_init();
+
+	ret = o2net_init();
+	if (ret)
+		goto out;
 
 	ocfs2_table_header = register_sysctl_table(ocfs2_root_table);
 	if (!ocfs2_table_header) {
fs/ocfs2/cluster/tcp.c +68 -0

132 lines not on this page · raw message

fs/ocfs2/cluster/tcp.h +32 -0
index f36f66a..a705d5d 100644
@@ -117,4 +117,36 @@ int o2net_num_connected_peers(void);
 int o2net_init(void);
 void o2net_exit(void);
 
+struct o2net_send_tracking;
+struct o2net_sock_container;
+
+#ifdef CONFIG_DEBUG_FS
+int o2net_debugfs_init(void);
+void o2net_debugfs_exit(void);
+void o2net_debug_add_nst(struct o2net_send_tracking *nst);
+void o2net_debug_del_nst(struct o2net_send_tracking *nst);
+void o2net_debug_add_sc(struct o2net_sock_container *sc);
+void o2net_debug_del_sc(struct o2net_sock_container *sc);
+#else
+static int o2net_debugfs_init(void)
+{
+	return 0;
+}
+static void o2net_debugfs_exit(void)
+{
+}
+static void o2net_debug_add_nst(struct o2net_send_tracking *nst)
+{
+}
+static void o2net_debug_del_nst(struct o2net_send_tracking *nst)
+{
+}
+static void o2net_debug_add_sc(struct o2net_sock_container *sc)
+{
+}
+static void o2net_debug_del_sc(struct o2net_sock_container *sc)
+{
+}
+#endif	/* CONFIG_DEBUG_FS */
+
 #endif /* O2CLUSTER_TCP_H */
fs/ocfs2/cluster/tcp_internal.h +23 -1
index b4c5586..8d58cfe 100644
@@ -166,7 +166,9 @@ struct o2net_sock_container {
 	/* original handlers for the sockets */
 	void			(*sc_state_change)(struct sock *sk);
 	void			(*sc_data_ready)(struct sock *sk, int bytes);
-
+#ifdef CONFIG_DEBUG_FS
+	struct list_head        sc_net_debug_item;
+#endif
 	struct timeval 		sc_tv_timer;
 	struct timeval 		sc_tv_data_ready;
 	struct timeval 		sc_tv_advance_start;
@@ -208,4 +210,24 @@ struct o2net_status_wait {
 	struct list_head	ns_node_item;
 };
 
+#ifdef CONFIG_DEBUG_FS
+/* just for state dumps */
+struct o2net_send_tracking {
+	struct list_head		st_net_debug_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;
+	struct timeval			st_sock_time;
+	struct timeval			st_send_time;
+	struct timeval			st_status_time;
+};
+#else
+struct o2net_send_tracking {
+	u32	dummy;
+};
+#endif	/* CONFIG_DEBUG_FS */
+
 #endif /* O2CLUSTER_TCP_INTERNAL_H */
Signature · 1 line
1.5.3.6