diff options
| -rw-r--r-- | fs/ocfs2/cluster/heartbeat.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 2a7cd17e96f0..62a8af271344 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
| @@ -66,9 +66,12 @@ static DECLARE_WAIT_QUEUE_HEAD(o2hb_steady_queue); | |||
| 66 | * In global heartbeat, we maintain a series of region bitmaps. | 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. | 67 | * - o2hb_region_bitmap allows us to limit the region number to max region. |
| 68 | * - o2hb_live_region_bitmap tracks live regions (seen steady iterations). | 68 | * - o2hb_live_region_bitmap tracks live regions (seen steady iterations). |
| 69 | * - o2hb_quorum_region_bitmap tracks live regions that have seen all nodes | ||
| 70 | * heartbeat on it. | ||
| 69 | */ | 71 | */ |
| 70 | static unsigned long o2hb_region_bitmap[BITS_TO_LONGS(O2NM_MAX_REGIONS)]; | 72 | static unsigned long o2hb_region_bitmap[BITS_TO_LONGS(O2NM_MAX_REGIONS)]; |
| 71 | static unsigned long o2hb_live_region_bitmap[BITS_TO_LONGS(O2NM_MAX_REGIONS)]; | 73 | static unsigned long o2hb_live_region_bitmap[BITS_TO_LONGS(O2NM_MAX_REGIONS)]; |
| 74 | static unsigned long o2hb_quorum_region_bitmap[BITS_TO_LONGS(O2NM_MAX_REGIONS)]; | ||
| 72 | 75 | ||
| 73 | #define O2HB_DB_TYPE_LIVENODES 0 | 76 | #define O2HB_DB_TYPE_LIVENODES 0 |
| 74 | struct o2hb_debug_buf { | 77 | struct o2hb_debug_buf { |
| @@ -607,6 +610,35 @@ static void o2hb_shutdown_slot(struct o2hb_disk_slot *slot) | |||
| 607 | o2nm_node_put(node); | 610 | o2nm_node_put(node); |
| 608 | } | 611 | } |
| 609 | 612 | ||
| 613 | static void o2hb_set_quorum_device(struct o2hb_region *reg, | ||
| 614 | struct o2hb_disk_slot *slot) | ||
| 615 | { | ||
| 616 | assert_spin_locked(&o2hb_live_lock); | ||
| 617 | |||
| 618 | if (!o2hb_global_heartbeat_active()) | ||
| 619 | return; | ||
| 620 | |||
| 621 | if (test_bit(reg->hr_region_num, o2hb_quorum_region_bitmap)) | ||
| 622 | return; | ||
| 623 | |||
| 624 | /* | ||
| 625 | * A region can be added to the quorum only when it sees all | ||
| 626 | * live nodes heartbeat on it. In other words, the region has been | ||
| 627 | * added to all nodes. | ||
| 628 | */ | ||
| 629 | if (memcmp(reg->hr_live_node_bitmap, o2hb_live_node_bitmap, | ||
| 630 | sizeof(o2hb_live_node_bitmap))) | ||
| 631 | return; | ||
| 632 | |||
| 633 | if (slot->ds_changed_samples < O2HB_LIVE_THRESHOLD) | ||
| 634 | return; | ||
| 635 | |||
| 636 | printk(KERN_NOTICE "o2hb: Region %s is now a quorum device\n", | ||
| 637 | config_item_name(®->hr_item)); | ||
| 638 | |||
| 639 | set_bit(reg->hr_region_num, o2hb_quorum_region_bitmap); | ||
| 640 | } | ||
| 641 | |||
| 610 | static int o2hb_check_slot(struct o2hb_region *reg, | 642 | static int o2hb_check_slot(struct o2hb_region *reg, |
| 611 | struct o2hb_disk_slot *slot) | 643 | struct o2hb_disk_slot *slot) |
| 612 | { | 644 | { |
| @@ -772,6 +804,8 @@ fire_callbacks: | |||
| 772 | slot->ds_equal_samples = 0; | 804 | slot->ds_equal_samples = 0; |
| 773 | } | 805 | } |
| 774 | out: | 806 | out: |
| 807 | o2hb_set_quorum_device(reg, slot); | ||
| 808 | |||
| 775 | spin_unlock(&o2hb_live_lock); | 809 | spin_unlock(&o2hb_live_lock); |
| 776 | 810 | ||
| 777 | o2hb_run_event_list(&event); | 811 | o2hb_run_event_list(&event); |
| @@ -1138,6 +1172,7 @@ int o2hb_init(void) | |||
| 1138 | memset(o2hb_live_node_bitmap, 0, sizeof(o2hb_live_node_bitmap)); | 1172 | memset(o2hb_live_node_bitmap, 0, sizeof(o2hb_live_node_bitmap)); |
| 1139 | memset(o2hb_region_bitmap, 0, sizeof(o2hb_region_bitmap)); | 1173 | memset(o2hb_region_bitmap, 0, sizeof(o2hb_region_bitmap)); |
| 1140 | memset(o2hb_live_region_bitmap, 0, sizeof(o2hb_live_region_bitmap)); | 1174 | memset(o2hb_live_region_bitmap, 0, sizeof(o2hb_live_region_bitmap)); |
| 1175 | memset(o2hb_quorum_region_bitmap, 0, sizeof(o2hb_quorum_region_bitmap)); | ||
| 1141 | 1176 | ||
| 1142 | return o2hb_debug_init(); | 1177 | return o2hb_debug_init(); |
| 1143 | } | 1178 | } |
