diff options
author | Sunil Mushran <sunil.mushran@oracle.com> | 2008-12-17 17:17:42 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-04-03 14:39:14 -0400 |
commit | 87d3d3f3931f3e0fca44fbb5c06ad45fc4dca9bc (patch) | |
tree | 3f707f7b29905975b054906df0317f833cd411a0 /fs/ocfs2/cluster | |
parent | 20bec8ab1458c24bed0d5492ee15d87807fc415a (diff) |
ocfs2/hb: Expose the list of heartbeating nodes via debugfs
This patch creates a debugfs file, o2hb/livesnodes, which exposes the
aggregate list of heartbeating node across all heartbeat regions.
Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/cluster')
-rw-r--r-- | fs/ocfs2/cluster/heartbeat.c | 96 | ||||
-rw-r--r-- | fs/ocfs2/cluster/heartbeat.h | 3 | ||||
-rw-r--r-- | fs/ocfs2/cluster/nodemanager.c | 9 |
3 files changed, 104 insertions, 4 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 04697ba7f73e..4f85eceab376 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/random.h> | 33 | #include <linux/random.h> |
34 | #include <linux/crc32.h> | 34 | #include <linux/crc32.h> |
35 | #include <linux/time.h> | 35 | #include <linux/time.h> |
36 | #include <linux/debugfs.h> | ||
36 | 37 | ||
37 | #include "heartbeat.h" | 38 | #include "heartbeat.h" |
38 | #include "tcp.h" | 39 | #include "tcp.h" |
@@ -60,6 +61,11 @@ static unsigned long o2hb_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; | |||
60 | static LIST_HEAD(o2hb_node_events); | 61 | static LIST_HEAD(o2hb_node_events); |
61 | static DECLARE_WAIT_QUEUE_HEAD(o2hb_steady_queue); | 62 | static DECLARE_WAIT_QUEUE_HEAD(o2hb_steady_queue); |
62 | 63 | ||
64 | #define O2HB_DEBUG_DIR "o2hb" | ||
65 | #define O2HB_DEBUG_LIVENODES "livenodes" | ||
66 | static struct dentry *o2hb_debug_dir; | ||
67 | static struct dentry *o2hb_debug_livenodes; | ||
68 | |||
63 | static LIST_HEAD(o2hb_all_regions); | 69 | static LIST_HEAD(o2hb_all_regions); |
64 | 70 | ||
65 | static struct o2hb_callback { | 71 | static struct o2hb_callback { |
@@ -905,7 +911,77 @@ static int o2hb_thread(void *data) | |||
905 | return 0; | 911 | return 0; |
906 | } | 912 | } |
907 | 913 | ||
908 | void o2hb_init(void) | 914 | #ifdef CONFIG_DEBUG_FS |
915 | static int o2hb_debug_open(struct inode *inode, struct file *file) | ||
916 | { | ||
917 | unsigned long map[BITS_TO_LONGS(O2NM_MAX_NODES)]; | ||
918 | char *buf = NULL; | ||
919 | int i = -1; | ||
920 | int out = 0; | ||
921 | |||
922 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
923 | if (!buf) | ||
924 | goto bail; | ||
925 | |||
926 | o2hb_fill_node_map(map, sizeof(map)); | ||
927 | |||
928 | while ((i = find_next_bit(map, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) | ||
929 | out += snprintf(buf + out, PAGE_SIZE - out, "%d ", i); | ||
930 | out += snprintf(buf + out, PAGE_SIZE - out, "\n"); | ||
931 | |||
932 | i_size_write(inode, out); | ||
933 | |||
934 | file->private_data = buf; | ||
935 | |||
936 | return 0; | ||
937 | bail: | ||
938 | return -ENOMEM; | ||
939 | } | ||
940 | |||
941 | static int o2hb_debug_release(struct inode *inode, struct file *file) | ||
942 | { | ||
943 | kfree(file->private_data); | ||
944 | return 0; | ||
945 | } | ||
946 | |||
947 | static ssize_t o2hb_debug_read(struct file *file, char __user *buf, | ||
948 | size_t nbytes, loff_t *ppos) | ||
949 | { | ||
950 | return simple_read_from_buffer(buf, nbytes, ppos, file->private_data, | ||
951 | i_size_read(file->f_mapping->host)); | ||
952 | } | ||
953 | #else | ||
954 | static int o2hb_debug_open(struct inode *inode, struct file *file) | ||
955 | { | ||
956 | return 0; | ||
957 | } | ||
958 | static int o2hb_debug_release(struct inode *inode, struct file *file) | ||
959 | { | ||
960 | return 0; | ||
961 | } | ||
962 | static ssize_t o2hb_debug_read(struct file *file, char __user *buf, | ||
963 | size_t nbytes, loff_t *ppos) | ||
964 | { | ||
965 | return 0; | ||
966 | } | ||
967 | #endif /* CONFIG_DEBUG_FS */ | ||
968 | |||
969 | static struct file_operations o2hb_debug_fops = { | ||
970 | .open = o2hb_debug_open, | ||
971 | .release = o2hb_debug_release, | ||
972 | .read = o2hb_debug_read, | ||
973 | .llseek = generic_file_llseek, | ||
974 | }; | ||
975 | |||
976 | void o2hb_exit(void) | ||
977 | { | ||
978 | if (o2hb_debug_livenodes) | ||
979 | debugfs_remove(o2hb_debug_livenodes); | ||
980 | if (o2hb_debug_dir) | ||
981 | debugfs_remove(o2hb_debug_dir); | ||
982 | } | ||
983 | |||
984 | int o2hb_init(void) | ||
909 | { | 985 | { |
910 | int i; | 986 | int i; |
911 | 987 | ||
@@ -918,6 +994,24 @@ void o2hb_init(void) | |||
918 | INIT_LIST_HEAD(&o2hb_node_events); | 994 | INIT_LIST_HEAD(&o2hb_node_events); |
919 | 995 | ||
920 | memset(o2hb_live_node_bitmap, 0, sizeof(o2hb_live_node_bitmap)); | 996 | memset(o2hb_live_node_bitmap, 0, sizeof(o2hb_live_node_bitmap)); |
997 | |||
998 | o2hb_debug_dir = debugfs_create_dir(O2HB_DEBUG_DIR, NULL); | ||
999 | if (!o2hb_debug_dir) { | ||
1000 | mlog_errno(-ENOMEM); | ||
1001 | return -ENOMEM; | ||
1002 | } | ||
1003 | |||
1004 | o2hb_debug_livenodes = debugfs_create_file(O2HB_DEBUG_LIVENODES, | ||
1005 | S_IFREG|S_IRUSR, | ||
1006 | o2hb_debug_dir, NULL, | ||
1007 | &o2hb_debug_fops); | ||
1008 | if (!o2hb_debug_livenodes) { | ||
1009 | mlog_errno(-ENOMEM); | ||
1010 | debugfs_remove(o2hb_debug_dir); | ||
1011 | return -ENOMEM; | ||
1012 | } | ||
1013 | |||
1014 | return 0; | ||
921 | } | 1015 | } |
922 | 1016 | ||
923 | /* if we're already in a callback then we're already serialized by the sem */ | 1017 | /* if we're already in a callback then we're already serialized by the sem */ |
diff --git a/fs/ocfs2/cluster/heartbeat.h b/fs/ocfs2/cluster/heartbeat.h index e511339886b3..2f1649253b49 100644 --- a/fs/ocfs2/cluster/heartbeat.h +++ b/fs/ocfs2/cluster/heartbeat.h | |||
@@ -75,7 +75,8 @@ void o2hb_unregister_callback(const char *region_uuid, | |||
75 | struct o2hb_callback_func *hc); | 75 | struct o2hb_callback_func *hc); |
76 | void o2hb_fill_node_map(unsigned long *map, | 76 | void o2hb_fill_node_map(unsigned long *map, |
77 | unsigned bytes); | 77 | unsigned bytes); |
78 | void o2hb_init(void); | 78 | void o2hb_exit(void); |
79 | int o2hb_init(void); | ||
79 | int o2hb_check_node_heartbeating(u8 node_num); | 80 | int o2hb_check_node_heartbeating(u8 node_num); |
80 | int o2hb_check_node_heartbeating_from_callback(u8 node_num); | 81 | int o2hb_check_node_heartbeating_from_callback(u8 node_num); |
81 | int o2hb_check_local_node_heartbeating(void); | 82 | int o2hb_check_local_node_heartbeating(void); |
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index 70e8fa9e2539..7ee6188bc79a 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c | |||
@@ -881,6 +881,7 @@ static void __exit exit_o2nm(void) | |||
881 | o2cb_sys_shutdown(); | 881 | o2cb_sys_shutdown(); |
882 | 882 | ||
883 | o2net_exit(); | 883 | o2net_exit(); |
884 | o2hb_exit(); | ||
884 | } | 885 | } |
885 | 886 | ||
886 | static int __init init_o2nm(void) | 887 | static int __init init_o2nm(void) |
@@ -889,11 +890,13 @@ static int __init init_o2nm(void) | |||
889 | 890 | ||
890 | cluster_print_version(); | 891 | cluster_print_version(); |
891 | 892 | ||
892 | o2hb_init(); | 893 | ret = o2hb_init(); |
894 | if (ret) | ||
895 | goto out; | ||
893 | 896 | ||
894 | ret = o2net_init(); | 897 | ret = o2net_init(); |
895 | if (ret) | 898 | if (ret) |
896 | goto out; | 899 | goto out_o2hb; |
897 | 900 | ||
898 | ret = o2net_register_hb_callbacks(); | 901 | ret = o2net_register_hb_callbacks(); |
899 | if (ret) | 902 | if (ret) |
@@ -916,6 +919,8 @@ out_callbacks: | |||
916 | o2net_unregister_hb_callbacks(); | 919 | o2net_unregister_hb_callbacks(); |
917 | out_o2net: | 920 | out_o2net: |
918 | o2net_exit(); | 921 | o2net_exit(); |
922 | out_o2hb: | ||
923 | o2hb_exit(); | ||
919 | out: | 924 | out: |
920 | return ret; | 925 | return ret; |
921 | } | 926 | } |