From 04a57cca495c4653a9f5709efcbc1c708c7aea22 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 29 2019 11:44:03 +0000 Subject: import sbd-1.4.0-15.el7 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01e5d42 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/sbd-7f33d1a409d0a4e2cd69946688c48eaa8f3c5d26.tar.gz diff --git a/.sbd.metadata b/.sbd.metadata new file mode 100644 index 0000000..4341adc --- /dev/null +++ b/.sbd.metadata @@ -0,0 +1 @@ +7bf4ad26875cafa743ca96aec9dae1739bd6281b SOURCES/sbd-7f33d1a409d0a4e2cd69946688c48eaa8f3c5d26.tar.gz diff --git a/SOURCES/0001-Fix-sbd-cluster-finalize-cmap-connection-if-disconne.patch b/SOURCES/0001-Fix-sbd-cluster-finalize-cmap-connection-if-disconne.patch new file mode 100644 index 0000000..a2cc41a --- /dev/null +++ b/SOURCES/0001-Fix-sbd-cluster-finalize-cmap-connection-if-disconne.patch @@ -0,0 +1,79 @@ +From f8f980340256ab5bef5385cd3bc082fdfb7613ed Mon Sep 17 00:00:00 2001 +From: "Gao,Yan" +Date: Thu, 7 Mar 2019 15:01:26 +0100 +Subject: [PATCH] Fix: sbd-cluster: finalize cmap connection if disconnected + from cluster + +Previously if sbd cluster servant anyhow got dis-/reconnected from the +cluster, it'd start hogging CPU keeping polling the main loop source +from the old cmap connection. +--- + src/sbd-cluster.c | 38 ++++++++++++++++++++++++++------------ + 1 file changed, 26 insertions(+), 12 deletions(-) + +diff --git a/src/sbd-cluster.c b/src/sbd-cluster.c +index 51bb456..541212f 100644 +--- a/src/sbd-cluster.c ++++ b/src/sbd-cluster.c +@@ -174,6 +174,25 @@ cmap_dispatch_callback (gpointer user_data) + return TRUE; + } + ++static void ++cmap_destroy(void) ++{ ++ if (cmap_source) { ++ g_source_destroy(cmap_source); ++ cmap_source = NULL; ++ } ++ ++ if (track_handle) { ++ cmap_track_delete(cmap_handle, track_handle); ++ track_handle = 0; ++ } ++ ++ if (cmap_handle) { ++ cmap_finalize(cmap_handle); ++ cmap_handle = 0; ++ } ++} ++ + static gboolean + sbd_get_two_node(void) + { +@@ -217,18 +236,7 @@ sbd_get_two_node(void) + return TRUE; + + out: +- if (cmap_source) { +- g_source_destroy(cmap_source); +- cmap_source = NULL; +- } +- if (track_handle) { +- cmap_track_delete(cmap_handle, track_handle); +- track_handle = 0; +- } +- if (cmap_handle) { +- cmap_finalize(cmap_handle); +- cmap_handle = 0; +- } ++ cmap_destroy(); + + return FALSE; + } +@@ -327,6 +335,12 @@ sbd_membership_destroy(gpointer user_data) + { + cl_log(LOG_WARNING, "Lost connection to %s", name_for_cluster_type(get_cluster_type())); + ++ if (get_cluster_type() != pcmk_cluster_unknown) { ++#if SUPPORT_COROSYNC && CHECK_TWO_NODE ++ cmap_destroy(); ++#endif ++ } ++ + set_servant_health(pcmk_health_unclean, LOG_ERR, "Cluster connection terminated"); + notify_parent(); + +-- +1.8.3.1 + diff --git a/SOURCES/0002-Fix-sbd-pacemaker-make-handling-of-cib-connection-lo.patch b/SOURCES/0002-Fix-sbd-pacemaker-make-handling-of-cib-connection-lo.patch new file mode 100644 index 0000000..0d70c92 --- /dev/null +++ b/SOURCES/0002-Fix-sbd-pacemaker-make-handling-of-cib-connection-lo.patch @@ -0,0 +1,302 @@ +From a716a8ddd3df615009bcff3bd96dd9ae64cb5f68 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Tue, 19 Mar 2019 21:36:15 +0100 +Subject: [PATCH] Fix: sbd-pacemaker: make handling of cib-connection loss more + robust + +Exit pcmk-servant on graceful pacemaker shutdown and go back +to state before pacemaker was detected initially. +Purge all cib-traces otherwise and try to reconnect within timeout. +--- + src/sbd-inquisitor.c | 24 ++++++++++++++++++++---- + src/sbd-md.c | 30 +++++++++++++++--------------- + src/sbd-pacemaker.c | 38 +++++++++++++++++++++++++++++--------- + src/sbd.h | 11 +++++++---- + 4 files changed, 71 insertions(+), 32 deletions(-) + +diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c +index 9be6c99..77c6e4f 100644 +--- a/src/sbd-inquisitor.c ++++ b/src/sbd-inquisitor.c +@@ -490,19 +490,19 @@ void inquisitor_child(void) + if (sbd_is_disk(s)) { + if (WIFEXITED(status)) { + switch(WEXITSTATUS(status)) { +- case EXIT_MD_IO_FAIL: ++ case EXIT_MD_SERVANT_IO_FAIL: + DBGLOG(LOG_INFO, "Servant for %s requests to be disowned", + s->devname); + break; +- case EXIT_MD_REQUEST_RESET: ++ case EXIT_MD_SERVANT_REQUEST_RESET: + cl_log(LOG_WARNING, "%s requested a reset", s->devname); + do_reset(); + break; +- case EXIT_MD_REQUEST_SHUTOFF: ++ case EXIT_MD_SERVANT_REQUEST_SHUTOFF: + cl_log(LOG_WARNING, "%s requested a shutoff", s->devname); + do_off(); + break; +- case EXIT_MD_REQUEST_CRASHDUMP: ++ case EXIT_MD_SERVANT_REQUEST_CRASHDUMP: + cl_log(LOG_WARNING, "%s requested a crashdump", s->devname); + do_crashdump(); + break; +@@ -510,6 +510,22 @@ void inquisitor_child(void) + break; + } + } ++ } else if (sbd_is_pcmk(s)) { ++ if (WIFEXITED(status)) { ++ switch(WEXITSTATUS(status)) { ++ case EXIT_PCMK_SERVANT_GRACEFUL_SHUTDOWN: ++ DBGLOG(LOG_INFO, "PCMK-Servant has exited gracefully"); ++ /* revert to state prior to pacemaker-detection */ ++ s->restarts = 0; ++ s->restart_blocked = 0; ++ cluster_appeared = 0; ++ s->outdated = 1; ++ s->t_last.tv_sec = 0; ++ break; ++ default: ++ break; ++ } ++ } + } + cleanup_servant_by_pid(pid); + } +diff --git a/src/sbd-md.c b/src/sbd-md.c +index ba2c34d..c51d381 100644 +--- a/src/sbd-md.c ++++ b/src/sbd-md.c +@@ -1061,19 +1061,19 @@ int servant_md(const char *diskname, int mode, const void* argp) + + st = open_device(diskname, LOG_WARNING); + if (!st) { +- exit(EXIT_MD_IO_FAIL); ++ exit(EXIT_MD_SERVANT_IO_FAIL); + } + + s_header = header_get(st); + if (!s_header) { + cl_log(LOG_ERR, "Not a valid header on %s", diskname); +- exit(EXIT_MD_IO_FAIL); ++ exit(EXIT_MD_SERVANT_IO_FAIL); + } + + if (servant_check_timeout_inconsistent(s_header) < 0) { + cl_log(LOG_ERR, "Timeouts on %s do not match first device", + diskname); +- exit(EXIT_MD_IO_FAIL); ++ exit(EXIT_MD_SERVANT_IO_FAIL); + } + + if (s_header->minor_version > 0) { +@@ -1086,14 +1086,14 @@ int servant_md(const char *diskname, int mode, const void* argp) + cl_log(LOG_ERR, + "No slot allocated, and automatic allocation failed for disk %s.", + diskname); +- rc = EXIT_MD_IO_FAIL; ++ rc = EXIT_MD_SERVANT_IO_FAIL; + goto out; + } + s_node = sector_alloc(); + if (slot_read(st, mbox, s_node) < 0) { + cl_log(LOG_ERR, "Unable to read node entry on %s", + diskname); +- exit(EXIT_MD_IO_FAIL); ++ exit(EXIT_MD_SERVANT_IO_FAIL); + } + + cl_log(LOG_NOTICE, "Monitoring slot %d on disk %s", mbox, diskname); +@@ -1109,7 +1109,7 @@ int servant_md(const char *diskname, int mode, const void* argp) + if (mode > 0) { + if (mbox_read(st, mbox, s_mbox) < 0) { + cl_log(LOG_ERR, "mbox read failed during start-up in servant."); +- rc = EXIT_MD_IO_FAIL; ++ rc = EXIT_MD_SERVANT_IO_FAIL; + goto out; + } + if (s_mbox->cmd != SBD_MSG_EXIT && +@@ -1125,7 +1125,7 @@ int servant_md(const char *diskname, int mode, const void* argp) + DBGLOG(LOG_INFO, "First servant start - zeroing inbox"); + memset(s_mbox, 0, sizeof(*s_mbox)); + if (mbox_write(st, mbox, s_mbox) < 0) { +- rc = EXIT_MD_IO_FAIL; ++ rc = EXIT_MD_SERVANT_IO_FAIL; + goto out; + } + } +@@ -1154,28 +1154,28 @@ int servant_md(const char *diskname, int mode, const void* argp) + s_header_retry = header_get(st); + if (!s_header_retry) { + cl_log(LOG_ERR, "No longer found a valid header on %s", diskname); +- exit(EXIT_MD_IO_FAIL); ++ exit(EXIT_MD_SERVANT_IO_FAIL); + } + if (memcmp(s_header, s_header_retry, sizeof(*s_header)) != 0) { + cl_log(LOG_ERR, "Header on %s changed since start-up!", diskname); +- exit(EXIT_MD_IO_FAIL); ++ exit(EXIT_MD_SERVANT_IO_FAIL); + } + free(s_header_retry); + + s_node_retry = sector_alloc(); + if (slot_read(st, mbox, s_node_retry) < 0) { + cl_log(LOG_ERR, "slot read failed in servant."); +- exit(EXIT_MD_IO_FAIL); ++ exit(EXIT_MD_SERVANT_IO_FAIL); + } + if (memcmp(s_node, s_node_retry, sizeof(*s_node)) != 0) { + cl_log(LOG_ERR, "Node entry on %s changed since start-up!", diskname); +- exit(EXIT_MD_IO_FAIL); ++ exit(EXIT_MD_SERVANT_IO_FAIL); + } + free(s_node_retry); + + if (mbox_read(st, mbox, s_mbox) < 0) { + cl_log(LOG_ERR, "mbox read failed in servant."); +- exit(EXIT_MD_IO_FAIL); ++ exit(EXIT_MD_SERVANT_IO_FAIL); + } + + if (s_mbox->cmd > 0) { +@@ -1190,14 +1190,14 @@ int servant_md(const char *diskname, int mode, const void* argp) + sigqueue(ppid, SIG_TEST, signal_value); + break; + case SBD_MSG_RESET: +- exit(EXIT_MD_REQUEST_RESET); ++ exit(EXIT_MD_SERVANT_REQUEST_RESET); + case SBD_MSG_OFF: +- exit(EXIT_MD_REQUEST_SHUTOFF); ++ exit(EXIT_MD_SERVANT_REQUEST_SHUTOFF); + case SBD_MSG_EXIT: + sigqueue(ppid, SIG_EXITREQ, signal_value); + break; + case SBD_MSG_CRASHDUMP: +- exit(EXIT_MD_REQUEST_CRASHDUMP); ++ exit(EXIT_MD_SERVANT_REQUEST_CRASHDUMP); + default: + /* FIXME: + An "unknown" message might result +diff --git a/src/sbd-pacemaker.c b/src/sbd-pacemaker.c +index aac355a..c69fc55 100644 +--- a/src/sbd-pacemaker.c ++++ b/src/sbd-pacemaker.c +@@ -103,6 +103,9 @@ static pe_working_set_t *data_set = NULL; + + static long last_refresh = 0; + ++static int pcmk_clean_shutdown = 0; ++static int pcmk_shutdown = 0; ++ + static gboolean + mon_timer_reconnect(gpointer data) + { +@@ -128,10 +131,26 @@ mon_cib_connection_destroy(gpointer user_data) + { + if (cib) { + cib->cmds->signoff(cib); ++ /* retrigger as last one might have been skipped */ ++ mon_refresh_state(NULL); ++ if (pcmk_clean_shutdown) { ++ /* assume a graceful pacemaker-shutdown */ ++ clean_up(EXIT_PCMK_SERVANT_GRACEFUL_SHUTDOWN); ++ } ++ /* getting here we aren't sure about the pacemaker-state ++ so try to use the timeout to reconnect and get ++ everything sorted out again ++ */ ++ pcmk_shutdown = 0; + set_servant_health(pcmk_health_transient, LOG_WARNING, "Disconnected from CIB"); + timer_id_reconnect = g_timeout_add(reconnect_msec, mon_timer_reconnect, NULL); + } + cib_connected = 0; ++ /* no sense in looking into outdated cib, trying to apply patch, ... */ ++ if (current_cib) { ++ free_xml(current_cib); ++ current_cib = NULL; ++ } + return; + } + +@@ -171,7 +190,7 @@ static gboolean + mon_timer_notify(gpointer data) + { + static int counter = 0; +- int counter_max = timeout_watchdog / timeout_loop; ++ int counter_max = timeout_watchdog / timeout_loop / 2; + + if (timer_id_notify > 0) { + g_source_remove(timer_id_notify); +@@ -280,11 +299,6 @@ compute_status(pe_working_set_t * data_set) + } else if (node->details->pending) { + set_servant_health(pcmk_health_pending, LOG_WARNING, "Node state: pending"); + +-#if 0 +- } else if (node->details->shutdown) { +- set_servant_health(pcmk_health_shutdown, LOG_WARNING, "Node state: shutting down"); +-#endif +- + } else if (data_set->flags & pe_flag_have_quorum) { + set_servant_health(pcmk_health_online, LOG_INFO, "Node state: online"); + ever_had_quorum = TRUE; +@@ -315,6 +329,12 @@ compute_status(pe_working_set_t * data_set) + } + } + ++ if (node->details->shutdown) { ++ pcmk_shutdown = 1; ++ } ++ if (pcmk_shutdown && !(node->details->running_rsc)) { ++ pcmk_clean_shutdown = 1; ++ } + notify_parent(); + return; + } +@@ -339,7 +359,7 @@ crm_diff_update(const char *event, xmlNode * msg) + static mainloop_timer_t *refresh_timer = NULL; + + if(refresh_timer == NULL) { +- refresh_timer = mainloop_timer_add("refresh", 2000, FALSE, mon_trigger_refresh, NULL); ++ refresh_timer = mainloop_timer_add("refresh", reconnect_msec, FALSE, mon_trigger_refresh, NULL); + refresh_trigger = mainloop_add_trigger(G_PRIORITY_LOW, mon_refresh_state, refresh_timer); + } + +@@ -369,9 +389,9 @@ crm_diff_update(const char *event, xmlNode * msg) + } + + /* Refresh +- * - immediately if the last update was more than 5s ago ++ * - immediately if the last update was more than 1s ago + * - every 10 updates +- * - at most 2s after the last update ++ * - at most 1s after the last update + */ + if (updates > 10 || (now - last_refresh) > (reconnect_msec / 1000)) { + mon_refresh_state(refresh_timer); +diff --git a/src/sbd.h b/src/sbd.h +index 6fe07f9..3b05a11 100644 +--- a/src/sbd.h ++++ b/src/sbd.h +@@ -54,10 +54,13 @@ + /* FIXME: should add dynamic check of SIG_XX >= SIGRTMAX */ + + /* exit status for disk-servant */ +-#define EXIT_MD_IO_FAIL 20 +-#define EXIT_MD_REQUEST_RESET 21 +-#define EXIT_MD_REQUEST_SHUTOFF 22 +-#define EXIT_MD_REQUEST_CRASHDUMP 23 ++#define EXIT_MD_SERVANT_IO_FAIL 20 ++#define EXIT_MD_SERVANT_REQUEST_RESET 21 ++#define EXIT_MD_SERVANT_REQUEST_SHUTOFF 22 ++#define EXIT_MD_SERVANT_REQUEST_CRASHDUMP 23 ++ ++/* exit status for pcmk-servant */ ++#define EXIT_PCMK_SERVANT_GRACEFUL_SHUTDOWN 30 + + #define HOG_CHAR 0xff + #define SECTOR_NAME_MAX 63 +-- +1.8.3.1 + diff --git a/SOURCES/0003-Fix-sbd-pacemaker-bail-out-of-status-earlier.patch b/SOURCES/0003-Fix-sbd-pacemaker-bail-out-of-status-earlier.patch new file mode 100644 index 0000000..776edea --- /dev/null +++ b/SOURCES/0003-Fix-sbd-pacemaker-bail-out-of-status-earlier.patch @@ -0,0 +1,45 @@ +From 79b778debfee5b4ab2d099b2bfc7385f45597f70 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Tue, 26 Mar 2019 11:17:45 +0100 +Subject: [PATCH] Fix: sbd-pacemaker: bail out of status earlier + +Prevents possible subsequent null-pointer access and avoids +unnecessary search for node. +--- + src/sbd-pacemaker.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/sbd-pacemaker.c b/src/sbd-pacemaker.c +index c69fc55..9a8b95f 100644 +--- a/src/sbd-pacemaker.c ++++ b/src/sbd-pacemaker.c +@@ -276,7 +276,7 @@ compute_status(pe_working_set_t * data_set) + static int updates = 0; + static int ever_had_quorum = FALSE; + +- node_t *node = pe_find_node(data_set->nodes, local_uname); ++ node_t *node = NULL; + + updates++; + +@@ -286,11 +286,15 @@ compute_status(pe_working_set_t * data_set) + return; + } + ++ node = pe_find_node(data_set->nodes, local_uname); + +- if (node == NULL) { ++ if ((node == NULL) || (node->details == NULL)) { + set_servant_health(pcmk_health_unknown, LOG_WARNING, "Node state: %s is UNKNOWN", local_uname); ++ notify_parent(); ++ return; ++ } + +- } else if (node->details->online == FALSE) { ++ if (node->details->online == FALSE) { + set_servant_health(pcmk_health_unknown, LOG_WARNING, "Node state: OFFLINE"); + + } else if (node->details->unclean) { +-- +1.8.3.1 + diff --git a/SOURCES/0004-Doc-sbd.8.pod-use-the-generic-term-cluster-services-.patch b/SOURCES/0004-Doc-sbd.8.pod-use-the-generic-term-cluster-services-.patch new file mode 100644 index 0000000..ce9d698 --- /dev/null +++ b/SOURCES/0004-Doc-sbd.8.pod-use-the-generic-term-cluster-services-.patch @@ -0,0 +1,26 @@ +From 6d4289655dacad4b72fb64373c37bd1ad33649e6 Mon Sep 17 00:00:00 2001 +From: "Gao,Yan" +Date: Tue, 22 Jan 2019 16:33:04 +0100 +Subject: [PATCH] Doc: sbd.8.pod: use the generic term "cluster services" + instead of the specific "openais" + +--- + man/sbd.8.pod | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/man/sbd.8.pod b/man/sbd.8.pod +index ffd01c2..fed6bd3 100644 +--- a/man/sbd.8.pod ++++ b/man/sbd.8.pod +@@ -476,7 +476,7 @@ storage (with internal redundancy) anyway; the SBD device does not + introduce an additional single point of failure then. + + If the SBD device is not accessible, the daemon will fail to start and +-inhibit openais startup. ++inhibit startup of cluster services. + + =item Two devices + +-- +1.8.3.1 + diff --git a/SOURCES/0005-Doc-sbd.sysconfig-watchdog-timeout-set-in-the-on-dis.patch b/SOURCES/0005-Doc-sbd.sysconfig-watchdog-timeout-set-in-the-on-dis.patch new file mode 100644 index 0000000..8c096e0 --- /dev/null +++ b/SOURCES/0005-Doc-sbd.sysconfig-watchdog-timeout-set-in-the-on-dis.patch @@ -0,0 +1,27 @@ +From 091e10ae3f62239251b53bf7d81d47a57a9b82f2 Mon Sep 17 00:00:00 2001 +From: "Gao,Yan" +Date: Wed, 23 Jan 2019 17:21:15 +0100 +Subject: [PATCH] Doc: sbd.sysconfig: watchdog timeout set in the on-disk + metadata takes precedence + +--- + src/sbd.sysconfig | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/sbd.sysconfig b/src/sbd.sysconfig +index e661f96..f163f21 100644 +--- a/src/sbd.sysconfig ++++ b/src/sbd.sysconfig +@@ -68,6 +68,9 @@ SBD_WATCHDOG_DEV=/dev/watchdog + # If your sbd device(s) reside on a multipath setup or iSCSI, this + # should be the time required to detect a path failure. + # ++# Be aware that watchdog timeout set in the on-disk metadata takes ++# precedence. ++# + SBD_WATCHDOG_TIMEOUT=5 + + ## Type: string +-- +1.8.3.1 + diff --git a/SOURCES/0006-Refactor-fail-earlier-on-invalid-servants.patch b/SOURCES/0006-Refactor-fail-earlier-on-invalid-servants.patch new file mode 100644 index 0000000..cb71002 --- /dev/null +++ b/SOURCES/0006-Refactor-fail-earlier-on-invalid-servants.patch @@ -0,0 +1,142 @@ +From 8301cbafed191f30656a22876941cc7c9189b623 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Thu, 31 Jan 2019 14:42:01 +0100 +Subject: [PATCH] Refactor: fail earlier on invalid servants + +--- + src/sbd-inquisitor.c | 51 ++++++++++++++++++++++++++++++++------------------- + src/sbd-md.c | 7 +------ + src/sbd.h | 2 +- + 3 files changed, 34 insertions(+), 26 deletions(-) + +diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c +index 8e0bc87..9be6c99 100644 +--- a/src/sbd-inquisitor.c ++++ b/src/sbd-inquisitor.c +@@ -42,19 +42,36 @@ void recruit_servant(const char *devname, pid_t pid) + struct servants_list_item *newbie; + + if (lookup_servant_by_dev(devname)) { +- cl_log(LOG_DEBUG, "Servant %s already exists", devname); +- return; ++ cl_log(LOG_DEBUG, "Servant %s already exists", devname); ++ return; + } + + newbie = malloc(sizeof(*newbie)); +- if (!newbie) { +- fprintf(stderr, "malloc failed in recruit_servant.\n"); +- exit(1); ++ if (newbie) { ++ memset(newbie, 0, sizeof(*newbie)); ++ newbie->devname = strdup(devname); ++ newbie->pid = pid; ++ newbie->first_start = 1; ++ } ++ if (!newbie || !newbie->devname) { ++ fprintf(stderr, "heap allocation failed in recruit_servant.\n"); ++ exit(1); ++ } ++ ++ /* some sanity-check on our newbie */ ++ if (sbd_is_disk(newbie)) { ++ cl_log(LOG_INFO, "Monitoring %s", devname); ++ disk_count++; ++ } else if (sbd_is_pcmk(newbie) || sbd_is_cluster(newbie)) { ++ /* alive just after pcmk and cluster servants have shown up */ ++ newbie->outdated = 1; ++ } else { ++ /* toss our newbie */ ++ cl_log(LOG_ERR, "Refusing to recruit unrecognized servant %s", devname); ++ free((void *) newbie->devname); ++ free(newbie); ++ return; + } +- memset(newbie, 0, sizeof(*newbie)); +- newbie->devname = strdup(devname); +- newbie->pid = pid; +- newbie->first_start = 1; + + if (!s) { + servants_leader = newbie; +@@ -65,12 +82,6 @@ void recruit_servant(const char *devname, pid_t pid) + } + + servant_count++; +- if(sbd_is_disk(newbie)) { +- cl_log(LOG_INFO, "Monitoring %s", devname); +- disk_count++; +- } else { +- newbie->outdated = 1; +- } + } + + int assign_servant(const char* devname, functionp_t functionp, int mode, const void* argp) +@@ -148,7 +159,7 @@ void servant_start(struct servants_list_item *s) + if (sbd_is_disk(s)) { + #if SUPPORT_SHARED_DISK + DBGLOG(LOG_INFO, "Starting servant for device %s", s->devname); +- s->pid = assign_servant(s->devname, servant, start_mode, s); ++ s->pid = assign_servant(s->devname, servant_md, start_mode, s); + #else + cl_log(LOG_ERR, "Shared disk functionality not supported"); + return; +@@ -785,12 +796,14 @@ parse_device_line(const char *line) + + if (lpc > last) { + entry = calloc(1, 1 + lpc - last); ++ if (!entry) { ++ fprintf(stderr, "heap allocation failed parsing device-line.\n"); ++ exit(1); ++ } + rc = sscanf(line + last, "%[^;]", entry); + } + +- if (entry == NULL) { +- /* Skip */ +- } else if (rc != 1) { ++ if (rc != 1) { + cl_log(LOG_WARNING, "Could not parse (%d %d): %s", last, lpc, line + last); + } else { + cl_log(LOG_DEBUG, "Adding '%s'", entry); +diff --git a/src/sbd-md.c b/src/sbd-md.c +index 579d273..ba2c34d 100644 +--- a/src/sbd-md.c ++++ b/src/sbd-md.c +@@ -1031,7 +1031,7 @@ static int servant_check_timeout_inconsistent(struct sector_header_s *hdr) + return 0; + } + +-int servant(const char *diskname, int mode, const void* argp) ++int servant_md(const char *diskname, int mode, const void* argp) + { + struct sector_mbox_s *s_mbox = NULL; + struct sector_node_s *s_node = NULL; +@@ -1046,11 +1046,6 @@ int servant(const char *diskname, int mode, const void* argp) + char uuid[37]; + const struct servants_list_item *s = argp; + +- if (!diskname) { +- cl_log(LOG_ERR, "Empty disk name %s.", diskname); +- return -1; +- } +- + cl_log(LOG_INFO, "Servant starting for device %s", diskname); + + /* Block most of the signals */ +diff --git a/src/sbd.h b/src/sbd.h +index 386c85c..6fe07f9 100644 +--- a/src/sbd.h ++++ b/src/sbd.h +@@ -175,7 +175,7 @@ int ping_via_slots(const char *name, struct servants_list_item *servants); + int dump_headers(struct servants_list_item *servants); + unsigned long get_first_msgwait(struct servants_list_item *servants); + int messenger(const char *name, const char *msg, struct servants_list_item *servants); +-int servant(const char *diskname, int mode, const void* argp); ++int servant_md(const char *diskname, int mode, const void* argp); + #endif + + int servant_pcmk(const char *diskname, int mode, const void* argp); +-- +1.8.3.1 + diff --git a/SOURCES/0007-Fix-sbd-inquisitor-overhaul-device-list-parser.patch b/SOURCES/0007-Fix-sbd-inquisitor-overhaul-device-list-parser.patch new file mode 100644 index 0000000..c0ccf3d --- /dev/null +++ b/SOURCES/0007-Fix-sbd-inquisitor-overhaul-device-list-parser.patch @@ -0,0 +1,112 @@ +From d3be2caffb9edbb6bfe0e2658c66a1826f4e9c3a Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Mon, 15 Apr 2019 17:41:51 +0200 +Subject: [PATCH] Fix: sbd-inquisitor: overhaul device-list-parser + +for readability and robustness +--- + src/sbd-inquisitor.c | 60 ++++++++++++++++++++++++++-------------------------- + 1 file changed, 30 insertions(+), 30 deletions(-) + +diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c +index 715e978..b4b5585 100644 +--- a/src/sbd-inquisitor.c ++++ b/src/sbd-inquisitor.c +@@ -780,56 +780,56 @@ int inquisitor(void) + int + parse_device_line(const char *line) + { +- int lpc = 0; +- int last = 0; +- int max = 0; ++ size_t lpc = 0; ++ size_t last = 0; ++ size_t max = 0; + int found = 0; ++ bool skip_space = true; ++ int space_run = 0; + +- if(line) { +- max = strlen(line); ++ if (!line) { ++ return 0; + } + +- if (max <= 0) { +- return found; +- } ++ max = strlen(line); + +- cl_log(LOG_DEBUG, "Processing %d bytes: [%s]", max, line); +- /* Skip initial whitespace */ +- for (lpc = 0; lpc <= max && isspace(line[lpc]); lpc++) { +- last = lpc + 1; +- } ++ cl_log(LOG_DEBUG, "Processing %d bytes: [%s]", (int) max, line); + +- /* Now the actual content */ + for (lpc = 0; lpc <= max; lpc++) { +- int a_space = isspace(line[lpc]); +- +- if (a_space && lpc < max && isspace(line[lpc + 1])) { +- /* fast-forward to the end of the spaces */ +- +- } else if (a_space || line[lpc] == ';' || line[lpc] == 0) { +- int rc = 1; +- char *entry = NULL; ++ if (isspace(line[lpc])) { ++ if (skip_space) { ++ last = lpc + 1; ++ } else { ++ space_run++; ++ } ++ continue; ++ } ++ skip_space = false; ++ if (line[lpc] == ';' || line[lpc] == 0) { ++ int rc = 0; ++ char *entry = calloc(1, 1 + lpc - last); + +- if (lpc > last) { +- entry = calloc(1, 1 + lpc - last); +- if (!entry) { +- fprintf(stderr, "heap allocation failed parsing device-line.\n"); +- exit(1); +- } ++ if (entry) { + rc = sscanf(line + last, "%[^;]", entry); ++ } else { ++ fprintf(stderr, "Heap allocation failed parsing device-line.\n"); ++ exit(1); + } + + if (rc != 1) { +- cl_log(LOG_WARNING, "Could not parse (%d %d): %s", last, lpc, line + last); ++ cl_log(LOG_WARNING, "Could not parse: '%s'", line + last); + } else { ++ entry[strlen(entry)-space_run] = '\0'; + cl_log(LOG_DEBUG, "Adding '%s'", entry); + recruit_servant(entry, 0); + found++; + } + + free(entry); ++ skip_space = true; + last = lpc + 1; + } ++ space_run = 0; + } + return found; + } +@@ -890,7 +890,7 @@ int main(int argc, char **argv, char **envp) + int devices = parse_device_line(value); + if(devices < 1) { + fprintf(stderr, "Invalid device line: %s\n", value); +- exit_status = -2; ++ exit_status = -2; + goto out; + } + #else +-- +1.8.3.1 + diff --git a/SOURCES/0008-Refactor-sbd-common-no-reason-for-stack-hogger-havin.patch b/SOURCES/0008-Refactor-sbd-common-no-reason-for-stack-hogger-havin.patch new file mode 100644 index 0000000..f0a6d44 --- /dev/null +++ b/SOURCES/0008-Refactor-sbd-common-no-reason-for-stack-hogger-havin.patch @@ -0,0 +1,47 @@ +From 8e94781169fc2f36eb49078de1978ceb53df6b6c Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Mon, 15 Apr 2019 17:40:26 +0200 +Subject: [PATCH] Refactor: sbd-common: no reason for stack-hogger having + retval + +--- + src/sbd-common.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/sbd-common.c b/src/sbd-common.c +index 3966f25..873a76e 100644 +--- a/src/sbd-common.c ++++ b/src/sbd-common.c +@@ -568,13 +568,13 @@ enum { + #define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK) + #define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data) + +-static unsigned char ++static void + sbd_stack_hogger(unsigned char * inbuf, int kbytes) + { + unsigned char buf[1024]; + + if(kbytes <= 0) { +- return HOG_CHAR; ++ return; + } + + if (inbuf == NULL) { +@@ -584,10 +584,10 @@ sbd_stack_hogger(unsigned char * inbuf, int kbytes) + } + + if (kbytes > 0) { +- return sbd_stack_hogger(buf, kbytes-1); +- } else { +- return buf[sizeof(buf)-1]; ++ sbd_stack_hogger(buf, kbytes-1); + } ++ ++ return; + } + + static void +-- +1.8.3.1 + diff --git a/SOURCES/0009-Sanity-sbd-inquisitor-free-timeout-action-on-bail-ou.patch b/SOURCES/0009-Sanity-sbd-inquisitor-free-timeout-action-on-bail-ou.patch new file mode 100644 index 0000000..9eae5d6 --- /dev/null +++ b/SOURCES/0009-Sanity-sbd-inquisitor-free-timeout-action-on-bail-ou.patch @@ -0,0 +1,36 @@ +From 5c80753afb4abc2b5b024f4a5f2fc78669bda70b Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Mon, 15 Apr 2019 17:39:12 +0200 +Subject: [PATCH] Sanity: sbd-inquisitor: free timeout action on bail out + +--- + src/sbd-inquisitor.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c +index 77c6e4f..715e978 100644 +--- a/src/sbd-inquisitor.c ++++ b/src/sbd-inquisitor.c +@@ -1088,7 +1088,8 @@ int main(int argc, char **argv, char **envp) + break; + case 'h': + usage(); +- return (0); ++ goto out; ++ break; + default: + exit_status = -2; + goto out; +@@ -1241,6 +1242,9 @@ int main(int argc, char **argv, char **envp) + } + + out: ++ if (timeout_action) { ++ free(timeout_action); ++ } + if (exit_status < 0) { + if (exit_status == -2) { + usage(); +-- +1.8.3.1 + diff --git a/SOURCES/0010-Sanity-sbd-md-prevent-unrealistic-overflow-on-sector.patch b/SOURCES/0010-Sanity-sbd-md-prevent-unrealistic-overflow-on-sector.patch new file mode 100644 index 0000000..cc8c4ee --- /dev/null +++ b/SOURCES/0010-Sanity-sbd-md-prevent-unrealistic-overflow-on-sector.patch @@ -0,0 +1,29 @@ +From f6af36a0fb05b5a37b3dfb153677e28ca5cb3fd8 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Mon, 15 Apr 2019 17:37:42 +0200 +Subject: [PATCH] Sanity: sbd-md: prevent unrealistic overflow on sector io + calc + +--- + src/sbd-md.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/sbd-md.c b/src/sbd-md.c +index 60a1873..f437c41 100644 +--- a/src/sbd-md.c ++++ b/src/sbd-md.c +@@ -162,9 +162,9 @@ sector_io(struct sbd_context *st, int sector, void *data, int rw) + + memset(&st->io, 0, sizeof(struct iocb)); + if (rw) { +- io_prep_pwrite(&st->io, st->devfd, data, sector_size, sector_size * sector); ++ io_prep_pwrite(&st->io, st->devfd, data, sector_size, (long long) sector_size * sector); + } else { +- io_prep_pread(&st->io, st->devfd, data, sector_size, sector_size * sector); ++ io_prep_pread(&st->io, st->devfd, data, sector_size, (long long) sector_size * sector); + } + + if (io_submit(st->ioctx, 1, ios) != 1) { +-- +1.8.3.1 + diff --git a/SOURCES/0011-Sanity-sbd-md-remove-some-left-over-code.patch b/SOURCES/0011-Sanity-sbd-md-remove-some-left-over-code.patch new file mode 100644 index 0000000..64dd8cb --- /dev/null +++ b/SOURCES/0011-Sanity-sbd-md-remove-some-left-over-code.patch @@ -0,0 +1,35 @@ +From a80fe9392fd910074eccc4733ff2cd3e1625e48e Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Mon, 15 Apr 2019 17:36:12 +0200 +Subject: [PATCH] Sanity: sbd-md: remove some left over code + +--- + src/sbd-md.c | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/src/sbd-md.c b/src/sbd-md.c +index c51d381..60a1873 100644 +--- a/src/sbd-md.c ++++ b/src/sbd-md.c +@@ -373,7 +373,6 @@ init_device(struct sbd_context *st) + struct sector_header_s *s_header; + struct sector_node_s *s_node; + struct sector_mbox_s *s_mbox; +- struct stat s; + char uuid[37]; + int i; + int rc = 0; +@@ -394,10 +393,6 @@ init_device(struct sbd_context *st) + uuid_generate(s_header->uuid); + uuid_unparse_lower(s_header->uuid, uuid); + +- fstat(st->devfd, &s); +- /* printf("st_size = %ld, st_blksize = %ld, st_blocks = %ld\n", +- s.st_size, s.st_blksize, s.st_blocks); */ +- + cl_log(LOG_INFO, "Creating version %d.%d header on device %d (uuid: %s)", + s_header->version, s_header->minor_version, + st->devfd, uuid); +-- +1.8.3.1 + diff --git a/SOURCES/0012-Fix-sbd-common-query-rt-budget-0-otherwise-try-movin.patch b/SOURCES/0012-Fix-sbd-common-query-rt-budget-0-otherwise-try-movin.patch new file mode 100644 index 0000000..41cf428 --- /dev/null +++ b/SOURCES/0012-Fix-sbd-common-query-rt-budget-0-otherwise-try-movin.patch @@ -0,0 +1,215 @@ +From eaeed6cca46a0223617ead834aaa576dd5ad07ff Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Fri, 31 May 2019 16:11:16 +0200 +Subject: [PATCH] Fix: sbd-common: query rt-budget > 0 otherwise try moving to + root-slice + +--- + src/sbd-common.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ + src/sbd-inquisitor.c | 15 +++++++ + src/sbd.h | 2 + + src/sbd.sysconfig | 14 +++++++ + 4 files changed, 141 insertions(+) + +diff --git a/src/sbd-common.c b/src/sbd-common.c +index 873a76e..ebfdaa3 100644 +--- a/src/sbd-common.c ++++ b/src/sbd-common.c +@@ -662,6 +662,112 @@ static void sbd_memlock(int stackgrowK, int heapgrowK) + #endif + } + ++static int get_realtime_budget(void) ++{ ++ FILE *f; ++ char fname[PATH_MAX]; ++ int res = -1, lnum = 0; ++ char *cgroup = NULL, *namespecs = NULL; ++ ++ snprintf(fname, PATH_MAX, "/proc/%jd/cgroup", (intmax_t)getpid()); ++ f = fopen(fname, "rt"); ++ if (f == NULL) { ++ cl_log(LOG_WARNING, "Can't open cgroup file for pid=%jd", ++ (intmax_t)getpid()); ++ goto exit_res; ++ } ++ while( fscanf(f, "%d:%m[^:]:%m[^\n]", &lnum, &namespecs, &cgroup) !=EOF ) { ++ if (namespecs && strstr(namespecs, "cpuacct")) { ++ free(namespecs); ++ break; ++ } ++ if (cgroup) { ++ free(cgroup); ++ cgroup = NULL; ++ } ++ if (namespecs) { ++ free(namespecs); ++ namespecs = NULL; ++ } ++ } ++ fclose(f); ++ if (cgroup == NULL) { ++ cl_log(LOG_WARNING, "Failed getting cgroup for pid=%jd", ++ (intmax_t)getpid()); ++ goto exit_res; ++ } ++ snprintf(fname, PATH_MAX, "/sys/fs/cgroup/cpu%s/cpu.rt_runtime_us", ++ cgroup); ++ f = fopen(fname, "rt"); ++ if (f == NULL) { ++ cl_log(LOG_WARNING, "cpu.rt_runtime_us existed for root-slice but " ++ "doesn't for '%s'", cgroup); ++ goto exit_res; ++ } ++ if (fscanf(f, "%d", &res) != 1) { ++ cl_log(LOG_WARNING, "failed reading rt-budget from %s", fname); ++ } else { ++ cl_log(LOG_INFO, "slice='%s' has rt-budget=%d", cgroup, res); ++ } ++ fclose(f); ++ ++exit_res: ++ if (cgroup) { ++ free(cgroup); ++ } ++ return res; ++} ++ ++/* stolen from corosync */ ++static int sbd_move_to_root_cgroup(bool enforce_root_cgroup) { ++ FILE *f; ++ int res = -1; ++ ++ /* ++ * /sys/fs/cgroup is hardcoded, because most of Linux distributions are now ++ * using systemd and systemd uses hardcoded path of cgroup mount point. ++ * ++ * This feature is expected to be removed as soon as systemd gets support ++ * for managing RT configuration. ++ */ ++ f = fopen("/sys/fs/cgroup/cpu/cpu.rt_runtime_us", "rt"); ++ if (f == NULL) { ++ cl_log(LOG_DEBUG, "cpu.rt_runtime_us doesn't exist -> " ++ "system without cgroup or with disabled CONFIG_RT_GROUP_SCHED"); ++ res = 0; ++ goto exit_res; ++ } ++ fclose(f); ++ ++ if ((!enforce_root_cgroup) && (get_realtime_budget() > 0)) { ++ cl_log(LOG_DEBUG, "looks as if we have rt-budget in the slice we are " ++ "-> skip moving to root-slice"); ++ res = 0; ++ goto exit_res; ++ } ++ ++ f = fopen("/sys/fs/cgroup/cpu/tasks", "w"); ++ if (f == NULL) { ++ cl_log(LOG_WARNING, "Can't open cgroups tasks file for writing"); ++ ++ goto exit_res; ++ } ++ ++ if (fprintf(f, "%jd\n", (intmax_t)getpid()) <= 0) { ++ cl_log(LOG_WARNING, "Can't write sbd pid into cgroups tasks file"); ++ goto close_and_exit_res; ++ } ++ ++close_and_exit_res: ++ if (fclose(f) != 0) { ++ cl_log(LOG_WARNING, "Can't close cgroups tasks file"); ++ goto exit_res; ++ } ++ ++exit_res: ++ return (res); ++} ++ + void + sbd_make_realtime(int priority, int stackgrowK, int heapgrowK) + { +@@ -670,6 +776,10 @@ sbd_make_realtime(int priority, int stackgrowK, int heapgrowK) + } + + #ifdef SCHED_RR ++ if (move_to_root_cgroup) { ++ sbd_move_to_root_cgroup(enforce_moving_to_root_cgroup); ++ } ++ + { + int pcurrent = 0; + int pmin = sched_get_priority_min(SCHED_RR); +diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c +index abde4e5..cef5cc7 100644 +--- a/src/sbd-inquisitor.c ++++ b/src/sbd-inquisitor.c +@@ -33,6 +33,8 @@ int start_mode = 0; + char* pidfile = NULL; + bool do_flush = true; + char timeout_sysrq_char = 'b'; ++bool move_to_root_cgroup = true; ++bool enforce_moving_to_root_cgroup = false; + + int parse_device_line(const char *line); + +@@ -965,6 +967,19 @@ int main(int argc, char **argv, char **envp) + timeout_action = strdup(value); + } + ++ value = getenv("SBD_MOVE_TO_ROOT_CGROUP"); ++ if(value) { ++ move_to_root_cgroup = crm_is_true(value); ++ ++ if (move_to_root_cgroup) { ++ enforce_moving_to_root_cgroup = true; ++ } else { ++ if (strcmp(value, "auto") == 0) { ++ move_to_root_cgroup = true; ++ } ++ } ++ } ++ + while ((c = getopt(argc, argv, "czC:DPRTWZhvw:d:n:p:1:2:3:4:5:t:I:F:S:s:r:")) != -1) { + switch (c) { + case 'D': +diff --git a/src/sbd.h b/src/sbd.h +index 3b05a11..ac30ec7 100644 +--- a/src/sbd.h ++++ b/src/sbd.h +@@ -159,6 +159,8 @@ extern bool watchdogdev_is_default; + extern char* local_uname; + extern bool do_flush; + extern char timeout_sysrq_char; ++extern bool move_to_root_cgroup; ++extern bool enforce_moving_to_root_cgroup; + + /* Global, non-tunable variables: */ + extern int sector_size; +diff --git a/src/sbd.sysconfig b/src/sbd.sysconfig +index f163f21..e1a60ed 100644 +--- a/src/sbd.sysconfig ++++ b/src/sbd.sysconfig +@@ -91,6 +91,20 @@ SBD_WATCHDOG_TIMEOUT=5 + # + SBD_TIMEOUT_ACTION=flush,reboot + ++## Type: yesno / auto ++## Default: auto ++# ++# If CPUAccounting is enabled default is not to assign any RT-budget ++# to the system.slice which prevents sbd from running RR-scheduled. ++# ++# One way to escape that issue is to move sbd-processes from the ++# slice they were originally started to root-slice. ++# Of course starting sbd in a certain slice might be intentional. ++# Thus in auto-mode sbd will check if the slice has RT-budget assigned. ++# If that is the case sbd will stay in that slice while it will ++# be moved to root-slice otherwise. ++SBD_MOVE_TO_ROOT_CGROUP=auto ++ + ## Type: string + ## Default: "" + # +-- +1.8.3.1 + diff --git a/SOURCES/0013-Fix-sbd-pacemaker-assume-graceful-exit-if-leftovers-.patch b/SOURCES/0013-Fix-sbd-pacemaker-assume-graceful-exit-if-leftovers-.patch new file mode 100644 index 0000000..8c92df8 --- /dev/null +++ b/SOURCES/0013-Fix-sbd-pacemaker-assume-graceful-exit-if-leftovers-.patch @@ -0,0 +1,60 @@ +From 824fe834c67fb7bae7feb87607381f9fa8fa2945 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Fri, 7 Jun 2019 19:09:06 +0200 +Subject: [PATCH] Fix: sbd-pacemaker: assume graceful exit if leftovers are + unmanged + +--- + src/sbd-pacemaker.c | 32 +++++++++++++++++++++++++++++++- + 1 file changed, 31 insertions(+), 1 deletion(-) + +diff --git a/src/sbd-pacemaker.c b/src/sbd-pacemaker.c +index 9a8b95f..2b35ff6 100644 +--- a/src/sbd-pacemaker.c ++++ b/src/sbd-pacemaker.c +@@ -333,11 +333,41 @@ compute_status(pe_working_set_t * data_set) + } + } + ++ /* If we are in shutdown-state once this will go on till the end. ++ * If we've on top reached a state of 0 locally running resources ++ * we can assume a clean shutdown. ++ * Tricky are the situations where the node is in maintenance-mode ++ * or resources are unmanaged. So if the node is in maintenance or ++ * all left-over running resources are unmanaged we assume intention. ++ */ + if (node->details->shutdown) { + pcmk_shutdown = 1; + } +- if (pcmk_shutdown && !(node->details->running_rsc)) { ++ if (pcmk_shutdown) ++ { + pcmk_clean_shutdown = 1; ++ if (!(node->details->maintenance)) { ++ GListPtr iter; ++ ++ for (iter = node->details->running_rsc; ++ iter != NULL; iter = iter->next) { ++ resource_t *rsc = (resource_t *) iter->data; ++ ++ ++ if (is_set(rsc->flags, pe_rsc_managed)) { ++ pcmk_clean_shutdown = 0; ++ crm_debug("not clean as %s managed and still running", ++ rsc->id); ++ break; ++ } ++ } ++ if (pcmk_clean_shutdown) { ++ crm_debug("pcmk_clean_shutdown because " ++ "all managed resources down"); ++ } ++ } else { ++ crm_debug("pcmk_clean_shutdown because node is in maintenance"); ++ } + } + notify_parent(); + return; +-- +1.8.3.1 + diff --git a/SOURCES/0014-Fix-sbd-cluster-periodically-check-corosync-daemon-l.patch b/SOURCES/0014-Fix-sbd-cluster-periodically-check-corosync-daemon-l.patch new file mode 100644 index 0000000..9f4de96 --- /dev/null +++ b/SOURCES/0014-Fix-sbd-cluster-periodically-check-corosync-daemon-l.patch @@ -0,0 +1,123 @@ +From 1387ed890e3a9e246e9b9f780b2a7cb5379459ab Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Wed, 5 Jun 2019 11:32:49 +0200 +Subject: [PATCH] Fix: sbd-cluster: periodically check corosync-daemon liveness + +using votequorum_getinfo. +--- + configure.ac | 12 +++++++++++- + src/sbd-cluster.c | 36 ++++++++++++++++++++++++++++++++++-- + 2 files changed, 45 insertions(+), 3 deletions(-) + +diff --git a/configure.ac b/configure.ac +index fac26a8..c44e747 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -33,6 +33,7 @@ PKG_CHECK_MODULES(glib, [glib-2.0]) + dnl PKG_CHECK_MODULES(libcoroipcc, [libcoroipcc]) + + PKG_CHECK_MODULES(cmap, [libcmap], HAVE_cmap=1, HAVE_cmap=0) ++PKG_CHECK_MODULES(votequorum, [libvotequorum], HAVE_votequorum=1, HAVE_votequorum=0) + + dnl pacemaker > 1.1.8 + PKG_CHECK_MODULES(pacemaker, [pacemaker, pacemaker-cib], HAVE_pacemaker=1, HAVE_pacemaker=0) +@@ -49,7 +50,12 @@ elif test $HAVE_pacemaker = 1; then + if test $HAVE_cmap = 0; then + AC_MSG_NOTICE(No package 'cmap' found) + else +- CPPFLAGS="$CPPFLAGS $cmap_CFLAGS" ++ CPPFLAGS="$CPPFLAGS $cmap_CFLAGS" ++ fi ++ if test $HAVE_votequorum = 0; then ++ AC_MSG_NOTICE(No library 'votequorum' found) ++ else ++ CPPFLAGS="$CPPFLAGS $votequorum_CFLAGS" + fi + fi + +@@ -66,6 +72,7 @@ AC_CHECK_LIB(pe_rules, test_rule, , missing="yes") + AC_CHECK_LIB(crmcluster, crm_peer_init, , missing="yes") + AC_CHECK_LIB(uuid, uuid_unparse, , missing="yes") + AC_CHECK_LIB(cmap, cmap_initialize, , HAVE_cmap=0) ++AC_CHECK_LIB(votequorum, votequorum_getinfo, , HAVE_votequorum=0) + + dnl pacemaker >= 1.1.8 + AC_CHECK_HEADERS(pacemaker/crm/cluster.h) +@@ -107,6 +114,9 @@ fi + AC_DEFINE_UNQUOTED(CHECK_TWO_NODE, $HAVE_cmap, Turn on checking for 2-node cluster) + AM_CONDITIONAL(CHECK_TWO_NODE, test "$HAVE_cmap" = "1") + ++AC_DEFINE_UNQUOTED(CHECK_VOTEQUORUM_HANDLE, $HAVE_votequorum, Turn on periodic checking of votequorum-handle) ++AM_CONDITIONAL(CHECK_VOTEQUORUM_HANDLE, test "$HAVE_votequorum" = "1") ++ + CONFIGDIR="" + AC_ARG_WITH(configdir, + [ --with-configdir=DIR +diff --git a/src/sbd-cluster.c b/src/sbd-cluster.c +index 541212f..9fb6224 100644 +--- a/src/sbd-cluster.c ++++ b/src/sbd-cluster.c +@@ -80,6 +80,12 @@ sbd_plugin_membership_dispatch(cpg_handle_t handle, + + #if SUPPORT_COROSYNC + ++#if CHECK_VOTEQUORUM_HANDLE ++#include ++ ++static votequorum_handle_t votequorum_handle = 0; ++#endif ++ + static bool two_node = false; + static bool ever_seen_both = false; + static int cpg_membership_entries = -1; +@@ -261,12 +267,32 @@ notify_timer_cb(gpointer data) + + #endif + case pcmk_cluster_corosync: ++ do { ++#if SUPPORT_COROSYNC && CHECK_VOTEQUORUM_HANDLE ++ struct votequorum_info info; ++ ++ if (votequorum_getinfo(votequorum_handle, 0, &info) != CS_OK) { ++ ++ votequorum_finalize(votequorum_handle); ++ if (votequorum_initialize(&votequorum_handle, NULL) != CS_OK) { ++ votequorum_handle = 0; ++ break; ++ } ++ if (votequorum_getinfo(votequorum_handle, 0, &info) != CS_OK) { ++ break; ++ } ++ } ++#endif ++ notify_parent(); ++ } while (0); ++ break; ++ + #if HAVE_DECL_PCMK_CLUSTER_CMAN + case pcmk_cluster_cman: +-#endif +- /* TODO - Make a CPG call and only call notify_parent() when we get a reply */ ++ + notify_parent(); + break; ++#endif + + default: + break; +@@ -533,6 +559,12 @@ find_pacemaker_remote(void) + static void + clean_up(int rc) + { ++#if CHECK_VOTEQUORUM_HANDLE ++ votequorum_finalize(votequorum_handle); ++ votequorum_handle = 0; /* there isn't really an invalid handle value ++ * just to be back where we started ++ */ ++#endif + return; + } + +-- +1.8.3.1 + diff --git a/SOURCES/0015-build-say-library-when-missing-cmap-not-package-to-a.patch b/SOURCES/0015-build-say-library-when-missing-cmap-not-package-to-a.patch new file mode 100644 index 0000000..231c77c --- /dev/null +++ b/SOURCES/0015-build-say-library-when-missing-cmap-not-package-to-a.patch @@ -0,0 +1,26 @@ +From 0de14256fc873aee735117955662503b773bf71c Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Tue, 11 Jun 2019 08:05:33 +0200 +Subject: [PATCH] build: say library when missing cmap not package to avoid + confusion + +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index c44e747..1c55094 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -48,7 +48,7 @@ if test $HAVE_pacemaker = 0 -a $HAVE_pcmk = 0; then + elif test $HAVE_pacemaker = 1; then + CPPFLAGS="$CPPFLAGS $glib_CFLAGS $pacemaker_CFLAGS" + if test $HAVE_cmap = 0; then +- AC_MSG_NOTICE(No package 'cmap' found) ++ AC_MSG_NOTICE(No library 'cmap' found) + else + CPPFLAGS="$CPPFLAGS $cmap_CFLAGS" + fi +-- +1.8.3.1 + diff --git a/SOURCES/0016-Fix-sbd-pacemaker-check-for-shutdown-attribute-on-ev.patch b/SOURCES/0016-Fix-sbd-pacemaker-check-for-shutdown-attribute-on-ev.patch new file mode 100644 index 0000000..16a50e0 --- /dev/null +++ b/SOURCES/0016-Fix-sbd-pacemaker-check-for-shutdown-attribute-on-ev.patch @@ -0,0 +1,54 @@ +From c8e3de2a7e98550ea9f27a0c59e13013ce02992d Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Fri, 16 Aug 2019 12:07:32 +0200 +Subject: [PATCH] Fix: sbd-pacemaker: check for shutdown attribute on every + cib-diff + +--- + src/sbd-pacemaker.c | 22 +++++++++++++++++++++- + 1 file changed, 21 insertions(+), 1 deletion(-) + +diff --git a/src/sbd-pacemaker.c b/src/sbd-pacemaker.c +index 2b35ff6..1217acf 100644 +--- a/src/sbd-pacemaker.c ++++ b/src/sbd-pacemaker.c +@@ -383,6 +383,24 @@ mon_trigger_refresh(gpointer user_data) + return FALSE; + } + ++#define XPATH_SHUTDOWN "//" XML_CIB_TAG_STATE "[@uname='%s']/" \ ++ XML_TAG_TRANSIENT_NODEATTRS "/" XML_TAG_ATTR_SETS "/" \ ++ XML_CIB_TAG_NVPAIR "[@name='" XML_CIB_ATTR_SHUTDOWN "']" ++ ++static gboolean ++shutdown_attr_in_cib(void) ++{ ++ xmlNode *match = NULL; ++ char *xpath_string; ++ ++ xpath_string = crm_strdup_printf(XPATH_SHUTDOWN, local_uname); ++ if (xpath_string) { ++ match = get_xpath_object(xpath_string, current_cib, LOG_TRACE); ++ free(xpath_string); ++ } ++ return (match != NULL); ++} ++ + static void + crm_diff_update(const char *event, xmlNode * msg) + { +@@ -426,8 +444,10 @@ crm_diff_update(const char *event, xmlNode * msg) + * - immediately if the last update was more than 1s ago + * - every 10 updates + * - at most 1s after the last update ++ * - shutdown attribute for our node set for the first time + */ +- if (updates > 10 || (now - last_refresh) > (reconnect_msec / 1000)) { ++ if ((!pcmk_shutdown && shutdown_attr_in_cib()) || ++ (updates > 10 || (now - last_refresh) > (reconnect_msec / 1000))) { + mon_refresh_state(refresh_timer); + updates = 0; + +-- +1.8.3.1 + diff --git a/SPECS/sbd.spec b/SPECS/sbd.spec new file mode 100644 index 0000000..668fea5 --- /dev/null +++ b/SPECS/sbd.spec @@ -0,0 +1,304 @@ +# +# spec file for package sbd +# +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2013 Lars Marowsky-Bree +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# +%global commit 7f33d1a409d0a4e2cd69946688c48eaa8f3c5d26 +%global shortcommit %(c=%{commit}; echo ${c:0:7}) +%global github_owner Clusterlabs +%global buildnum 15 + +Name: sbd +Summary: Storage-based death +License: GPLv2+ +Group: System Environment/Daemons +Version: 1.4.0 +Release: %{buildnum}%{?dist} +Url: https://github.com/%{github_owner}/%{name} +Source0: https://github.com/%{github_owner}/%{name}/archive/%{commit}/%{name}-%{commit}.tar.gz +Patch0: 0001-Fix-sbd-cluster-finalize-cmap-connection-if-disconne.patch +Patch1: 0002-Fix-sbd-pacemaker-make-handling-of-cib-connection-lo.patch +Patch2: 0003-Fix-sbd-pacemaker-bail-out-of-status-earlier.patch +Patch3: 0004-Doc-sbd.8.pod-use-the-generic-term-cluster-services-.patch +Patch4: 0005-Doc-sbd.sysconfig-watchdog-timeout-set-in-the-on-dis.patch +Patch5: 0006-Refactor-fail-earlier-on-invalid-servants.patch +Patch6: 0007-Fix-sbd-inquisitor-overhaul-device-list-parser.patch +Patch7: 0008-Refactor-sbd-common-no-reason-for-stack-hogger-havin.patch +Patch8: 0009-Sanity-sbd-inquisitor-free-timeout-action-on-bail-ou.patch +Patch9: 0010-Sanity-sbd-md-prevent-unrealistic-overflow-on-sector.patch +Patch10: 0011-Sanity-sbd-md-remove-some-left-over-code.patch +Patch11: 0012-Fix-sbd-common-query-rt-budget-0-otherwise-try-movin.patch +Patch12: 0013-Fix-sbd-pacemaker-assume-graceful-exit-if-leftovers-.patch +Patch13: 0014-Fix-sbd-cluster-periodically-check-corosync-daemon-l.patch +Patch14: 0015-build-say-library-when-missing-cmap-not-package-to-a.patch +Patch15: 0016-Fix-sbd-pacemaker-check-for-shutdown-attribute-on-ev.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libuuid-devel +BuildRequires: glib2-devel +BuildRequires: libaio-devel +BuildRequires: corosync-devel +BuildRequires: pacemaker-libs-devel > 1.1.12 +BuildRequires: libtool +BuildRequires: libuuid-devel +BuildRequires: libxml2-devel +BuildRequires: pkgconfig +BuildRequires: python-devel + +%if 0%{?rhel} > 0 +ExclusiveArch: i686 x86_64 s390x ppc64le aarch64 +%endif + +%if %{defined systemd_requires} +%systemd_requires +%endif + +%description + +This package contains the storage-based death functionality. + +########################################################### + +%prep +%autosetup -n %{name}-%{commit} -p1 + +########################################################### + +%build +autoreconf -i +export CFLAGS="$RPM_OPT_FLAGS -Wall -Werror" +%configure +make %{?_smp_mflags} + +########################################################### + +%install + +make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} install +rm -rf ${RPM_BUILD_ROOT}%{_libdir}/stonith + +%if %{defined _unitdir} +install -D -m 0644 src/sbd.service $RPM_BUILD_ROOT/%{_unitdir}/sbd.service +install -D -m 0644 src/sbd_remote.service $RPM_BUILD_ROOT/%{_unitdir}/sbd_remote.service +%endif + +mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig +install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd + +########################################################### + +%clean +rm -rf %{buildroot} + +%if %{defined _unitdir} +%post +%systemd_post sbd.service +%systemd_post sbd_remote.service +if [ $1 -ne 1 ] ; then + if systemctl --quiet is-enabled sbd.service 2>/dev/null + then + systemctl --quiet reenable sbd.service 2>/dev/null || : + fi + if systemctl --quiet is-enabled sbd_remote.service 2>/dev/null + then + systemctl --quiet reenable sbd_remote.service 2>/dev/null || : + fi +fi + +%preun +%systemd_preun sbd.service +%systemd_preun sbd_remote.service + +%postun +%systemd_postun sbd.service +%systemd_postun sbd_remote.service +%endif + +%files +########################################################### +%defattr(-,root,root) +%config(noreplace) %{_sysconfdir}/sysconfig/sbd +%{_sbindir}/sbd +#%{_datadir}/sbd +%doc %{_mandir}/man8/sbd* +%if %{defined _unitdir} +%{_unitdir}/sbd.service +%{_unitdir}/sbd_remote.service +%endif +%doc COPYING + +%changelog +* Fri Aug 16 2019 Klaus Wenninger - 1.4.0-15 +- check for shutdown attribute on every cib-diff + + Resolves: rhbz#1713023 + +* Tue Aug 13 2019 Klaus Wenninger - 1.4.0-14 +- rebuild with updated brew-root + + Resolves: rhbz#1718297 + Resolves: rhbz#1713023 + Resolves: rhbz#1732368 + +* Fri Aug 9 2019 Klaus Wenninger - 1.4.0-13 +- properly increment release + + Resolves: rhbz#1718297 + Resolves: rhbz#1713023 + Resolves: rhbz#1732368 + +* Fri Aug 9 2019 Klaus Wenninger - 1.4.0-12 +- rebuild with updated brew-root + + Resolves: rhbz#1718297 + Resolves: rhbz#1713023 + Resolves: rhbz#1732368 + +* Tue Jul 23 2019 Klaus Wenninger - 1.4.0-11 +- synchronize with rhel-8.1.0 + + Resolves: rhbz#1718297 + Resolves: rhbz#1713023 + Resolves: rhbz#1732368 + +* Tue Mar 26 2019 Klaus Wenninger - 1.4.0-4 +- fix possible null-pointer-access just introduced + + Resolves: rhbz#1691484 + +* Tue Mar 26 2019 Klaus Wenninger - 1.4.0-3 +- finalize cmap connection if disconnected from cluster +- make handling of cib-connection loss more robust + + Resolves: rhbz#1691484 + +* Thu Feb 7 2019 Klaus Wenninger - 1.4.0-2 +- rebuild against pacemaker 1.20 to make sbd actually use + the new libpengine API + + Resolves: rhbz#1661233 + +* Mon Jan 14 2019 Klaus Wenninger - 1.4.0-1 +- rebase to upstream v1.4.0 + + Resolves: rhbz#1660158 + +* Wed Sep 19 2018 Klaus Wenninger - 1.3.1-8.2 +- avoid statting potential symlink-targets in /dev + + Resolves: rhbz#1628988 + +* Fri Sep 14 2018 Klaus Wenninger - 1.3.1-8.1 +- skip symlinks pointing to dev-nodes outside of /dev + + Resolves: rhbz#1628988 + +* Mon Apr 16 2018 - 1.3.1-8 +- Added aarch64 target + + Resolves: rhbz#1568029 + +* Mon Jan 15 2018 - 1.3.1-7 +- reenable sbd on upgrade so that additional + links to make pacemaker properly depend on + sbd are created + + Resolves: rhbz#1525981 + +* Wed Jan 10 2018 - 1.3.1-5 +- add man sections for query- & test-watchdog + + Resolves: rhbz#1462002 + +* Wed Dec 20 2017 - 1.3.1-3 +- mention timeout caveat with SBD_DELAY_START + in configuration template +- make systemd wait for sbd-start to finish + before starting pacemaker or dlm + + Resolves: rhbz#1525981 + +* Fri Nov 3 2017 - 1.3.1-2 +- rebase to upstream v1.3.1 + + Resolves: rhbz#1499864 + rhbz#1468580 + rhbz#1462002 + +* Wed Jun 7 2017 - 1.3.0-3 +- prevent creation of duplicate servants +- check 2Node flag in corosync to support + 2-node-clusters with shared disk fencing +- move disk-triggered reboot/off/crashdump + to inquisitor to have sysrq observed by watchdog + + Resolves: rhbz#1413951 + +* Sun Mar 26 2017 - 1.3.0-1 +- rebase to upstream v1.3.0 +- remove watchdog-limitation from description + Resolves: rhbz#1413951 + +* Mon Feb 27 2017 - 1.2.1-23 +- if shared-storage enabled check for node-name <= 63 chars + Resolves: rhbz#1413951 + +* Tue Jan 31 2017 - 1.2.1-22 +- Rebuild with shared-storage enabled +- Package original manpage +- Added ppc64le target + Resolves: rhbz#1413951 + +* Fri Apr 15 2016 - 1.2.1-21 +- Rebuild for new pacemaker + Resolves: rhbz#1320400 + +* Fri Apr 15 2016 - 1.2.1-20 +- tarball updated to c511b0692784a7085df4b1ae35748fb318fa79ee + from https://github.com/Clusterlabs/sbd + Resolves: rhbz#1324240 + +* Thu Jul 23 2015 - 1.2.1-5 +- Rebuild for pacemaker + +* Tue Jun 02 2015 - 1.2.1-4 +- Include the dist tag in the release string +- Rebuild for new pacemaker + +* Mon Jan 12 2015 - 1.2.1-3 +- Correctly parse SBD_WATCHDOG_TIMEOUT into seconds (not milliseconds) + +* Mon Oct 27 2014 - 1.2.1-2 +- Correctly enable /proc/pid validation for sbd_lock_running() + +* Fri Oct 24 2014 - 1.2.1-1 +- Further improve integration with the el7 environment + +* Thu Oct 16 2014 - 1.2.1-0.5.872e82f3.git +- Disable unsupported functionality (for now) + +* Wed Oct 15 2014 - 1.2.1-0.4.872e82f3.git +- Improved integration with the el7 environment + +* Tue Sep 30 2014 - 1.2.1-0.3.8f912945.git +- Only build on archs supported by the HA Add-on + +* Fri Aug 29 2014 - 1.2.1-0.2.8f912945.git +- Remove some additional SUSE-isms + +* Fri Aug 29 2014 - 1.2.1-0.1.8f912945.git +- Prepare for package review + Resolves: rhbz#1134245