diff options
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/cluster/heartbeat.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index b06b9e52fba8..f28de4b09c6b 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
@@ -79,6 +79,8 @@ static unsigned long o2hb_failed_region_bitmap[BITS_TO_LONGS(O2NM_MAX_REGIONS)]; | |||
79 | #define O2HB_DB_TYPE_LIVEREGIONS 1 | 79 | #define O2HB_DB_TYPE_LIVEREGIONS 1 |
80 | #define O2HB_DB_TYPE_QUORUMREGIONS 2 | 80 | #define O2HB_DB_TYPE_QUORUMREGIONS 2 |
81 | #define O2HB_DB_TYPE_FAILEDREGIONS 3 | 81 | #define O2HB_DB_TYPE_FAILEDREGIONS 3 |
82 | #define O2HB_DB_TYPE_REGION_LIVENODES 4 | ||
83 | #define O2HB_DB_TYPE_REGION_NUMBER 5 | ||
82 | struct o2hb_debug_buf { | 84 | struct o2hb_debug_buf { |
83 | int db_type; | 85 | int db_type; |
84 | int db_size; | 86 | int db_size; |
@@ -96,6 +98,7 @@ static struct o2hb_debug_buf *o2hb_db_failedregions; | |||
96 | #define O2HB_DEBUG_LIVEREGIONS "live_regions" | 98 | #define O2HB_DEBUG_LIVEREGIONS "live_regions" |
97 | #define O2HB_DEBUG_QUORUMREGIONS "quorum_regions" | 99 | #define O2HB_DEBUG_QUORUMREGIONS "quorum_regions" |
98 | #define O2HB_DEBUG_FAILEDREGIONS "failed_regions" | 100 | #define O2HB_DEBUG_FAILEDREGIONS "failed_regions" |
101 | #define O2HB_DEBUG_REGION_NUMBER "num" | ||
99 | 102 | ||
100 | static struct dentry *o2hb_debug_dir; | 103 | static struct dentry *o2hb_debug_dir; |
101 | static struct dentry *o2hb_debug_livenodes; | 104 | static struct dentry *o2hb_debug_livenodes; |
@@ -203,6 +206,12 @@ struct o2hb_region { | |||
203 | unsigned long hr_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; | 206 | unsigned long hr_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; |
204 | unsigned int hr_region_num; | 207 | unsigned int hr_region_num; |
205 | 208 | ||
209 | struct dentry *hr_debug_dir; | ||
210 | struct dentry *hr_debug_livenodes; | ||
211 | struct dentry *hr_debug_regnum; | ||
212 | struct o2hb_debug_buf *hr_db_livenodes; | ||
213 | struct o2hb_debug_buf *hr_db_regnum; | ||
214 | |||
206 | /* let the person setting up hb wait for it to return until it | 215 | /* let the person setting up hb wait for it to return until it |
207 | * has reached a 'steady' state. This will be fixed when we have | 216 | * has reached a 'steady' state. This will be fixed when we have |
208 | * a more complete api that doesn't lead to this sort of fragility. */ | 217 | * a more complete api that doesn't lead to this sort of fragility. */ |
@@ -1083,6 +1092,7 @@ static int o2hb_thread(void *data) | |||
1083 | static int o2hb_debug_open(struct inode *inode, struct file *file) | 1092 | static int o2hb_debug_open(struct inode *inode, struct file *file) |
1084 | { | 1093 | { |
1085 | struct o2hb_debug_buf *db = inode->i_private; | 1094 | struct o2hb_debug_buf *db = inode->i_private; |
1095 | struct o2hb_region *reg; | ||
1086 | unsigned long map[BITS_TO_LONGS(O2NM_MAX_NODES)]; | 1096 | unsigned long map[BITS_TO_LONGS(O2NM_MAX_NODES)]; |
1087 | char *buf = NULL; | 1097 | char *buf = NULL; |
1088 | int i = -1; | 1098 | int i = -1; |
@@ -1105,6 +1115,19 @@ static int o2hb_debug_open(struct inode *inode, struct file *file) | |||
1105 | spin_unlock(&o2hb_live_lock); | 1115 | spin_unlock(&o2hb_live_lock); |
1106 | break; | 1116 | break; |
1107 | 1117 | ||
1118 | case O2HB_DB_TYPE_REGION_LIVENODES: | ||
1119 | spin_lock(&o2hb_live_lock); | ||
1120 | reg = (struct o2hb_region *)db->db_data; | ||
1121 | memcpy(map, reg->hr_live_node_bitmap, db->db_size); | ||
1122 | spin_unlock(&o2hb_live_lock); | ||
1123 | break; | ||
1124 | |||
1125 | case O2HB_DB_TYPE_REGION_NUMBER: | ||
1126 | reg = (struct o2hb_region *)db->db_data; | ||
1127 | out += snprintf(buf + out, PAGE_SIZE - out, "%d\n", | ||
1128 | reg->hr_region_num); | ||
1129 | goto done; | ||
1130 | |||
1108 | default: | 1131 | default: |
1109 | goto done; | 1132 | goto done; |
1110 | } | 1133 | } |
@@ -1342,6 +1365,12 @@ static void o2hb_region_release(struct config_item *item) | |||
1342 | if (reg->hr_slots) | 1365 | if (reg->hr_slots) |
1343 | kfree(reg->hr_slots); | 1366 | kfree(reg->hr_slots); |
1344 | 1367 | ||
1368 | kfree(reg->hr_db_regnum); | ||
1369 | kfree(reg->hr_db_livenodes); | ||
1370 | debugfs_remove(reg->hr_debug_livenodes); | ||
1371 | debugfs_remove(reg->hr_debug_regnum); | ||
1372 | debugfs_remove(reg->hr_debug_dir); | ||
1373 | |||
1345 | spin_lock(&o2hb_live_lock); | 1374 | spin_lock(&o2hb_live_lock); |
1346 | list_del(®->hr_all_item); | 1375 | list_del(®->hr_all_item); |
1347 | spin_unlock(&o2hb_live_lock); | 1376 | spin_unlock(&o2hb_live_lock); |
@@ -1856,10 +1885,52 @@ static struct o2hb_heartbeat_group *to_o2hb_heartbeat_group(struct config_group | |||
1856 | : NULL; | 1885 | : NULL; |
1857 | } | 1886 | } |
1858 | 1887 | ||
1888 | static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir) | ||
1889 | { | ||
1890 | int ret = -ENOMEM; | ||
1891 | |||
1892 | reg->hr_debug_dir = | ||
1893 | debugfs_create_dir(config_item_name(®->hr_item), dir); | ||
1894 | if (!reg->hr_debug_dir) { | ||
1895 | mlog_errno(ret); | ||
1896 | goto bail; | ||
1897 | } | ||
1898 | |||
1899 | reg->hr_debug_livenodes = | ||
1900 | o2hb_debug_create(O2HB_DEBUG_LIVENODES, | ||
1901 | reg->hr_debug_dir, | ||
1902 | &(reg->hr_db_livenodes), | ||
1903 | sizeof(*(reg->hr_db_livenodes)), | ||
1904 | O2HB_DB_TYPE_REGION_LIVENODES, | ||
1905 | sizeof(reg->hr_live_node_bitmap), | ||
1906 | O2NM_MAX_NODES, reg); | ||
1907 | if (!reg->hr_debug_livenodes) { | ||
1908 | mlog_errno(ret); | ||
1909 | goto bail; | ||
1910 | } | ||
1911 | |||
1912 | reg->hr_debug_regnum = | ||
1913 | o2hb_debug_create(O2HB_DEBUG_REGION_NUMBER, | ||
1914 | reg->hr_debug_dir, | ||
1915 | &(reg->hr_db_regnum), | ||
1916 | sizeof(*(reg->hr_db_regnum)), | ||
1917 | O2HB_DB_TYPE_REGION_NUMBER, | ||
1918 | 0, O2NM_MAX_NODES, reg); | ||
1919 | if (!reg->hr_debug_regnum) { | ||
1920 | mlog_errno(ret); | ||
1921 | goto bail; | ||
1922 | } | ||
1923 | |||
1924 | ret = 0; | ||
1925 | bail: | ||
1926 | return ret; | ||
1927 | } | ||
1928 | |||
1859 | static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *group, | 1929 | static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *group, |
1860 | const char *name) | 1930 | const char *name) |
1861 | { | 1931 | { |
1862 | struct o2hb_region *reg = NULL; | 1932 | struct o2hb_region *reg = NULL; |
1933 | int ret; | ||
1863 | 1934 | ||
1864 | reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); | 1935 | reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); |
1865 | if (reg == NULL) | 1936 | if (reg == NULL) |
@@ -1884,6 +1955,12 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g | |||
1884 | 1955 | ||
1885 | config_item_init_type_name(®->hr_item, name, &o2hb_region_type); | 1956 | config_item_init_type_name(®->hr_item, name, &o2hb_region_type); |
1886 | 1957 | ||
1958 | ret = o2hb_debug_region_init(reg, o2hb_debug_dir); | ||
1959 | if (ret) { | ||
1960 | config_item_put(®->hr_item); | ||
1961 | return ERR_PTR(ret); | ||
1962 | } | ||
1963 | |||
1887 | return ®->hr_item; | 1964 | return ®->hr_item; |
1888 | } | 1965 | } |
1889 | 1966 | ||