blob: 7f37540ac4ab607ccb75ae768b4b65afd167190c [file] [log] [blame]
Thomas Gleixner328970d2019-05-24 12:04:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Mark Fasheha7f6a5f2005-12-15 14:31:23 -08002/* -*- mode: c; c-basic-offset: 8; -*-
3 * vim: noexpandtab sw=8 ts=8 sts=0:
4 *
5 * heartbeat.h
6 *
7 * Function prototypes
8 *
9 * Copyright (C) 2004 Oracle. All rights reserved.
Mark Fasheha7f6a5f2005-12-15 14:31:23 -080010 */
11
12#ifndef O2CLUSTER_HEARTBEAT_H
13#define O2CLUSTER_HEARTBEAT_H
14
15#include "ocfs2_heartbeat.h"
16
17#define O2HB_REGION_TIMEOUT_MS 2000
18
Sunil Mushranb3c85c42010-10-07 14:31:06 -070019#define O2HB_MAX_REGION_NAME_LEN 32
20
Mark Fasheha7f6a5f2005-12-15 14:31:23 -080021/* number of changes to be seen as live */
22#define O2HB_LIVE_THRESHOLD 2
23/* number of equal samples to be seen as dead */
24extern unsigned int o2hb_dead_threshold;
Sunil Mushran17104682007-11-06 16:10:23 -080025#define O2HB_DEFAULT_DEAD_THRESHOLD 31
Mark Fasheha7f6a5f2005-12-15 14:31:23 -080026/* Otherwise MAX_WRITE_TIMEOUT will be zero... */
27#define O2HB_MIN_DEAD_THRESHOLD 2
28#define O2HB_MAX_WRITE_TIMEOUT_MS (O2HB_REGION_TIMEOUT_MS * (o2hb_dead_threshold - 1))
29
30#define O2HB_CB_MAGIC 0x51d1e4ec
31
32/* callback stuff */
33enum o2hb_callback_type {
34 O2HB_NODE_DOWN_CB = 0,
35 O2HB_NODE_UP_CB,
36 O2HB_NUM_CB
37};
38
39struct o2nm_node;
40typedef void (o2hb_cb_func)(struct o2nm_node *, int, void *);
41
42struct o2hb_callback_func {
43 u32 hc_magic;
44 struct list_head hc_item;
45 o2hb_cb_func *hc_func;
46 void *hc_data;
47 int hc_priority;
48 enum o2hb_callback_type hc_type;
49};
50
51struct config_group *o2hb_alloc_hb_set(void);
52void o2hb_free_hb_set(struct config_group *group);
53
54void o2hb_setup_callback(struct o2hb_callback_func *hc,
55 enum o2hb_callback_type type,
56 o2hb_cb_func *func,
57 void *data,
58 int priority);
Joel Becker14829422007-06-14 21:40:49 -070059int o2hb_register_callback(const char *region_uuid,
60 struct o2hb_callback_func *hc);
61void o2hb_unregister_callback(const char *region_uuid,
62 struct o2hb_callback_func *hc);
Mark Fasheha7f6a5f2005-12-15 14:31:23 -080063void o2hb_fill_node_map(unsigned long *map,
64 unsigned bytes);
Sunil Mushran87d3d3f2008-12-17 14:17:42 -080065void o2hb_exit(void);
66int o2hb_init(void);
Joseph Qi70e82a12014-10-09 15:25:13 -070067int o2hb_check_node_heartbeating_no_sem(u8 node_num);
Mark Fasheha7f6a5f2005-12-15 14:31:23 -080068int o2hb_check_node_heartbeating_from_callback(u8 node_num);
Mark Fasheha7f6a5f2005-12-15 14:31:23 -080069void o2hb_stop_all_regions(void);
Sunil Mushranb3c85c42010-10-07 14:31:06 -070070int o2hb_get_all_regions(char *region_uuids, u8 numregions);
71int o2hb_global_heartbeat_active(void);
Mark Fasheha7f6a5f2005-12-15 14:31:23 -080072
73#endif /* O2CLUSTER_HEARTBEAT_H */