heartbeat.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifndef O2CLUSTER_HEARTBEAT_H
  10. #define O2CLUSTER_HEARTBEAT_H
  11. #include "ocfs2_heartbeat.h"
  12. #define O2HB_REGION_TIMEOUT_MS 2000
  13. #define O2HB_MAX_REGION_NAME_LEN 32
  14. /* number of changes to be seen as live */
  15. #define O2HB_LIVE_THRESHOLD 2
  16. /* number of equal samples to be seen as dead */
  17. extern unsigned int o2hb_dead_threshold;
  18. #define O2HB_DEFAULT_DEAD_THRESHOLD 31
  19. /* Otherwise MAX_WRITE_TIMEOUT will be zero... */
  20. #define O2HB_MIN_DEAD_THRESHOLD 2
  21. #define O2HB_MAX_WRITE_TIMEOUT_MS (O2HB_REGION_TIMEOUT_MS * (o2hb_dead_threshold - 1))
  22. #define O2HB_CB_MAGIC 0x51d1e4ec
  23. /* callback stuff */
  24. enum o2hb_callback_type {
  25. O2HB_NODE_DOWN_CB = 0,
  26. O2HB_NODE_UP_CB,
  27. O2HB_NUM_CB
  28. };
  29. struct o2nm_node;
  30. typedef void (o2hb_cb_func)(struct o2nm_node *, int, void *);
  31. struct o2hb_callback_func {
  32. u32 hc_magic;
  33. struct list_head hc_item;
  34. o2hb_cb_func *hc_func;
  35. void *hc_data;
  36. int hc_priority;
  37. enum o2hb_callback_type hc_type;
  38. };
  39. struct config_group *o2hb_alloc_hb_set(void);
  40. void o2hb_free_hb_set(struct config_group *group);
  41. void o2hb_setup_callback(struct o2hb_callback_func *hc,
  42. enum o2hb_callback_type type,
  43. o2hb_cb_func *func,
  44. void *data,
  45. int priority);
  46. int o2hb_register_callback(const char *region_uuid,
  47. struct o2hb_callback_func *hc);
  48. void o2hb_unregister_callback(const char *region_uuid,
  49. struct o2hb_callback_func *hc);
  50. void o2hb_fill_node_map(unsigned long *map,
  51. unsigned int bits);
  52. void o2hb_exit(void);
  53. void o2hb_init(void);
  54. int o2hb_check_node_heartbeating_no_sem(u8 node_num);
  55. int o2hb_check_node_heartbeating_from_callback(u8 node_num);
  56. void o2hb_stop_all_regions(void);
  57. int o2hb_get_all_regions(char *region_uuids, u8 numregions);
  58. int o2hb_global_heartbeat_active(void);
  59. #endif /* O2CLUSTER_HEARTBEAT_H */