aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorSunil Mushran <sunil.mushran@oracle.com>2010-10-07 17:31:06 -0400
committerSunil Mushran <sunil.mushran@oracle.com>2010-10-07 17:31:06 -0400
commitb3c85c4cdf77154acc940dd0f14d1fb99cbbaf75 (patch)
treec88f7d311ba46650691768dffc90362db9129338 /fs/ocfs2
parentb1365d0bd14b912cceb424cbeed9fe939a9038e3 (diff)
ocfs2/cluster: Get all heartbeat regions
Export function in o2hb to get a list of heartbeat regions. It also adds an upper limit to the length of the heartbeat region name. o2hb_global_heartbeat_active() currently disables global heartbeat. It will be enabled in a later patch after all the code is added. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/cluster/heartbeat.c34
-rw-r--r--fs/ocfs2/cluster/heartbeat.h4
2 files changed, 38 insertions, 0 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 4d36459a8343..3415e58ff77b 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1623,6 +1623,9 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
1623 if (reg == NULL) 1623 if (reg == NULL)
1624 return ERR_PTR(-ENOMEM); 1624 return ERR_PTR(-ENOMEM);
1625 1625
1626 if (strlen(name) > O2HB_MAX_REGION_NAME_LEN)
1627 return ERR_PTR(-ENAMETOOLONG);
1628
1626 config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type); 1629 config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type);
1627 1630
1628 spin_lock(&o2hb_live_lock); 1631 spin_lock(&o2hb_live_lock);
@@ -2035,3 +2038,34 @@ void o2hb_stop_all_regions(void)
2035 spin_unlock(&o2hb_live_lock); 2038 spin_unlock(&o2hb_live_lock);
2036} 2039}
2037EXPORT_SYMBOL_GPL(o2hb_stop_all_regions); 2040EXPORT_SYMBOL_GPL(o2hb_stop_all_regions);
2041
2042int o2hb_get_all_regions(char *region_uuids, u8 max_regions)
2043{
2044 struct o2hb_region *reg;
2045 int numregs = 0;
2046 char *p;
2047
2048 spin_lock(&o2hb_live_lock);
2049
2050 p = region_uuids;
2051 list_for_each_entry(reg, &o2hb_all_regions, hr_all_item) {
2052 mlog(0, "Region: %s\n", config_item_name(&reg->hr_item));
2053 if (numregs < max_regions) {
2054 memcpy(p, config_item_name(&reg->hr_item),
2055 O2HB_MAX_REGION_NAME_LEN);
2056 p += O2HB_MAX_REGION_NAME_LEN;
2057 }
2058 numregs++;
2059 }
2060
2061 spin_unlock(&o2hb_live_lock);
2062
2063 return numregs;
2064}
2065EXPORT_SYMBOL_GPL(o2hb_get_all_regions);
2066
2067int o2hb_global_heartbeat_active(void)
2068{
2069 return 0;
2070}
2071EXPORT_SYMBOL(o2hb_global_heartbeat_active);
diff --git a/fs/ocfs2/cluster/heartbeat.h b/fs/ocfs2/cluster/heartbeat.h
index 2f1649253b49..00ad8e8fea51 100644
--- a/fs/ocfs2/cluster/heartbeat.h
+++ b/fs/ocfs2/cluster/heartbeat.h
@@ -31,6 +31,8 @@
31 31
32#define O2HB_REGION_TIMEOUT_MS 2000 32#define O2HB_REGION_TIMEOUT_MS 2000
33 33
34#define O2HB_MAX_REGION_NAME_LEN 32
35
34/* number of changes to be seen as live */ 36/* number of changes to be seen as live */
35#define O2HB_LIVE_THRESHOLD 2 37#define O2HB_LIVE_THRESHOLD 2
36/* number of equal samples to be seen as dead */ 38/* number of equal samples to be seen as dead */
@@ -81,5 +83,7 @@ int o2hb_check_node_heartbeating(u8 node_num);
81int o2hb_check_node_heartbeating_from_callback(u8 node_num); 83int o2hb_check_node_heartbeating_from_callback(u8 node_num);
82int o2hb_check_local_node_heartbeating(void); 84int o2hb_check_local_node_heartbeating(void);
83void o2hb_stop_all_regions(void); 85void o2hb_stop_all_regions(void);
86int o2hb_get_all_regions(char *region_uuids, u8 numregions);
87int o2hb_global_heartbeat_active(void);
84 88
85#endif /* O2CLUSTER_HEARTBEAT_H */ 89#endif /* O2CLUSTER_HEARTBEAT_H */