162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * heartbeat.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Function prototypes 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (C) 2004 Oracle. All rights reserved. 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef O2CLUSTER_HEARTBEAT_H 1162306a36Sopenharmony_ci#define O2CLUSTER_HEARTBEAT_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include "ocfs2_heartbeat.h" 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#define O2HB_REGION_TIMEOUT_MS 2000 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#define O2HB_MAX_REGION_NAME_LEN 32 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci/* number of changes to be seen as live */ 2062306a36Sopenharmony_ci#define O2HB_LIVE_THRESHOLD 2 2162306a36Sopenharmony_ci/* number of equal samples to be seen as dead */ 2262306a36Sopenharmony_ciextern unsigned int o2hb_dead_threshold; 2362306a36Sopenharmony_ci#define O2HB_DEFAULT_DEAD_THRESHOLD 31 2462306a36Sopenharmony_ci/* Otherwise MAX_WRITE_TIMEOUT will be zero... */ 2562306a36Sopenharmony_ci#define O2HB_MIN_DEAD_THRESHOLD 2 2662306a36Sopenharmony_ci#define O2HB_MAX_WRITE_TIMEOUT_MS (O2HB_REGION_TIMEOUT_MS * (o2hb_dead_threshold - 1)) 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define O2HB_CB_MAGIC 0x51d1e4ec 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci/* callback stuff */ 3162306a36Sopenharmony_cienum o2hb_callback_type { 3262306a36Sopenharmony_ci O2HB_NODE_DOWN_CB = 0, 3362306a36Sopenharmony_ci O2HB_NODE_UP_CB, 3462306a36Sopenharmony_ci O2HB_NUM_CB 3562306a36Sopenharmony_ci}; 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_cistruct o2nm_node; 3862306a36Sopenharmony_citypedef void (o2hb_cb_func)(struct o2nm_node *, int, void *); 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_cistruct o2hb_callback_func { 4162306a36Sopenharmony_ci u32 hc_magic; 4262306a36Sopenharmony_ci struct list_head hc_item; 4362306a36Sopenharmony_ci o2hb_cb_func *hc_func; 4462306a36Sopenharmony_ci void *hc_data; 4562306a36Sopenharmony_ci int hc_priority; 4662306a36Sopenharmony_ci enum o2hb_callback_type hc_type; 4762306a36Sopenharmony_ci}; 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_cistruct config_group *o2hb_alloc_hb_set(void); 5062306a36Sopenharmony_civoid o2hb_free_hb_set(struct config_group *group); 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_civoid o2hb_setup_callback(struct o2hb_callback_func *hc, 5362306a36Sopenharmony_ci enum o2hb_callback_type type, 5462306a36Sopenharmony_ci o2hb_cb_func *func, 5562306a36Sopenharmony_ci void *data, 5662306a36Sopenharmony_ci int priority); 5762306a36Sopenharmony_ciint o2hb_register_callback(const char *region_uuid, 5862306a36Sopenharmony_ci struct o2hb_callback_func *hc); 5962306a36Sopenharmony_civoid o2hb_unregister_callback(const char *region_uuid, 6062306a36Sopenharmony_ci struct o2hb_callback_func *hc); 6162306a36Sopenharmony_civoid o2hb_fill_node_map(unsigned long *map, 6262306a36Sopenharmony_ci unsigned int bits); 6362306a36Sopenharmony_civoid o2hb_exit(void); 6462306a36Sopenharmony_civoid o2hb_init(void); 6562306a36Sopenharmony_ciint o2hb_check_node_heartbeating_no_sem(u8 node_num); 6662306a36Sopenharmony_ciint o2hb_check_node_heartbeating_from_callback(u8 node_num); 6762306a36Sopenharmony_civoid o2hb_stop_all_regions(void); 6862306a36Sopenharmony_ciint o2hb_get_all_regions(char *region_uuids, u8 numregions); 6962306a36Sopenharmony_ciint o2hb_global_heartbeat_active(void); 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#endif /* O2CLUSTER_HEARTBEAT_H */ 72