votequorum.c 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699
  1. /*
  2. * Copyright (c) 2009 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Christine Caulfield (ccaulfie@redhat.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <config.h>
  35. #include <sys/types.h>
  36. #ifndef COROSYNC_BSD
  37. #include <alloca.h>
  38. #endif
  39. #include <sys/types.h>
  40. #include <sys/socket.h>
  41. #include <sys/un.h>
  42. #include <sys/time.h>
  43. #include <sys/ioctl.h>
  44. #include <netinet/in.h>
  45. #include <sys/uio.h>
  46. #include <unistd.h>
  47. #include <fcntl.h>
  48. #include <stdlib.h>
  49. #include <stdio.h>
  50. #include <errno.h>
  51. #include <signal.h>
  52. #include <time.h>
  53. #include <unistd.h>
  54. #include <netinet/in.h>
  55. #include <arpa/inet.h>
  56. #include <corosync/corotypes.h>
  57. #include <corosync/cfg.h>
  58. #include <corosync/list.h>
  59. #include <corosync/lcr/lcr_comp.h>
  60. #include <corosync/engine/logsys.h>
  61. #include <corosync/ipc_gen.h>
  62. #include <corosync/engine/coroapi.h>
  63. #include <corosync/engine/quorum.h>
  64. #include <corosync/ipc_votequorum.h>
  65. #include <corosync/list.h>
  66. #define VOTEQUORUM_MAJOR_VERSION 6
  67. #define VOTEQUORUM_MINOR_VERSION 3
  68. #define VOTEQUORUM_PATCH_VERSION 0
  69. /* Silly default to prevent accidents! */
  70. #define DEFAULT_EXPECTED 1024
  71. #define DEFAULT_QDEV_POLL 10000
  72. #define DEFAULT_LEAVE_TMO 10000
  73. LOGSYS_DECLARE_SUBSYS ("VOTEQ", LOG_INFO);
  74. enum quorum_message_req_types {
  75. MESSAGE_REQ_EXEC_VOTEQUORUM_NODEINFO = 0,
  76. MESSAGE_REQ_EXEC_VOTEQUORUM_RECONFIGURE = 1,
  77. MESSAGE_REQ_EXEC_VOTEQUORUM_KILLNODE = 2,
  78. };
  79. #define NODE_FLAGS_BEENDOWN 1
  80. #define NODE_FLAGS_SEESDISALLOWED 8
  81. #define NODE_FLAGS_HASSTATE 16
  82. #define NODE_FLAGS_QDISK 32
  83. #define NODE_FLAGS_REMOVED 64
  84. #define NODE_FLAGS_US 128
  85. typedef enum { NODESTATE_JOINING=1, NODESTATE_MEMBER,
  86. NODESTATE_DEAD, NODESTATE_LEAVING, NODESTATE_DISALLOWED } nodestate_t;
  87. /* This structure is tacked onto the start of a cluster message packet for our
  88. * own nefarious purposes. */
  89. struct q_protheader {
  90. unsigned char tgtport; /* Target port number */
  91. unsigned char srcport; /* Source (originating) port number */
  92. unsigned short pad;
  93. unsigned int flags;
  94. int srcid; /* Node ID of the sender */
  95. int tgtid; /* Node ID of the target */
  96. } __attribute__((packed));
  97. struct cluster_node {
  98. int flags;
  99. int node_id;
  100. unsigned int expected_votes;
  101. unsigned int votes;
  102. time_t join_time;
  103. nodestate_t state;
  104. struct timeval last_hello; /* Only used for quorum devices */
  105. struct list_head list;
  106. };
  107. static int quorum_flags;
  108. #define VOTEQUORUM_FLAG_FEATURE_DISALLOWED 1
  109. #define VOTEQUORUM_FLAG_FEATURE_TWONODE 1
  110. static int quorum;
  111. static int cluster_is_quorate;
  112. static int first_trans = 1;
  113. static unsigned int quorumdev_poll = DEFAULT_QDEV_POLL;
  114. static unsigned int leaving_timeout = DEFAULT_LEAVE_TMO;
  115. static struct cluster_node *us;
  116. static struct cluster_node *quorum_device = NULL;
  117. static char quorum_device_name[VOTEQUORUM_MAX_QDISK_NAME_LEN];
  118. static corosync_timer_handle_t quorum_device_timer;
  119. static corosync_timer_handle_t leaving_timer;
  120. static struct list_head cluster_members_list;
  121. static struct corosync_api_v1 *corosync_api;
  122. static struct list_head trackers_list;
  123. static unsigned int quorum_members[PROCESSOR_COUNT_MAX+1];
  124. static int quorum_members_entries = 0;
  125. static struct memb_ring_id quorum_ringid;
  126. static hdb_handle_t group_handle;
  127. #define max(a,b) (((a) > (b)) ? (a) : (b))
  128. static struct cluster_node *find_node_by_nodeid(int nodeid);
  129. static struct cluster_node *allocate_node(int nodeid);
  130. static const char *kill_reason(int reason);
  131. static struct corosync_tpg_group quorum_group[1] = {
  132. { .group = "VOTEQ", .group_len = 5},
  133. };
  134. #define list_iterate(v, head) \
  135. for (v = (head)->next; v != head; v = v->next)
  136. struct quorum_pd {
  137. unsigned char track_flags;
  138. int tracking_enabled;
  139. uint64_t tracking_context;
  140. struct list_head list;
  141. void *conn;
  142. };
  143. /*
  144. * Service Interfaces required by service_message_handler struct
  145. */
  146. static void votequorum_init(struct corosync_api_v1 *api,
  147. quorum_set_quorate_fn_t report);
  148. static void quorum_confchg_fn (
  149. enum totem_configuration_type configuration_type,
  150. unsigned int *member_list, int member_list_entries,
  151. unsigned int *left_list, int left_list_entries,
  152. unsigned int *joined_list, int joined_list_entries,
  153. struct memb_ring_id *ring_id);
  154. static void quorum_deliver_fn(unsigned int nodeid, struct iovec *iovec, int iov_len,
  155. int endian_conversion_required);
  156. static int votequorum_exec_init_fn (struct corosync_api_v1 *corosync_api);
  157. static int quorum_lib_init_fn (void *conn);
  158. static int quorum_lib_exit_fn (void *conn);
  159. static void message_handler_req_exec_quorum_nodeinfo (
  160. void *message,
  161. unsigned int nodeid);
  162. static void message_handler_req_exec_quorum_reconfigure (
  163. void *message,
  164. unsigned int nodeid);
  165. static void message_handler_req_exec_quorum_killnode (
  166. void *message,
  167. unsigned int nodeid);
  168. static void message_handler_req_lib_votequorum_getinfo (void *conn, void *message);
  169. static void message_handler_req_lib_votequorum_setexpected (void *conn, void *message);
  170. static void message_handler_req_lib_votequorum_setvotes (void *conn, void *message);
  171. static void message_handler_req_lib_votequorum_qdisk_register (void *conn, void *message);
  172. static void message_handler_req_lib_votequorum_qdisk_unregister (void *conn, void *message);
  173. static void message_handler_req_lib_votequorum_qdisk_poll (void *conn, void *message);
  174. static void message_handler_req_lib_votequorum_qdisk_getinfo (void *conn, void *message);
  175. static void message_handler_req_lib_votequorum_setstate (void *conn, void *message);
  176. static void message_handler_req_lib_votequorum_leaving (void *conn, void *message);
  177. static void message_handler_req_lib_votequorum_trackstart (void *conn, void *msg);
  178. static void message_handler_req_lib_votequorum_trackstop (void *conn, void *msg);
  179. static int quorum_exec_send_nodeinfo(void);
  180. static int quorum_exec_send_reconfigure(int param, int nodeid, int value);
  181. static int quorum_exec_send_killnode(int nodeid, unsigned int reason);
  182. static void add_votequorum_config_notification(hdb_handle_t quorum_object_handle);
  183. static void recalculate_quorum(int allow_decrease, int by_current_nodes);
  184. /*
  185. * Library Handler Definition
  186. */
  187. static struct corosync_lib_handler quorum_lib_service[] =
  188. {
  189. { /* 0 */
  190. .lib_handler_fn = message_handler_req_lib_votequorum_getinfo,
  191. .response_size = sizeof (struct res_lib_votequorum_getinfo),
  192. .response_id = MESSAGE_RES_VOTEQUORUM_GETINFO,
  193. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  194. },
  195. { /* 1 */
  196. .lib_handler_fn = message_handler_req_lib_votequorum_setexpected,
  197. .response_size = sizeof (struct res_lib_votequorum_status),
  198. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  199. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  200. },
  201. { /* 2 */
  202. .lib_handler_fn = message_handler_req_lib_votequorum_setvotes,
  203. .response_size = sizeof (struct res_lib_votequorum_status),
  204. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  205. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  206. },
  207. { /* 3 */
  208. .lib_handler_fn = message_handler_req_lib_votequorum_qdisk_register,
  209. .response_size = sizeof (struct res_lib_votequorum_status),
  210. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  211. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  212. },
  213. { /* 4 */
  214. .lib_handler_fn = message_handler_req_lib_votequorum_qdisk_unregister,
  215. .response_size = sizeof (struct res_lib_votequorum_status),
  216. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  217. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  218. },
  219. { /* 5 */
  220. .lib_handler_fn = message_handler_req_lib_votequorum_qdisk_poll,
  221. .response_size = sizeof (struct res_lib_votequorum_status),
  222. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  223. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  224. },
  225. { /* 6 */
  226. .lib_handler_fn = message_handler_req_lib_votequorum_qdisk_getinfo,
  227. .response_size = sizeof (struct res_lib_votequorum_qdisk_getinfo),
  228. .response_id = MESSAGE_RES_VOTEQUORUM_QDISK_GETINFO,
  229. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  230. },
  231. { /* 7 */
  232. .lib_handler_fn = message_handler_req_lib_votequorum_setstate,
  233. .response_size = sizeof (struct res_lib_votequorum_status),
  234. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  235. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  236. },
  237. { /* 8 */
  238. .lib_handler_fn = message_handler_req_lib_votequorum_leaving,
  239. .response_size = sizeof (struct res_lib_votequorum_status),
  240. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  241. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  242. },
  243. { /* 9 */
  244. .lib_handler_fn = message_handler_req_lib_votequorum_trackstart,
  245. .response_size = sizeof (struct res_lib_votequorum_status),
  246. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  247. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  248. },
  249. { /* 10 */
  250. .lib_handler_fn = message_handler_req_lib_votequorum_trackstop,
  251. .response_size = sizeof (struct res_lib_votequorum_status),
  252. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  253. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  254. }
  255. };
  256. static quorum_set_quorate_fn_t set_quorum;
  257. /*
  258. * lcrso object definition
  259. */
  260. static struct quorum_services_api_ver1 votequorum_iface_ver0 = {
  261. .init = votequorum_init
  262. };
  263. static struct corosync_service_engine quorum_service_handler = {
  264. .name = "corosync votes quorum service v0.90",
  265. .id = VOTEQUORUM_SERVICE,
  266. .private_data_size = sizeof (struct quorum_pd),
  267. .allow_inquorate = CS_LIB_ALLOW_INQUORATE,
  268. .flow_control = COROSYNC_LIB_FLOW_CONTROL_REQUIRED,
  269. .lib_init_fn = quorum_lib_init_fn,
  270. .lib_exit_fn = quorum_lib_exit_fn,
  271. .lib_engine = quorum_lib_service,
  272. .lib_engine_count = sizeof (quorum_lib_service) / sizeof (struct corosync_lib_handler),
  273. .exec_init_fn = votequorum_exec_init_fn,
  274. .exec_engine = NULL,
  275. .exec_engine_count = 0,
  276. .confchg_fn = NULL,
  277. };
  278. /*
  279. * Dynamic loader definition
  280. */
  281. static struct corosync_service_engine *quorum_get_service_handler_ver0 (void);
  282. static struct corosync_service_engine_iface_ver0 quorum_service_handler_iface = {
  283. .corosync_get_service_engine_ver0 = quorum_get_service_handler_ver0
  284. };
  285. static struct lcr_iface corosync_quorum_ver0[2] = {
  286. {
  287. .name = "corosync_votequorum",
  288. .version = 0,
  289. .versions_replace = 0,
  290. .versions_replace_count = 0,
  291. .dependencies = 0,
  292. .dependency_count = 0,
  293. .constructor = NULL,
  294. .destructor = NULL,
  295. .interfaces = (void **)(void *)&votequorum_iface_ver0
  296. },
  297. {
  298. .name = "corosync_votequorum_iface",
  299. .version = 0,
  300. .versions_replace = 0,
  301. .versions_replace_count = 0,
  302. .dependencies = 0,
  303. .dependency_count = 0,
  304. .constructor = NULL,
  305. .destructor = NULL,
  306. .interfaces = NULL
  307. }
  308. };
  309. static struct lcr_comp quorum_comp_ver0 = {
  310. .iface_count = 2,
  311. .ifaces = corosync_quorum_ver0
  312. };
  313. static struct corosync_service_engine *quorum_get_service_handler_ver0 (void)
  314. {
  315. return (&quorum_service_handler);
  316. }
  317. __attribute__ ((constructor)) static void quorum_comp_register (void) {
  318. lcr_interfaces_set (&corosync_quorum_ver0[0], &votequorum_iface_ver0);
  319. lcr_interfaces_set (&corosync_quorum_ver0[1], &quorum_service_handler_iface);
  320. lcr_component_register (&quorum_comp_ver0);
  321. }
  322. static void votequorum_init(struct corosync_api_v1 *api,
  323. quorum_set_quorate_fn_t report)
  324. {
  325. ENTER();
  326. set_quorum = report;
  327. /* Load the library-servicing part of this module */
  328. api->service_link_and_init(api, "corosync_votequorum_iface", 0);
  329. LEAVE();
  330. }
  331. /* Message types */
  332. #define VOTEQUORUM_MSG_NODEINFO 5
  333. #define VOTEQUORUM_MSG_KILLNODE 6
  334. #define VOTEQUORUM_MSG_RECONFIGURE 8
  335. struct req_exec_quorum_nodeinfo {
  336. unsigned char cmd;
  337. unsigned char first_trans;
  338. unsigned int votes;
  339. unsigned int expected_votes;
  340. unsigned int major_version; /* Not backwards compatible */
  341. unsigned int minor_version; /* Backwards compatible */
  342. unsigned int patch_version; /* Backwards/forwards compatible */
  343. unsigned int config_version;
  344. unsigned int flags;
  345. } __attribute__((packed));
  346. /* Parameters for RECONFIG command */
  347. #define RECONFIG_PARAM_EXPECTED_VOTES 1
  348. #define RECONFIG_PARAM_NODE_VOTES 2
  349. #define RECONFIG_PARAM_LEAVING 3
  350. struct req_exec_quorum_reconfigure {
  351. unsigned char cmd;
  352. unsigned char param;
  353. unsigned short pad;
  354. int nodeid;
  355. unsigned int value;
  356. };
  357. struct req_exec_quorum_killnode {
  358. unsigned char cmd;
  359. unsigned char pad1;
  360. uint16_t reason;
  361. int nodeid;
  362. };
  363. /* These just make the access a little neater */
  364. static inline int objdb_get_string(struct corosync_api_v1 *corosync, unsigned int object_service_handle,
  365. char *key, char **value)
  366. {
  367. int res;
  368. *value = NULL;
  369. if ( !(res = corosync_api->object_key_get(object_service_handle,
  370. key,
  371. strlen(key),
  372. (void *)value,
  373. NULL))) {
  374. if (*value)
  375. return 0;
  376. }
  377. return -1;
  378. }
  379. static inline void objdb_get_int(struct corosync_api_v1 *corosync,
  380. unsigned int object_service_handle,
  381. const char *key, unsigned int *intvalue,
  382. unsigned int default_value)
  383. {
  384. char *value = NULL;
  385. *intvalue = default_value;
  386. if (!corosync_api->object_key_get(object_service_handle, key, strlen(key),
  387. (void *)&value, NULL)) {
  388. if (value) {
  389. *intvalue = atoi(value);
  390. }
  391. }
  392. }
  393. static int votequorum_send_message(void *message, int len)
  394. {
  395. struct iovec iov[2];
  396. struct q_protheader header;
  397. header.tgtport = 0;
  398. header.srcport = 0;
  399. header.flags = 0;
  400. header.srcid = us->node_id;
  401. header.tgtid = 0;
  402. iov[0].iov_base = &header;
  403. iov[0].iov_len = sizeof(header);
  404. iov[1].iov_base = message;
  405. iov[1].iov_len = len;
  406. return corosync_api->tpg_joined_mcast(group_handle, iov, 2, TOTEM_AGREED);
  407. }
  408. static void read_quorum_config(unsigned int quorum_handle)
  409. {
  410. unsigned int value = 0;
  411. int cluster_members = 0;
  412. struct list_head *tmp;
  413. struct cluster_node *node;
  414. log_printf(LOG_INFO, "Reading configuration\n");
  415. objdb_get_int(corosync_api, quorum_handle, "expected_votes", &us->expected_votes, DEFAULT_EXPECTED);
  416. objdb_get_int(corosync_api, quorum_handle, "votes", &us->votes, 1);
  417. objdb_get_int(corosync_api, quorum_handle, "quorumdev_poll", &quorumdev_poll, DEFAULT_QDEV_POLL);
  418. objdb_get_int(corosync_api, quorum_handle, "leaving_timeout", &leaving_timeout, DEFAULT_LEAVE_TMO);
  419. objdb_get_int(corosync_api, quorum_handle, "disallowed", &value, 0);
  420. if (value)
  421. quorum_flags |= VOTEQUORUM_FLAG_FEATURE_DISALLOWED;
  422. else
  423. quorum_flags &= ~VOTEQUORUM_FLAG_FEATURE_DISALLOWED;
  424. objdb_get_int(corosync_api, quorum_handle, "two_node", &value, 0);
  425. if (value)
  426. quorum_flags |= VOTEQUORUM_FLAG_FEATURE_TWONODE;
  427. else
  428. quorum_flags &= ~VOTEQUORUM_FLAG_FEATURE_TWONODE;
  429. /*
  430. * two_node mode is invalid if there are more than 2 nodes in the cluster!
  431. */
  432. list_iterate(tmp, &cluster_members_list) {
  433. node = list_entry(tmp, struct cluster_node, list);
  434. cluster_members++;
  435. }
  436. if (quorum_flags & VOTEQUORUM_FLAG_FEATURE_TWONODE && cluster_members > 2) {
  437. log_printf(LOG_WARNING, "quorum.two_node was set but there are more than 2 nodes in the cluster. It will be ignored.");
  438. quorum_flags &= ~VOTEQUORUM_FLAG_FEATURE_TWONODE;
  439. }
  440. }
  441. static int votequorum_exec_init_fn (struct corosync_api_v1 *api)
  442. {
  443. hdb_handle_t object_handle;
  444. hdb_handle_t find_handle;
  445. ENTER();
  446. corosync_api = api;
  447. list_init(&cluster_members_list);
  448. list_init(&trackers_list);
  449. /* Allocate a cluster_node for us */
  450. us = allocate_node(corosync_api->totem_nodeid_get());
  451. if (!us)
  452. return (1);
  453. us->flags |= NODE_FLAGS_US;
  454. us->state = NODESTATE_MEMBER;
  455. us->expected_votes = DEFAULT_EXPECTED;
  456. us->votes = 1;
  457. time(&us->join_time);
  458. /* Get configuration variables */
  459. corosync_api->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle);
  460. if (corosync_api->object_find_next(find_handle, &object_handle) == 0) {
  461. read_quorum_config(object_handle);
  462. }
  463. recalculate_quorum(0, 0);
  464. /* Listen for changes */
  465. add_votequorum_config_notification(object_handle);
  466. corosync_api->object_find_destroy(find_handle);
  467. api->tpg_init(&group_handle, quorum_deliver_fn, quorum_confchg_fn);
  468. api->tpg_join(group_handle, quorum_group, 1);
  469. LEAVE();
  470. return (0);
  471. }
  472. static int quorum_lib_exit_fn (void *conn)
  473. {
  474. struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  475. ENTER();
  476. if (quorum_pd->tracking_enabled) {
  477. list_del (&quorum_pd->list);
  478. list_init (&quorum_pd->list);
  479. }
  480. LEAVE();
  481. return (0);
  482. }
  483. static int send_quorum_notification(void *conn, uint64_t context)
  484. {
  485. struct res_lib_votequorum_notification *res_lib_votequorum_notification;
  486. struct list_head *tmp;
  487. struct cluster_node *node;
  488. int cluster_members = 0;
  489. int i = 0;
  490. int size;
  491. char *buf;
  492. ENTER();
  493. list_iterate(tmp, &cluster_members_list) {
  494. node = list_entry(tmp, struct cluster_node, list);
  495. cluster_members++;
  496. }
  497. if (quorum_device)
  498. cluster_members++;
  499. size = sizeof(struct res_lib_votequorum_notification) + sizeof(struct votequorum_node) * cluster_members;
  500. buf = alloca(size);
  501. if (!buf) {
  502. LEAVE();
  503. return -1;
  504. }
  505. res_lib_votequorum_notification = (struct res_lib_votequorum_notification *)buf;
  506. res_lib_votequorum_notification->quorate = cluster_is_quorate;
  507. res_lib_votequorum_notification->node_list_entries = cluster_members;
  508. res_lib_votequorum_notification->context = context;
  509. list_iterate(tmp, &cluster_members_list) {
  510. node = list_entry(tmp, struct cluster_node, list);
  511. res_lib_votequorum_notification->node_list[i].nodeid = node->node_id;
  512. res_lib_votequorum_notification->node_list[i++].state = node->state;
  513. }
  514. if (quorum_device) {
  515. res_lib_votequorum_notification->node_list[i].nodeid = 0;
  516. res_lib_votequorum_notification->node_list[i++].state = quorum_device->state | 0x80;
  517. }
  518. res_lib_votequorum_notification->header.id = MESSAGE_RES_VOTEQUORUM_NOTIFICATION;
  519. res_lib_votequorum_notification->header.size = size;
  520. res_lib_votequorum_notification->header.error = CS_OK;
  521. /* Send it to all interested parties */
  522. if (conn) {
  523. int ret = corosync_api->ipc_dispatch_send(conn, buf, size);
  524. LEAVE();
  525. return ret;
  526. }
  527. else {
  528. struct quorum_pd *qpd;
  529. list_iterate(tmp, &trackers_list) {
  530. qpd = list_entry(tmp, struct quorum_pd, list);
  531. res_lib_votequorum_notification->context = qpd->tracking_context;
  532. corosync_api->ipc_dispatch_send(qpd->conn, buf, size);
  533. }
  534. }
  535. LEAVE();
  536. return 0;
  537. }
  538. static void send_expectedvotes_notification(void)
  539. {
  540. struct res_lib_votequorum_expectedvotes_notification res_lib_votequorum_expectedvotes_notification;
  541. struct quorum_pd *qpd;
  542. struct list_head *tmp;
  543. log_printf(LOG_DEBUG, "Sending expected votes callback\n");
  544. res_lib_votequorum_expectedvotes_notification.header.id = MESSAGE_RES_VOTEQUORUM_EXPECTEDVOTES_NOTIFICATION;
  545. res_lib_votequorum_expectedvotes_notification.header.size = sizeof(res_lib_votequorum_expectedvotes_notification);
  546. res_lib_votequorum_expectedvotes_notification.header.error = CS_OK;
  547. res_lib_votequorum_expectedvotes_notification.expected_votes = us->expected_votes;
  548. list_iterate(tmp, &trackers_list) {
  549. qpd = list_entry(tmp, struct quorum_pd, list);
  550. res_lib_votequorum_expectedvotes_notification.context = qpd->tracking_context;
  551. corosync_api->ipc_dispatch_send(qpd->conn, &res_lib_votequorum_expectedvotes_notification,
  552. sizeof(struct res_lib_votequorum_expectedvotes_notification));
  553. }
  554. }
  555. static void set_quorate(int total_votes)
  556. {
  557. int quorate;
  558. ENTER();
  559. if (quorum > total_votes) {
  560. quorate = 0;
  561. }
  562. else {
  563. quorate = 1;
  564. }
  565. if (cluster_is_quorate && !quorate)
  566. log_printf(LOG_INFO, "quorum lost, blocking activity\n");
  567. if (!cluster_is_quorate && quorate)
  568. log_printf(LOG_INFO, "quorum regained, resuming activity\n");
  569. /* If we are newly quorate, then kill any DISALLOWED nodes */
  570. if (!cluster_is_quorate && quorate) {
  571. struct cluster_node *node = NULL;
  572. struct list_head *tmp;
  573. list_iterate(tmp, &cluster_members_list) {
  574. node = list_entry(tmp, struct cluster_node, list);
  575. if (node->state == NODESTATE_DISALLOWED)
  576. quorum_exec_send_killnode(node->node_id, VOTEQUORUM_REASON_KILL_REJOIN);
  577. }
  578. }
  579. cluster_is_quorate = quorate;
  580. set_quorum(quorum_members, quorum_members_entries, quorate, &quorum_ringid);
  581. ENTER();
  582. }
  583. static int calculate_quorum(int allow_decrease, int max_expected, unsigned int *ret_total_votes)
  584. {
  585. struct list_head *nodelist;
  586. struct cluster_node *node;
  587. unsigned int total_votes = 0;
  588. unsigned int highest_expected = 0;
  589. unsigned int newquorum, q1, q2;
  590. unsigned int total_nodes = 0;
  591. ENTER();
  592. list_iterate(nodelist, &cluster_members_list) {
  593. node = list_entry(nodelist, struct cluster_node, list);
  594. log_printf(LOG_DEBUG, "node %x state=%d, votes=%d, expected=%d\n",
  595. node->node_id, node->state, node->votes, node->expected_votes);
  596. if (node->state == NODESTATE_MEMBER) {
  597. if (max_expected)
  598. node->expected_votes = max_expected;
  599. else
  600. highest_expected = max(highest_expected, node->expected_votes);
  601. total_votes += node->votes;
  602. total_nodes++;
  603. }
  604. }
  605. if (quorum_device && quorum_device->state == NODESTATE_MEMBER)
  606. total_votes += quorum_device->votes;
  607. if (max_expected > 0)
  608. highest_expected = max_expected;
  609. /* This quorum calculation is taken from the OpenVMS Cluster Systems
  610. * manual, but, then, you guessed that didn't you */
  611. q1 = (highest_expected + 2) / 2;
  612. q2 = (total_votes + 2) / 2;
  613. newquorum = max(q1, q2);
  614. /* Normally quorum never decreases but the system administrator can
  615. * force it down by setting expected votes to a maximum value */
  616. if (!allow_decrease)
  617. newquorum = max(quorum, newquorum);
  618. /* The special two_node mode allows each of the two nodes to retain
  619. * quorum if the other fails. Only one of the two should live past
  620. * fencing (as both nodes try to fence each other in split-brain.)
  621. * Also: if there are more than two nodes, force us inquorate to avoid
  622. * any damage or confusion.
  623. */
  624. if ((quorum_flags & VOTEQUORUM_FLAG_FEATURE_TWONODE) && total_nodes <= 2)
  625. newquorum = 1;
  626. if (ret_total_votes)
  627. *ret_total_votes = total_votes;
  628. LEAVE();
  629. return newquorum;
  630. }
  631. /* Recalculate cluster quorum, set quorate and notify changes */
  632. static void recalculate_quorum(int allow_decrease, int by_current_nodes)
  633. {
  634. unsigned int total_votes = 0;
  635. int cluster_members = 0;
  636. struct list_head *nodelist;
  637. struct cluster_node *node;
  638. ENTER();
  639. list_iterate(nodelist, &cluster_members_list) {
  640. node = list_entry(nodelist, struct cluster_node, list);
  641. if (node->state == NODESTATE_MEMBER) {
  642. if (by_current_nodes)
  643. cluster_members++;
  644. total_votes += node->votes;
  645. }
  646. }
  647. /* Keep expected_votes at the highest number of votes in the cluster */
  648. log_printf(LOG_DEBUG, "total_votes=%d, expected_votes=%d\n", total_votes, us->expected_votes);
  649. if (total_votes > us->expected_votes) {
  650. us->expected_votes = total_votes;
  651. send_expectedvotes_notification();
  652. }
  653. quorum = calculate_quorum(allow_decrease, cluster_members, &total_votes);
  654. set_quorate(total_votes);
  655. send_quorum_notification(NULL, 0L);
  656. LEAVE();
  657. }
  658. static int have_disallowed(void)
  659. {
  660. struct cluster_node *node;
  661. struct list_head *tmp;
  662. list_iterate(tmp, &cluster_members_list) {
  663. node = list_entry(tmp, struct cluster_node, list);
  664. if (node->state == NODESTATE_DISALLOWED)
  665. return 1;
  666. }
  667. return 0;
  668. }
  669. static void node_add_ordered(struct cluster_node *newnode)
  670. {
  671. struct cluster_node *node = NULL;
  672. struct list_head *tmp;
  673. struct list_head *newlist = &newnode->list;
  674. list_iterate(tmp, &cluster_members_list) {
  675. node = list_entry(tmp, struct cluster_node, list);
  676. if (newnode->node_id < node->node_id)
  677. break;
  678. }
  679. if (!node)
  680. list_add(&newnode->list, &cluster_members_list);
  681. else {
  682. newlist->prev = tmp->prev;
  683. newlist->next = tmp;
  684. tmp->prev->next = newlist;
  685. tmp->prev = newlist;
  686. }
  687. }
  688. static struct cluster_node *allocate_node(int nodeid)
  689. {
  690. struct cluster_node *cl;
  691. cl = malloc(sizeof(struct cluster_node));
  692. if (cl) {
  693. memset(cl, 0, sizeof(struct cluster_node));
  694. cl->node_id = nodeid;
  695. if (nodeid)
  696. node_add_ordered(cl);
  697. }
  698. return cl;
  699. }
  700. static struct cluster_node *find_node_by_nodeid(int nodeid)
  701. {
  702. struct cluster_node *node;
  703. struct list_head *tmp;
  704. list_iterate(tmp, &cluster_members_list) {
  705. node = list_entry(tmp, struct cluster_node, list);
  706. if (node->node_id == nodeid)
  707. return node;
  708. }
  709. return NULL;
  710. }
  711. static int quorum_exec_send_nodeinfo()
  712. {
  713. struct req_exec_quorum_nodeinfo req_exec_quorum_nodeinfo;
  714. int ret;
  715. ENTER();
  716. req_exec_quorum_nodeinfo.cmd = VOTEQUORUM_MSG_NODEINFO;
  717. req_exec_quorum_nodeinfo.expected_votes = us->expected_votes;
  718. req_exec_quorum_nodeinfo.votes = us->votes;
  719. req_exec_quorum_nodeinfo.major_version = VOTEQUORUM_MAJOR_VERSION;
  720. req_exec_quorum_nodeinfo.minor_version = VOTEQUORUM_MINOR_VERSION;
  721. req_exec_quorum_nodeinfo.patch_version = VOTEQUORUM_PATCH_VERSION;
  722. req_exec_quorum_nodeinfo.flags = us->flags;
  723. req_exec_quorum_nodeinfo.first_trans = first_trans;
  724. if (have_disallowed())
  725. req_exec_quorum_nodeinfo.flags |= NODE_FLAGS_SEESDISALLOWED;
  726. ret = votequorum_send_message(&req_exec_quorum_nodeinfo, sizeof(req_exec_quorum_nodeinfo));
  727. LEAVE();
  728. return ret;
  729. }
  730. static int quorum_exec_send_reconfigure(int param, int nodeid, int value)
  731. {
  732. struct req_exec_quorum_reconfigure req_exec_quorum_reconfigure;
  733. int ret;
  734. ENTER();
  735. req_exec_quorum_reconfigure.cmd = VOTEQUORUM_MSG_RECONFIGURE;
  736. req_exec_quorum_reconfigure.param = param;
  737. req_exec_quorum_reconfigure.nodeid = nodeid;
  738. req_exec_quorum_reconfigure.value = value;
  739. ret = votequorum_send_message(&req_exec_quorum_reconfigure, sizeof(req_exec_quorum_reconfigure));
  740. LEAVE();
  741. return ret;
  742. }
  743. static int quorum_exec_send_killnode(int nodeid, unsigned int reason)
  744. {
  745. struct req_exec_quorum_killnode req_exec_quorum_killnode;
  746. int ret;
  747. ENTER();
  748. req_exec_quorum_killnode.cmd = VOTEQUORUM_MSG_KILLNODE;
  749. req_exec_quorum_killnode.nodeid = nodeid;
  750. req_exec_quorum_killnode.reason = reason;
  751. ret = votequorum_send_message(&req_exec_quorum_killnode, sizeof(req_exec_quorum_killnode));
  752. LEAVE();
  753. return ret;
  754. }
  755. static void quorum_confchg_fn (
  756. enum totem_configuration_type configuration_type,
  757. unsigned int *member_list, int member_list_entries,
  758. unsigned int *left_list, int left_list_entries,
  759. unsigned int *joined_list, int joined_list_entries,
  760. struct memb_ring_id *ring_id)
  761. {
  762. int i;
  763. int leaving = 0;
  764. struct cluster_node *node;
  765. ENTER();
  766. if (member_list_entries > 1)
  767. first_trans = 0;
  768. if (left_list_entries) {
  769. for (i = 0; i< left_list_entries; i++) {
  770. node = find_node_by_nodeid(left_list[i]);
  771. if (node) {
  772. if (node->state == NODESTATE_LEAVING)
  773. leaving = 1;
  774. node->state = NODESTATE_DEAD;
  775. node->flags |= NODE_FLAGS_BEENDOWN;
  776. }
  777. }
  778. recalculate_quorum(leaving, leaving);
  779. }
  780. if (member_list_entries) {
  781. memcpy(quorum_members, member_list, sizeof(unsigned int) * member_list_entries);
  782. quorum_members_entries = member_list_entries;
  783. if (quorum_device) {
  784. quorum_members[quorum_members_entries++] = 0;
  785. }
  786. quorum_exec_send_nodeinfo();
  787. }
  788. memcpy(&quorum_ringid, ring_id, sizeof(*ring_id));
  789. LEAVE();
  790. }
  791. static void exec_quorum_nodeinfo_endian_convert (void *msg)
  792. {
  793. struct req_exec_quorum_nodeinfo *nodeinfo = (struct req_exec_quorum_nodeinfo *)msg;
  794. nodeinfo->votes = swab32(nodeinfo->votes);
  795. nodeinfo->expected_votes = swab32(nodeinfo->expected_votes);
  796. nodeinfo->major_version = swab32(nodeinfo->major_version);
  797. nodeinfo->minor_version = swab32(nodeinfo->minor_version);
  798. nodeinfo->patch_version = swab32(nodeinfo->patch_version);
  799. nodeinfo->config_version = swab32(nodeinfo->config_version);
  800. nodeinfo->flags = swab32(nodeinfo->flags);
  801. }
  802. static void exec_quorum_reconfigure_endian_convert (void *msg)
  803. {
  804. struct req_exec_quorum_reconfigure *reconfigure = (struct req_exec_quorum_reconfigure *)msg;
  805. reconfigure->nodeid = swab32(reconfigure->nodeid);
  806. reconfigure->value = swab32(reconfigure->value);
  807. }
  808. static void exec_quorum_killnode_endian_convert (void *msg)
  809. {
  810. struct req_exec_quorum_killnode *killnode = (struct req_exec_quorum_killnode *)msg;
  811. killnode->reason = swab16(killnode->reason);
  812. killnode->nodeid = swab32(killnode->nodeid);
  813. }
  814. static void quorum_deliver_fn(unsigned int nodeid, struct iovec *iovec, int iov_len,
  815. int endian_conversion_required)
  816. {
  817. struct q_protheader *header = iovec->iov_base;
  818. char *buf;
  819. ENTER();
  820. if (endian_conversion_required) {
  821. header->srcid = swab32(header->srcid);
  822. header->tgtid = swab32(header->tgtid);
  823. header->flags = swab32(header->flags);
  824. }
  825. /* Only pass on messages for us or everyone */
  826. if (header->tgtport == 0 &&
  827. (header->tgtid == us->node_id ||
  828. header->tgtid == 0)) {
  829. buf = (char *)(iovec->iov_base) + sizeof(struct q_protheader);
  830. switch (*buf) {
  831. case VOTEQUORUM_MSG_NODEINFO:
  832. if (endian_conversion_required)
  833. exec_quorum_nodeinfo_endian_convert(buf);
  834. message_handler_req_exec_quorum_nodeinfo (buf, header->srcid);
  835. break;
  836. case VOTEQUORUM_MSG_RECONFIGURE:
  837. if (endian_conversion_required)
  838. exec_quorum_reconfigure_endian_convert(buf);
  839. message_handler_req_exec_quorum_reconfigure (buf, header->srcid);
  840. break;
  841. case VOTEQUORUM_MSG_KILLNODE:
  842. if (endian_conversion_required)
  843. exec_quorum_killnode_endian_convert(buf);
  844. message_handler_req_exec_quorum_killnode (buf, header->srcid);
  845. break;
  846. /* Just ignore other messages */
  847. }
  848. }
  849. LEAVE();
  850. }
  851. static void message_handler_req_exec_quorum_nodeinfo (
  852. void *message,
  853. unsigned int nodeid)
  854. {
  855. struct req_exec_quorum_nodeinfo *req_exec_quorum_nodeinfo = (struct req_exec_quorum_nodeinfo *)message;
  856. struct cluster_node *node;
  857. int old_votes;
  858. int old_expected;
  859. nodestate_t old_state;
  860. int new_node = 0;
  861. ENTER();
  862. log_printf(LOG_LEVEL_DEBUG, "got nodeinfo message from cluster node %d\n", nodeid);
  863. node = find_node_by_nodeid(nodeid);
  864. if (!node) {
  865. node = allocate_node(nodeid);
  866. new_node = 1;
  867. }
  868. if (!node) {
  869. corosync_api->error_memory_failure();
  870. return;
  871. }
  872. /*
  873. * If the node sending the message sees disallowed nodes and we don't, then
  874. * we have to leave
  875. */
  876. if (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_SEESDISALLOWED && !have_disallowed()) {
  877. /* Must use syslog directly here or the message will never arrive */
  878. syslog(LOG_CRIT, "[VOTEQ]: Joined a cluster with disallowed nodes. must die");
  879. corosync_api->fatal_error(2, __FILE__, __LINE__);
  880. exit(2);
  881. }
  882. old_votes = node->votes;
  883. old_expected = node->expected_votes;
  884. old_state = node->state;
  885. /* Update node state */
  886. if (req_exec_quorum_nodeinfo->minor_version >= 2)
  887. node->votes = req_exec_quorum_nodeinfo->votes;
  888. node->expected_votes = req_exec_quorum_nodeinfo->expected_votes;
  889. node->state = NODESTATE_MEMBER;
  890. /* Check flags for disallowed (if enabled) */
  891. if (quorum_flags & VOTEQUORUM_FLAG_FEATURE_DISALLOWED) {
  892. if ((req_exec_quorum_nodeinfo->flags & NODE_FLAGS_HASSTATE && node->flags & NODE_FLAGS_BEENDOWN) ||
  893. (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_HASSTATE && req_exec_quorum_nodeinfo->first_trans && !(node->flags & NODE_FLAGS_US) && (us->flags & NODE_FLAGS_HASSTATE))) {
  894. if (node->state != NODESTATE_DISALLOWED) {
  895. if (cluster_is_quorate) {
  896. log_printf(LOG_CRIT, "Killing node %d because it has rejoined the cluster with existing state", node->node_id);
  897. node->state = NODESTATE_DISALLOWED;
  898. quorum_exec_send_killnode(nodeid, VOTEQUORUM_REASON_KILL_REJOIN);
  899. }
  900. else {
  901. log_printf(LOG_CRIT, "Node %d not joined to quorum because it has existing state", node->node_id);
  902. node->state = NODESTATE_DISALLOWED;
  903. }
  904. }
  905. }
  906. }
  907. node->flags &= ~NODE_FLAGS_BEENDOWN;
  908. if (new_node || old_votes != node->votes || old_expected != node->expected_votes || old_state != node->state)
  909. recalculate_quorum(0, 0);
  910. LEAVE();
  911. }
  912. static void message_handler_req_exec_quorum_killnode (
  913. void *message,
  914. unsigned int nodeid)
  915. {
  916. struct req_exec_quorum_killnode *req_exec_quorum_killnode = (struct req_exec_quorum_killnode *)message;
  917. if (req_exec_quorum_killnode->nodeid == corosync_api->totem_nodeid_get()) {
  918. log_printf(LOG_CRIT, "Killed by node %d: %s\n", nodeid, kill_reason(req_exec_quorum_killnode->reason));
  919. corosync_api->fatal_error(1, __FILE__, __LINE__);
  920. exit(1);
  921. }
  922. }
  923. static void message_handler_req_exec_quorum_reconfigure (
  924. void *message,
  925. unsigned int nodeid)
  926. {
  927. struct req_exec_quorum_reconfigure *req_exec_quorum_reconfigure = (struct req_exec_quorum_reconfigure *)message;
  928. struct cluster_node *node;
  929. struct list_head *nodelist;
  930. log_printf(LOG_LEVEL_DEBUG, "got reconfigure message from cluster node %d\n", nodeid);
  931. node = find_node_by_nodeid(req_exec_quorum_reconfigure->nodeid);
  932. if (!node)
  933. return;
  934. switch(req_exec_quorum_reconfigure->param)
  935. {
  936. case RECONFIG_PARAM_EXPECTED_VOTES:
  937. list_iterate(nodelist, &cluster_members_list) {
  938. node = list_entry(nodelist, struct cluster_node, list);
  939. if (node->state == NODESTATE_MEMBER &&
  940. node->expected_votes > req_exec_quorum_reconfigure->value) {
  941. node->expected_votes = req_exec_quorum_reconfigure->value;
  942. }
  943. }
  944. send_expectedvotes_notification();
  945. recalculate_quorum(1, 0); /* Allow decrease */
  946. break;
  947. case RECONFIG_PARAM_NODE_VOTES:
  948. node->votes = req_exec_quorum_reconfigure->value;
  949. recalculate_quorum(1, 0); /* Allow decrease */
  950. break;
  951. case RECONFIG_PARAM_LEAVING:
  952. if (req_exec_quorum_reconfigure->value == 1 && node->state == NODESTATE_MEMBER)
  953. node->state = NODESTATE_LEAVING;
  954. if (req_exec_quorum_reconfigure->value == 0 && node->state == NODESTATE_LEAVING)
  955. node->state = NODESTATE_MEMBER;
  956. break;
  957. }
  958. }
  959. static int quorum_lib_init_fn (void *conn)
  960. {
  961. struct quorum_pd *pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  962. ENTER();
  963. list_init (&pd->list);
  964. pd->conn = conn;
  965. LEAVE();
  966. return (0);
  967. }
  968. /*
  969. * Someone called votequorum_leave AGES ago!
  970. * Assume they forgot to shut down the node.
  971. */
  972. static void leaving_timer_fn(void *arg)
  973. {
  974. ENTER();
  975. if (us->state == NODESTATE_LEAVING)
  976. us->state = NODESTATE_MEMBER;
  977. /* Tell everyone else we made a mistake */
  978. quorum_exec_send_reconfigure(RECONFIG_PARAM_LEAVING, us->node_id, 0);
  979. LEAVE();
  980. }
  981. /* Message from the library */
  982. static void message_handler_req_lib_votequorum_getinfo (void *conn, void *message)
  983. {
  984. struct req_lib_votequorum_getinfo *req_lib_votequorum_getinfo = (struct req_lib_votequorum_getinfo *)message;
  985. struct res_lib_votequorum_getinfo res_lib_votequorum_getinfo;
  986. struct cluster_node *node;
  987. unsigned int highest_expected = 0;
  988. unsigned int total_votes = 0;
  989. cs_error_t error = CS_OK;
  990. log_printf(LOG_LEVEL_DEBUG, "got getinfo request on %p for node %d\n", conn, req_lib_votequorum_getinfo->nodeid);
  991. if (req_lib_votequorum_getinfo->nodeid) {
  992. node = find_node_by_nodeid(req_lib_votequorum_getinfo->nodeid);
  993. }
  994. else {
  995. node = us;
  996. }
  997. if (node) {
  998. struct cluster_node *iternode;
  999. struct list_head *nodelist;
  1000. list_iterate(nodelist, &cluster_members_list) {
  1001. iternode = list_entry(nodelist, struct cluster_node, list);
  1002. if (iternode->state == NODESTATE_MEMBER) {
  1003. highest_expected =
  1004. max(highest_expected, iternode->expected_votes);
  1005. total_votes += iternode->votes;
  1006. }
  1007. }
  1008. if (quorum_device && quorum_device->state == NODESTATE_MEMBER) {
  1009. total_votes += quorum_device->votes;
  1010. }
  1011. res_lib_votequorum_getinfo.votes = us->votes;
  1012. res_lib_votequorum_getinfo.expected_votes = us->expected_votes;
  1013. res_lib_votequorum_getinfo.highest_expected = highest_expected;
  1014. res_lib_votequorum_getinfo.quorum = quorum;
  1015. res_lib_votequorum_getinfo.total_votes = total_votes;
  1016. res_lib_votequorum_getinfo.flags = 0;
  1017. res_lib_votequorum_getinfo.nodeid = node->node_id;
  1018. if (us->flags & NODE_FLAGS_HASSTATE)
  1019. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_HASSTATE;
  1020. if (quorum_flags & VOTEQUORUM_FLAG_FEATURE_TWONODE)
  1021. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_TWONODE;
  1022. if (cluster_is_quorate)
  1023. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_QUORATE;
  1024. if (us->flags & NODE_FLAGS_SEESDISALLOWED)
  1025. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_DISALLOWED;
  1026. }
  1027. else {
  1028. error = CS_ERR_NOT_EXIST;
  1029. }
  1030. res_lib_votequorum_getinfo.header.size = sizeof(res_lib_votequorum_getinfo);
  1031. res_lib_votequorum_getinfo.header.id = MESSAGE_RES_VOTEQUORUM_GETINFO;
  1032. res_lib_votequorum_getinfo.header.error = error;
  1033. corosync_api->ipc_response_send(conn, &res_lib_votequorum_getinfo, sizeof(res_lib_votequorum_getinfo));
  1034. log_printf(LOG_LEVEL_DEBUG, "getinfo response error: %d\n", error);
  1035. }
  1036. /* Message from the library */
  1037. static void message_handler_req_lib_votequorum_setexpected (void *conn, void *message)
  1038. {
  1039. struct req_lib_votequorum_setexpected *req_lib_votequorum_setexpected = (struct req_lib_votequorum_setexpected *)message;
  1040. struct res_lib_votequorum_status res_lib_votequorum_status;
  1041. cs_error_t error = CS_OK;
  1042. unsigned int newquorum;
  1043. unsigned int total_votes;
  1044. ENTER();
  1045. /*
  1046. * If there are disallowed nodes, then we can't allow the user
  1047. * to bypass them by fiddling with expected votes.
  1048. */
  1049. if (quorum_flags & VOTEQUORUM_FLAG_FEATURE_DISALLOWED && have_disallowed()) {
  1050. error = CS_ERR_EXIST;
  1051. goto error_exit;
  1052. }
  1053. /* Validate new expected votes */
  1054. newquorum = calculate_quorum(1, req_lib_votequorum_setexpected->expected_votes, &total_votes);
  1055. if (newquorum < total_votes / 2
  1056. || newquorum > total_votes) {
  1057. error = CS_ERR_INVALID_PARAM;
  1058. goto error_exit;
  1059. }
  1060. quorum_exec_send_reconfigure(RECONFIG_PARAM_EXPECTED_VOTES, us->node_id, req_lib_votequorum_setexpected->expected_votes);
  1061. /* send status */
  1062. error_exit:
  1063. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1064. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1065. res_lib_votequorum_status.header.error = error;
  1066. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1067. LEAVE();
  1068. }
  1069. /* Message from the library */
  1070. static void message_handler_req_lib_votequorum_setvotes (void *conn, void *message)
  1071. {
  1072. struct req_lib_votequorum_setvotes *req_lib_votequorum_setvotes = (struct req_lib_votequorum_setvotes *)message;
  1073. struct res_lib_votequorum_status res_lib_votequorum_status;
  1074. struct cluster_node *node;
  1075. unsigned int newquorum;
  1076. unsigned int total_votes;
  1077. unsigned int saved_votes;
  1078. cs_error_t error = CS_OK;
  1079. ENTER();
  1080. node = find_node_by_nodeid(req_lib_votequorum_setvotes->nodeid);
  1081. if (!node) {
  1082. error = CS_ERR_NAME_NOT_FOUND;
  1083. goto error_exit;
  1084. }
  1085. /* Check votes is valid */
  1086. saved_votes = node->votes;
  1087. node->votes = req_lib_votequorum_setvotes->votes;
  1088. newquorum = calculate_quorum(1, 0, &total_votes);
  1089. if (newquorum < total_votes / 2 || newquorum > total_votes) {
  1090. node->votes = saved_votes;
  1091. error = CS_ERR_INVALID_PARAM;
  1092. goto error_exit;
  1093. }
  1094. if (!req_lib_votequorum_setvotes->nodeid)
  1095. req_lib_votequorum_setvotes->nodeid = corosync_api->totem_nodeid_get();
  1096. quorum_exec_send_reconfigure(RECONFIG_PARAM_NODE_VOTES, req_lib_votequorum_setvotes->nodeid, req_lib_votequorum_setvotes->votes);
  1097. error_exit:
  1098. /* send status */
  1099. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1100. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1101. res_lib_votequorum_status.header.error = error;
  1102. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1103. LEAVE();
  1104. }
  1105. static void message_handler_req_lib_votequorum_leaving (void *conn, void *message)
  1106. {
  1107. struct res_lib_votequorum_status res_lib_votequorum_status;
  1108. cs_error_t error = CS_OK;
  1109. ENTER();
  1110. quorum_exec_send_reconfigure(RECONFIG_PARAM_LEAVING, us->node_id, 1);
  1111. /*
  1112. * If we don't shut down in a sensible amount of time then cancel the
  1113. * leave status.
  1114. */
  1115. if (leaving_timeout)
  1116. corosync_api->timer_add_duration((unsigned long long)leaving_timeout*1000000, NULL,
  1117. leaving_timer_fn, &leaving_timer);
  1118. /* send status */
  1119. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1120. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1121. res_lib_votequorum_status.header.error = error;
  1122. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1123. LEAVE();
  1124. }
  1125. static void quorum_device_timer_fn(void *arg)
  1126. {
  1127. struct timeval now;
  1128. ENTER();
  1129. if (!quorum_device || quorum_device->state == NODESTATE_DEAD)
  1130. return;
  1131. gettimeofday(&now, NULL);
  1132. if (quorum_device->last_hello.tv_sec + quorumdev_poll/1000 < now.tv_sec) {
  1133. quorum_device->state = NODESTATE_DEAD;
  1134. log_printf(LOG_INFO, "lost contact with quorum device\n");
  1135. recalculate_quorum(0, 0);
  1136. }
  1137. else {
  1138. corosync_api->timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
  1139. quorum_device_timer_fn, &quorum_device_timer);
  1140. }
  1141. LEAVE();
  1142. }
  1143. static void message_handler_req_lib_votequorum_qdisk_register (void *conn, void *message)
  1144. {
  1145. struct req_lib_votequorum_qdisk_register *req_lib_votequorum_qdisk_register = (struct req_lib_votequorum_qdisk_register *)message;
  1146. struct res_lib_votequorum_status res_lib_votequorum_status;
  1147. cs_error_t error = CS_OK;
  1148. ENTER();
  1149. if (quorum_device) {
  1150. error = CS_ERR_EXIST;
  1151. }
  1152. else {
  1153. quorum_device = allocate_node(0);
  1154. quorum_device->state = NODESTATE_DEAD;
  1155. quorum_device->votes = req_lib_votequorum_qdisk_register->votes;
  1156. strcpy(quorum_device_name, req_lib_votequorum_qdisk_register->name);
  1157. list_add(&quorum_device->list, &cluster_members_list);
  1158. }
  1159. /* send status */
  1160. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1161. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1162. res_lib_votequorum_status.header.error = error;
  1163. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1164. LEAVE();
  1165. }
  1166. static void message_handler_req_lib_votequorum_qdisk_unregister (void *conn, void *message)
  1167. {
  1168. struct res_lib_votequorum_status res_lib_votequorum_status;
  1169. cs_error_t error = CS_OK;
  1170. ENTER();
  1171. if (quorum_device) {
  1172. struct cluster_node *node = quorum_device;
  1173. quorum_device = NULL;
  1174. list_del(&node->list);
  1175. free(node);
  1176. recalculate_quorum(0, 0);
  1177. }
  1178. else {
  1179. error = CS_ERR_NOT_EXIST;
  1180. }
  1181. /* send status */
  1182. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1183. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1184. res_lib_votequorum_status.header.error = error;
  1185. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1186. LEAVE();
  1187. }
  1188. static void message_handler_req_lib_votequorum_qdisk_poll (void *conn, void *message)
  1189. {
  1190. struct req_lib_votequorum_qdisk_poll *req_lib_votequorum_qdisk_poll = (struct req_lib_votequorum_qdisk_poll *)message;
  1191. struct res_lib_votequorum_status res_lib_votequorum_status;
  1192. cs_error_t error = CS_OK;
  1193. ENTER();
  1194. if (quorum_device) {
  1195. if (req_lib_votequorum_qdisk_poll->state) {
  1196. gettimeofday(&quorum_device->last_hello, NULL);
  1197. if (quorum_device->state == NODESTATE_DEAD) {
  1198. quorum_device->state = NODESTATE_MEMBER;
  1199. recalculate_quorum(0, 0);
  1200. corosync_api->timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
  1201. quorum_device_timer_fn, &quorum_device_timer);
  1202. }
  1203. }
  1204. else {
  1205. if (quorum_device->state == NODESTATE_MEMBER) {
  1206. quorum_device->state = NODESTATE_DEAD;
  1207. recalculate_quorum(0, 0);
  1208. corosync_api->timer_delete(quorum_device_timer);
  1209. }
  1210. }
  1211. }
  1212. else {
  1213. error = CS_ERR_NOT_EXIST;
  1214. }
  1215. /* send status */
  1216. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1217. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1218. res_lib_votequorum_status.header.error = error;
  1219. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1220. LEAVE();
  1221. }
  1222. static void message_handler_req_lib_votequorum_qdisk_getinfo (void *conn, void *message)
  1223. {
  1224. struct res_lib_votequorum_qdisk_getinfo res_lib_votequorum_qdisk_getinfo;
  1225. cs_error_t error = CS_OK;
  1226. ENTER();
  1227. if (quorum_device) {
  1228. log_printf(LOG_LEVEL_DEBUG, "got qdisk_getinfo state %d\n", quorum_device->state);
  1229. res_lib_votequorum_qdisk_getinfo.votes = quorum_device->votes;
  1230. if (quorum_device->state == NODESTATE_MEMBER)
  1231. res_lib_votequorum_qdisk_getinfo.state = 1;
  1232. else
  1233. res_lib_votequorum_qdisk_getinfo.state = 0;
  1234. strcpy(res_lib_votequorum_qdisk_getinfo.name, quorum_device_name);
  1235. }
  1236. else {
  1237. error = CS_ERR_NOT_EXIST;
  1238. }
  1239. /* send status */
  1240. res_lib_votequorum_qdisk_getinfo.header.size = sizeof(res_lib_votequorum_qdisk_getinfo);
  1241. res_lib_votequorum_qdisk_getinfo.header.id = MESSAGE_RES_VOTEQUORUM_GETINFO;
  1242. res_lib_votequorum_qdisk_getinfo.header.error = error;
  1243. corosync_api->ipc_response_send(conn, &res_lib_votequorum_qdisk_getinfo, sizeof(res_lib_votequorum_qdisk_getinfo));
  1244. LEAVE();
  1245. }
  1246. static void message_handler_req_lib_votequorum_setstate (void *conn, void *message)
  1247. {
  1248. struct res_lib_votequorum_status res_lib_votequorum_status;
  1249. cs_error_t error = CS_OK;
  1250. ENTER();
  1251. us->flags |= NODE_FLAGS_HASSTATE;
  1252. /* send status */
  1253. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1254. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1255. res_lib_votequorum_status.header.error = error;
  1256. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1257. LEAVE();
  1258. }
  1259. static void message_handler_req_lib_votequorum_trackstart (void *conn, void *msg)
  1260. {
  1261. struct req_lib_votequorum_trackstart *req_lib_votequorum_trackstart = (struct req_lib_votequorum_trackstart *)msg;
  1262. struct res_lib_votequorum_status res_lib_votequorum_status;
  1263. struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  1264. ENTER();
  1265. /*
  1266. * If an immediate listing of the current cluster membership
  1267. * is requested, generate membership list
  1268. */
  1269. if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CURRENT ||
  1270. req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES) {
  1271. log_printf(LOG_LEVEL_DEBUG, "sending initial status to %p\n", conn);
  1272. send_quorum_notification(conn, req_lib_votequorum_trackstart->context);
  1273. }
  1274. /*
  1275. * Record requests for tracking
  1276. */
  1277. if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES ||
  1278. req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES_ONLY) {
  1279. quorum_pd->track_flags = req_lib_votequorum_trackstart->track_flags;
  1280. quorum_pd->tracking_enabled = 1;
  1281. quorum_pd->tracking_context = req_lib_votequorum_trackstart->context;
  1282. list_add (&quorum_pd->list, &trackers_list);
  1283. }
  1284. /* Send status */
  1285. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1286. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1287. res_lib_votequorum_status.header.error = CS_OK;
  1288. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1289. LEAVE();
  1290. }
  1291. static void message_handler_req_lib_votequorum_trackstop (void *conn, void *msg)
  1292. {
  1293. struct res_lib_votequorum_status res_lib_votequorum_status;
  1294. struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  1295. int error = CS_OK;
  1296. ENTER();
  1297. if (quorum_pd->tracking_enabled) {
  1298. error = CS_OK;
  1299. quorum_pd->tracking_enabled = 0;
  1300. list_del (&quorum_pd->list);
  1301. list_init (&quorum_pd->list);
  1302. } else {
  1303. error = CS_ERR_NOT_EXIST;
  1304. }
  1305. /* send status */
  1306. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1307. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1308. res_lib_votequorum_status.header.error = error;
  1309. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1310. LEAVE();
  1311. }
  1312. static const char *kill_reason(int reason)
  1313. {
  1314. static char msg[1024];
  1315. switch (reason)
  1316. {
  1317. case VOTEQUORUM_REASON_KILL_REJECTED:
  1318. return "our membership application was rejected";
  1319. case VOTEQUORUM_REASON_KILL_APPLICATION:
  1320. return "we were killed by an application request";
  1321. case VOTEQUORUM_REASON_KILL_REJOIN:
  1322. return "we rejoined the cluster without a full restart";
  1323. default:
  1324. sprintf(msg, "we got kill message number %d", reason);
  1325. return msg;
  1326. }
  1327. }
  1328. static void reread_config(hdb_handle_t object_handle)
  1329. {
  1330. unsigned int old_votes;
  1331. unsigned int old_expected;
  1332. old_votes = us->votes;
  1333. old_expected = us->expected_votes;
  1334. /*
  1335. * Reload the configuration
  1336. */
  1337. read_quorum_config(object_handle);
  1338. /*
  1339. * Check for fundamental changes that we need to propogate
  1340. */
  1341. if (old_votes != us->votes) {
  1342. quorum_exec_send_reconfigure(RECONFIG_PARAM_NODE_VOTES, us->node_id, us->votes);
  1343. }
  1344. if (old_expected != us->expected_votes) {
  1345. quorum_exec_send_reconfigure(RECONFIG_PARAM_EXPECTED_VOTES, us->node_id, us->expected_votes);
  1346. }
  1347. }
  1348. static void quorum_key_change_notify(object_change_type_t change_type,
  1349. hdb_handle_t parent_object_handle,
  1350. hdb_handle_t object_handle,
  1351. const void *object_name_pt,
  1352. int object_name_len,
  1353. const void *key_name_pt, int key_len,
  1354. const void *key_value_pt, int key_value_len,
  1355. void *priv_data_pt)
  1356. {
  1357. if (memcmp(object_name_pt, "quorum", object_name_len) == 0)
  1358. reread_config(object_handle);
  1359. }
  1360. /* Called when the objdb is reloaded */
  1361. static void votequorum_objdb_reload_notify(
  1362. objdb_reload_notify_type_t type, int flush,
  1363. void *priv_data_pt)
  1364. {
  1365. /*
  1366. * A new quorum {} key might exist, cancel the
  1367. * existing notification at the start of reload,
  1368. * and start a new one on the new object when
  1369. * it's all settled.
  1370. */
  1371. if (type == OBJDB_RELOAD_NOTIFY_START) {
  1372. corosync_api->object_track_stop(
  1373. quorum_key_change_notify,
  1374. NULL,
  1375. NULL,
  1376. NULL,
  1377. NULL);
  1378. }
  1379. if (type == OBJDB_RELOAD_NOTIFY_END ||
  1380. type == OBJDB_RELOAD_NOTIFY_FAILED) {
  1381. hdb_handle_t find_handle;
  1382. hdb_handle_t object_handle;
  1383. corosync_api->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle);
  1384. if (corosync_api->object_find_next(find_handle, &object_handle) == 0) {
  1385. add_votequorum_config_notification(object_handle);
  1386. reread_config(object_handle);
  1387. }
  1388. else {
  1389. log_printf(LOG_LEVEL_ERROR, "votequorum objdb tracking stopped, cannot find quorum{} handle in objdb\n");
  1390. }
  1391. }
  1392. }
  1393. static void add_votequorum_config_notification(
  1394. hdb_handle_t quorum_object_handle)
  1395. {
  1396. corosync_api->object_track_start(quorum_object_handle,
  1397. 1,
  1398. quorum_key_change_notify,
  1399. NULL,
  1400. NULL,
  1401. NULL,
  1402. NULL);
  1403. /*
  1404. * Reload notify must be on the parent object
  1405. */
  1406. corosync_api->object_track_start(OBJECT_PARENT_HANDLE,
  1407. 1,
  1408. NULL,
  1409. NULL,
  1410. NULL,
  1411. votequorum_objdb_reload_notify,
  1412. NULL);
  1413. }