diff options
Diffstat (limited to 'fs/ocfs2/cluster/heartbeat.c')
-rw-r--r-- | fs/ocfs2/cluster/heartbeat.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 188f50269b89..d66b17c000d4 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
@@ -62,6 +62,12 @@ static unsigned long o2hb_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; | |||
62 | static LIST_HEAD(o2hb_node_events); | 62 | static LIST_HEAD(o2hb_node_events); |
63 | static DECLARE_WAIT_QUEUE_HEAD(o2hb_steady_queue); | 63 | static DECLARE_WAIT_QUEUE_HEAD(o2hb_steady_queue); |
64 | 64 | ||
65 | /* | ||
66 | * In global heartbeat, we maintain a series of region bitmaps. | ||
67 | * - o2hb_region_bitmap allows us to limit the region number to max region. | ||
68 | */ | ||
69 | static unsigned long o2hb_region_bitmap[BITS_TO_LONGS(O2NM_MAX_REGIONS)]; | ||
70 | |||
65 | #define O2HB_DB_TYPE_LIVENODES 0 | 71 | #define O2HB_DB_TYPE_LIVENODES 0 |
66 | struct o2hb_debug_buf { | 72 | struct o2hb_debug_buf { |
67 | int db_type; | 73 | int db_type; |
@@ -176,6 +182,7 @@ struct o2hb_region { | |||
176 | 182 | ||
177 | /* live node map of this region */ | 183 | /* live node map of this region */ |
178 | unsigned long hr_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; | 184 | unsigned long hr_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; |
185 | unsigned int hr_region_num; | ||
179 | 186 | ||
180 | /* let the person setting up hb wait for it to return until it | 187 | /* let the person setting up hb wait for it to return until it |
181 | * has reached a 'steady' state. This will be fixed when we have | 188 | * has reached a 'steady' state. This will be fixed when we have |
@@ -1127,6 +1134,7 @@ int o2hb_init(void) | |||
1127 | INIT_LIST_HEAD(&o2hb_node_events); | 1134 | INIT_LIST_HEAD(&o2hb_node_events); |
1128 | 1135 | ||
1129 | memset(o2hb_live_node_bitmap, 0, sizeof(o2hb_live_node_bitmap)); | 1136 | memset(o2hb_live_node_bitmap, 0, sizeof(o2hb_live_node_bitmap)); |
1137 | memset(o2hb_region_bitmap, 0, sizeof(o2hb_region_bitmap)); | ||
1130 | 1138 | ||
1131 | return o2hb_debug_init(); | 1139 | return o2hb_debug_init(); |
1132 | } | 1140 | } |
@@ -1716,12 +1724,22 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g | |||
1716 | if (strlen(name) > O2HB_MAX_REGION_NAME_LEN) | 1724 | if (strlen(name) > O2HB_MAX_REGION_NAME_LEN) |
1717 | return ERR_PTR(-ENAMETOOLONG); | 1725 | return ERR_PTR(-ENAMETOOLONG); |
1718 | 1726 | ||
1719 | config_item_init_type_name(®->hr_item, name, &o2hb_region_type); | ||
1720 | |||
1721 | spin_lock(&o2hb_live_lock); | 1727 | spin_lock(&o2hb_live_lock); |
1728 | reg->hr_region_num = 0; | ||
1729 | if (o2hb_global_heartbeat_active()) { | ||
1730 | reg->hr_region_num = find_first_zero_bit(o2hb_region_bitmap, | ||
1731 | O2NM_MAX_REGIONS); | ||
1732 | if (reg->hr_region_num >= O2NM_MAX_REGIONS) { | ||
1733 | spin_unlock(&o2hb_live_lock); | ||
1734 | return ERR_PTR(-EFBIG); | ||
1735 | } | ||
1736 | set_bit(reg->hr_region_num, o2hb_region_bitmap); | ||
1737 | } | ||
1722 | list_add_tail(®->hr_all_item, &o2hb_all_regions); | 1738 | list_add_tail(®->hr_all_item, &o2hb_all_regions); |
1723 | spin_unlock(&o2hb_live_lock); | 1739 | spin_unlock(&o2hb_live_lock); |
1724 | 1740 | ||
1741 | config_item_init_type_name(®->hr_item, name, &o2hb_region_type); | ||
1742 | |||
1725 | return ®->hr_item; | 1743 | return ®->hr_item; |
1726 | } | 1744 | } |
1727 | 1745 | ||
@@ -1733,6 +1751,8 @@ static void o2hb_heartbeat_group_drop_item(struct config_group *group, | |||
1733 | 1751 | ||
1734 | /* stop the thread when the user removes the region dir */ | 1752 | /* stop the thread when the user removes the region dir */ |
1735 | spin_lock(&o2hb_live_lock); | 1753 | spin_lock(&o2hb_live_lock); |
1754 | if (o2hb_global_heartbeat_active()) | ||
1755 | clear_bit(reg->hr_region_num, o2hb_region_bitmap); | ||
1736 | hb_task = reg->hr_task; | 1756 | hb_task = reg->hr_task; |
1737 | reg->hr_task = NULL; | 1757 | reg->hr_task = NULL; |
1738 | spin_unlock(&o2hb_live_lock); | 1758 | spin_unlock(&o2hb_live_lock); |