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