aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/cluster/heartbeat.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/cluster/heartbeat.c')
-rw-r--r--fs/ocfs2/cluster/heartbeat.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 5c1c864e81cc..363f0dcc924f 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -628,11 +628,9 @@ static void o2hb_fire_callbacks(struct o2hb_callback *hbcall,
628 struct o2nm_node *node, 628 struct o2nm_node *node,
629 int idx) 629 int idx)
630{ 630{
631 struct list_head *iter;
632 struct o2hb_callback_func *f; 631 struct o2hb_callback_func *f;
633 632
634 list_for_each(iter, &hbcall->list) { 633 list_for_each_entry(f, &hbcall->list, hc_item) {
635 f = list_entry(iter, struct o2hb_callback_func, hc_item);
636 mlog(ML_HEARTBEAT, "calling funcs %p\n", f); 634 mlog(ML_HEARTBEAT, "calling funcs %p\n", f);
637 (f->hc_func)(node, idx, f->hc_data); 635 (f->hc_func)(node, idx, f->hc_data);
638 } 636 }
@@ -641,16 +639,9 @@ static void o2hb_fire_callbacks(struct o2hb_callback *hbcall,
641/* Will run the list in order until we process the passed event */ 639/* Will run the list in order until we process the passed event */
642static void o2hb_run_event_list(struct o2hb_node_event *queued_event) 640static void o2hb_run_event_list(struct o2hb_node_event *queued_event)
643{ 641{
644 int empty;
645 struct o2hb_callback *hbcall; 642 struct o2hb_callback *hbcall;
646 struct o2hb_node_event *event; 643 struct o2hb_node_event *event;
647 644
648 spin_lock(&o2hb_live_lock);
649 empty = list_empty(&queued_event->hn_item);
650 spin_unlock(&o2hb_live_lock);
651 if (empty)
652 return;
653
654 /* Holding callback sem assures we don't alter the callback 645 /* Holding callback sem assures we don't alter the callback
655 * lists when doing this, and serializes ourselves with other 646 * lists when doing this, and serializes ourselves with other
656 * processes wanting callbacks. */ 647 * processes wanting callbacks. */
@@ -709,6 +700,7 @@ static void o2hb_shutdown_slot(struct o2hb_disk_slot *slot)
709 struct o2hb_node_event event = 700 struct o2hb_node_event event =
710 { .hn_item = LIST_HEAD_INIT(event.hn_item), }; 701 { .hn_item = LIST_HEAD_INIT(event.hn_item), };
711 struct o2nm_node *node; 702 struct o2nm_node *node;
703 int queued = 0;
712 704
713 node = o2nm_get_node_by_num(slot->ds_node_num); 705 node = o2nm_get_node_by_num(slot->ds_node_num);
714 if (!node) 706 if (!node)
@@ -726,11 +718,13 @@ static void o2hb_shutdown_slot(struct o2hb_disk_slot *slot)
726 718
727 o2hb_queue_node_event(&event, O2HB_NODE_DOWN_CB, node, 719 o2hb_queue_node_event(&event, O2HB_NODE_DOWN_CB, node,
728 slot->ds_node_num); 720 slot->ds_node_num);
721 queued = 1;
729 } 722 }
730 } 723 }
731 spin_unlock(&o2hb_live_lock); 724 spin_unlock(&o2hb_live_lock);
732 725
733 o2hb_run_event_list(&event); 726 if (queued)
727 o2hb_run_event_list(&event);
734 728
735 o2nm_node_put(node); 729 o2nm_node_put(node);
736} 730}
@@ -790,6 +784,7 @@ static int o2hb_check_slot(struct o2hb_region *reg,
790 unsigned int dead_ms = o2hb_dead_threshold * O2HB_REGION_TIMEOUT_MS; 784 unsigned int dead_ms = o2hb_dead_threshold * O2HB_REGION_TIMEOUT_MS;
791 unsigned int slot_dead_ms; 785 unsigned int slot_dead_ms;
792 int tmp; 786 int tmp;
787 int queued = 0;
793 788
794 memcpy(hb_block, slot->ds_raw_block, reg->hr_block_bytes); 789 memcpy(hb_block, slot->ds_raw_block, reg->hr_block_bytes);
795 790
@@ -883,6 +878,7 @@ fire_callbacks:
883 slot->ds_node_num); 878 slot->ds_node_num);
884 879
885 changed = 1; 880 changed = 1;
881 queued = 1;
886 } 882 }
887 883
888 list_add_tail(&slot->ds_live_item, 884 list_add_tail(&slot->ds_live_item,
@@ -934,6 +930,7 @@ fire_callbacks:
934 node, slot->ds_node_num); 930 node, slot->ds_node_num);
935 931
936 changed = 1; 932 changed = 1;
933 queued = 1;
937 } 934 }
938 935
939 /* We don't clear this because the node is still 936 /* We don't clear this because the node is still
@@ -949,7 +946,8 @@ fire_callbacks:
949out: 946out:
950 spin_unlock(&o2hb_live_lock); 947 spin_unlock(&o2hb_live_lock);
951 948
952 o2hb_run_event_list(&event); 949 if (queued)
950 o2hb_run_event_list(&event);
953 951
954 if (node) 952 if (node)
955 o2nm_node_put(node); 953 o2nm_node_put(node);
@@ -2516,8 +2514,7 @@ unlock:
2516int o2hb_register_callback(const char *region_uuid, 2514int o2hb_register_callback(const char *region_uuid,
2517 struct o2hb_callback_func *hc) 2515 struct o2hb_callback_func *hc)
2518{ 2516{
2519 struct o2hb_callback_func *tmp; 2517 struct o2hb_callback_func *f;
2520 struct list_head *iter;
2521 struct o2hb_callback *hbcall; 2518 struct o2hb_callback *hbcall;
2522 int ret; 2519 int ret;
2523 2520
@@ -2540,10 +2537,9 @@ int o2hb_register_callback(const char *region_uuid,
2540 2537
2541 down_write(&o2hb_callback_sem); 2538 down_write(&o2hb_callback_sem);
2542 2539
2543 list_for_each(iter, &hbcall->list) { 2540 list_for_each_entry(f, &hbcall->list, hc_item) {
2544 tmp = list_entry(iter, struct o2hb_callback_func, hc_item); 2541 if (hc->hc_priority < f->hc_priority) {
2545 if (hc->hc_priority < tmp->hc_priority) { 2542 list_add_tail(&hc->hc_item, &f->hc_item);
2546 list_add_tail(&hc->hc_item, iter);
2547 break; 2543 break;
2548 } 2544 }
2549 } 2545 }