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