1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * heartbeat.h 4 * 5 * Function prototypes 6 * 7 * Copyright (C) 2004 Oracle. All rights reserved. 8 */ 9 10 #ifndef O2CLUSTER_HEARTBEAT_H 11 #define O2CLUSTER_HEARTBEAT_H 12 13 #include "ocfs2_heartbeat.h" 14 15 #define O2HB_REGION_TIMEOUT_MS 2000 16 17 #define O2HB_MAX_REGION_NAME_LEN 32 18 19 /* number of changes to be seen as live */ 20 #define O2HB_LIVE_THRESHOLD 2 21 /* number of equal samples to be seen as dead */ 22 extern unsigned int o2hb_dead_threshold; 23 #define O2HB_DEFAULT_DEAD_THRESHOLD 31 24 /* Otherwise MAX_WRITE_TIMEOUT will be zero... */ 25 #define O2HB_MIN_DEAD_THRESHOLD 2 26 #define O2HB_MAX_WRITE_TIMEOUT_MS (O2HB_REGION_TIMEOUT_MS * (o2hb_dead_threshold - 1)) 27 28 #define O2HB_CB_MAGIC 0x51d1e4ec 29 30 /* callback stuff */ 31 enum o2hb_callback_type { 32 O2HB_NODE_DOWN_CB = 0, 33 O2HB_NODE_UP_CB, 34 O2HB_NUM_CB 35 }; 36 37 struct o2nm_node; 38 typedef void (o2hb_cb_func)(struct o2nm_node *, int, void *); 39 40 struct o2hb_callback_func { 41 u32 hc_magic; 42 struct list_head hc_item; 43 o2hb_cb_func *hc_func; 44 void *hc_data; 45 int hc_priority; 46 enum o2hb_callback_type hc_type; 47 }; 48 49 struct config_group *o2hb_alloc_hb_set(void); 50 void o2hb_free_hb_set(struct config_group *group); 51 52 void o2hb_setup_callback(struct o2hb_callback_func *hc, 53 enum o2hb_callback_type type, 54 o2hb_cb_func *func, 55 void *data, 56 int priority); 57 int o2hb_register_callback(const char *region_uuid, 58 struct o2hb_callback_func *hc); 59 void o2hb_unregister_callback(const char *region_uuid, 60 struct o2hb_callback_func *hc); 61 void o2hb_fill_node_map(unsigned long *map, 62 unsigned int bits); 63 void o2hb_exit(void); 64 void o2hb_init(void); 65 int o2hb_check_node_heartbeating_no_sem(u8 node_num); 66 int o2hb_check_node_heartbeating_from_callback(u8 node_num); 67 void o2hb_stop_all_regions(void); 68 int o2hb_get_all_regions(char *region_uuids, u8 numregions); 69 int o2hb_global_heartbeat_active(void); 70 71 #endif /* O2CLUSTER_HEARTBEAT_H */ 72