From 61b96258844c680e675f835baa9351116a911296 Mon Sep 17 00:00:00 2001 From: dogsheng <960055655@qq.com> Date: Wed, 25 Dec 2019 15:57:36 +0800 Subject: [PATCH] Package init --- 6038-lvmetad-fix-sync-cache-to-lvmetad.patch | 175 ++++++++++++++++++ ...elect-to-avoid-condition-checking-ra.patch | 148 +++++++++++++++ ...-threads-are-reaped-before-checking-.patch | 35 ++++ 6041-lvmetad-fix-timeout-on-shutdown.patch | 63 +++++++ ...eck-for-no-dev-when-dropping-aliases.patch | 31 ++++ 6043-cov-missing-checks-of-syscalls.patch | 84 +++++++++ 6044-cov-ensure-read_ahead-is-available.patch | 26 +++ ...lvmcache-free-resource-on-error-path.patch | 33 ++++ ...daemons-check-for-non-zero-thread_id.patch | 27 +++ ...n-remove-extra-label-scan-and-read-f.patch | 28 +++ 9000-bugfix-lvm2-add-SSD.patch | 2 - lvm2.spec | 22 ++- 12 files changed, 669 insertions(+), 5 deletions(-) create mode 100644 6038-lvmetad-fix-sync-cache-to-lvmetad.patch create mode 100644 6039-libdaemon-use-pselect-to-avoid-condition-checking-ra.patch create mode 100644 6040-libdaemon-ensure-threads-are-reaped-before-checking-.patch create mode 100644 6041-lvmetad-fix-timeout-on-shutdown.patch create mode 100644 6042-devs-check-for-no-dev-when-dropping-aliases.patch create mode 100644 6043-cov-missing-checks-of-syscalls.patch create mode 100644 6044-cov-ensure-read_ahead-is-available.patch create mode 100644 6045-lvmcache-free-resource-on-error-path.patch create mode 100644 6046-daemons-check-for-non-zero-thread_id.patch create mode 100644 6047-revert-label_scan-remove-extra-label-scan-and-read-f.patch diff --git a/6038-lvmetad-fix-sync-cache-to-lvmetad.patch b/6038-lvmetad-fix-sync-cache-to-lvmetad.patch new file mode 100644 index 0000000..4da6ea6 --- /dev/null +++ b/6038-lvmetad-fix-sync-cache-to-lvmetad.patch @@ -0,0 +1,175 @@ +From 5d6bf1efb225b964bfff398277e68345acdac1d0 Mon Sep 17 00:00:00 2001 +From: David Teigland +Date: Wed, 25 Sep 2019 14:23:14 -0500 +Subject: [PATCH 126/180] lvmetad: fix sync cache to lvmetad + +error could be reproduced follow those steps: + #!/bin/bash + vgcreate vgtest /dev/sdb + lvcreate -L 100M -n lv1 vgtest + while : + do + service lvm2-lvmetad restart + vgs & + pvscan & + lvcreate -L 100M -n lv2 vgtest & + lvchange /dev/vgtest/lv1 --addtag xxxxx & + wait + if ! lvs|grep lv2;then + echo "err create" + break + fi + sleep 1 + lvremove -y /dev/vgtest/lv2 + lvchange /dev/vgtest/lv1 --deltag xxxxx + done + +and then fail to create vgtest/lv2, actually lv2 was created, while +the metadata written on disk is replaced by lvchange. It could look +up lv2 by calling dmsetup table, while lvs could not. + +This is because, when lvmetad restarted, several lvm commands update +token concurrently, when lvcreate recieve "token_mismatch", it cancle +communicating with lvmetad, which leads to that lvmetad cache is not +sync with the metadata on disk, then lv2 is not committed to lvmetad +cache. The metadata of vgtest which lvchange query from lvmetad is +out of date. After lvchange, it use the old metadata cover the new one. + +This patch let lvm process update token synchronously, only one command +update lvmetad token at a time. + +lvmetad_pvscan_single send the metadata on a pv by sending "pv_found" +to lvmetad, while the metadata maybe out of date after waiting for the +chance to update lvmetad token. Call label_read to read metadata again. + +Token mismatch may lead to problems, increase log level. + +Signed-off-by: wangjufeng +--- + daemons/lvmetad/lvmetad-core.c | 19 +++++++++++++++---- + lib/cache/lvmetad.c | 31 +++++++++++++++++++++++++++++-- + 2 files changed, 44 insertions(+), 6 deletions(-) + +diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c +index 72473d7..c274880 100644 +--- a/daemons/lvmetad/lvmetad-core.c ++++ b/daemons/lvmetad/lvmetad-core.c +@@ -2669,6 +2669,7 @@ static response handler(daemon_state s, client_handle h, request r) + int pid; + int cache_lock = 0; + int info_lock = 0; ++ uint64_t timegap = 0; + + rq = daemon_request_str(r, "request", "NONE"); + token = daemon_request_str(r, "token", "NONE"); +@@ -2711,9 +2712,19 @@ static response handler(daemon_state s, client_handle h, request r) + state->update_cmd); + + } else if (prev_in_progress && this_in_progress) { ++ timegap = _monotonic_seconds() - state->update_begin; ++ if (timegap < state->update_timeout) { ++ pthread_mutex_unlock(&state->token_lock); ++ return daemon_reply_simple("token_updating", ++ "expected = %s", state->token, ++ "update_pid = " FMTd64, (int64_t)state->update_pid, ++ "reason = %s", "another command has populated the cache", ++ NULL); ++ } ++ + /* Current update is cancelled and replaced by a new update */ + +- DEBUGLOG(state, "token_update replacing pid %d begin %llu len %d cmd %s", ++ WARN(state, "token_update replacing pid %d begin %llu len %d cmd %s", + state->update_pid, + (unsigned long long)state->update_begin, + (int)(_monotonic_seconds() - state->update_begin), +@@ -2726,7 +2737,7 @@ static response handler(daemon_state s, client_handle h, request r) + state->update_pid = pid; + strncpy(state->update_cmd, cmd, CMD_NAME_SIZE - 1); + +- DEBUGLOG(state, "token_update begin %llu timeout %d pid %d cmd %s", ++ WARN(state, "token_update begin %llu timeout %d pid %d cmd %s", + (unsigned long long)state->update_begin, + state->update_timeout, + state->update_pid, +@@ -2737,7 +2748,7 @@ static response handler(daemon_state s, client_handle h, request r) + + if (state->update_pid != pid) { + /* If a pid doing update was cancelled, ignore its token update at the end. */ +- DEBUGLOG(state, "token_update ignored from cancelled update pid %d", pid); ++ WARN(state, "token_update ignored from cancelled update pid %d", pid); + pthread_mutex_unlock(&state->token_lock); + + return daemon_reply_simple("token_mismatch", +@@ -2748,7 +2759,7 @@ static response handler(daemon_state s, client_handle h, request r) + NULL); + } + +- DEBUGLOG(state, "token_update end len %d pid %d new token %s", ++ WARN(state, "token_update end len %d pid %d new token %s", + (int)(_monotonic_seconds() - state->update_begin), + state->update_pid, token); + +diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c +index 291a2b2..8dc12a6 100644 +--- a/lib/cache/lvmetad.c ++++ b/lib/cache/lvmetad.c +@@ -552,7 +552,12 @@ static int _token_update(int *replaced_update) + const char *reply_str; + int update_pid; + int ending_our_update; ++ unsigned int wait_sec = 0; ++ uint64_t now = 0, wait_start = 0; ++ wait_sec = (unsigned int)_lvmetad_update_timeout; ++ unsigned int delay_usec = 0; + ++retry: + log_debug_lvmetad("Sending lvmetad token_update %s", _lvmetad_token); + reply = _lvmetad_send(NULL, "token_update", NULL); + +@@ -568,6 +573,28 @@ static int _token_update(int *replaced_update) + update_pid = (int)daemon_reply_int(reply, "update_pid", 0); + reply_str = daemon_reply_str(reply, "response", ""); + ++ if (!strcmp(reply_str, "token_updating")) { ++ daemon_reply_destroy(reply); ++ if (!(now = _monotonic_seconds())) { ++ log_print_unless_silent("_monotonic_seconds error"); ++ return 0; ++ } ++ ++ if (!wait_start) ++ wait_start = now; ++ ++ if (now - wait_start <= wait_sec) { ++ log_warn("lvmetad is being updated, retry for %u more seconds.", ++ wait_sec - (unsigned int)(now - wait_start)); ++ delay_usec = 1000000 + lvm_even_rand(&_lvmetad_cmd->rand_seed, 1000000); ++ usleep(delay_usec); ++ goto retry; ++ } ++ ++ log_print_unless_silent("Not using lvmetad after %u sec lvmetad_update_wait_time, no more try.", wait_sec); ++ return 0; ++ } ++ + /* + * A mismatch can only happen when this command attempts to set the + * token to filter: at the end of its update, but the update has +@@ -578,11 +605,11 @@ static int _token_update(int *replaced_update) + + ending_our_update = strcmp(_lvmetad_token, LVMETAD_TOKEN_UPDATE_IN_PROGRESS); + +- log_debug_lvmetad("Received token update mismatch expected \"%s\" our token \"%s\" update_pid %d our pid %d", ++ log_print_unless_silent("Received token update mismatch expected \"%s\" our token \"%s\" update_pid %d our pid %d", + token_expected, _lvmetad_token, update_pid, getpid()); + + if (ending_our_update && (update_pid != getpid())) { +- log_warn("WARNING: lvmetad was updated by another command (pid %d).", update_pid); ++ log_print_unless_silent("WARNING: lvmetad was updated by another command (pid %d).", update_pid); + } else { + /* + * Shouldn't happen. +-- +2.19.1 + diff --git a/6039-libdaemon-use-pselect-to-avoid-condition-checking-ra.patch b/6039-libdaemon-use-pselect-to-avoid-condition-checking-ra.patch new file mode 100644 index 0000000..8ec21e8 --- /dev/null +++ b/6039-libdaemon-use-pselect-to-avoid-condition-checking-ra.patch @@ -0,0 +1,148 @@ +From 6d4f36c2c7f782af31eca7eca63310791a4f8e93 Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Wed, 10 Apr 2019 12:50:53 +0200 +Subject: [PATCH] libdaemon: use pselect to avoid condition checking race + +To avoid tiny race on checking arrival of signal and entering select +(that can latter remain stuck as signal was already delivered) switch +to use pselect(). + +If it would needed, we can eventually add extra code for older systems +without pselect(), but there are probably no such ancient systems in +use. +--- + daemons/lvmetad/lvmetad-core.c | 2 +- + daemons/lvmpolld/lvmpolld-core.c | 2 +- + libdaemon/server/daemon-server.c | 38 +++++++++++++++++++++++--------- + libdaemon/server/daemon-server.h | 2 +- + 4 files changed, 31 insertions(+), 13 deletions(-) + +diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c +index c274880..fddec2e 100644 +--- a/daemons/lvmetad/lvmetad-core.c ++++ b/daemons/lvmetad/lvmetad-core.c +@@ -2964,7 +2964,7 @@ static void usage(const char *prog, FILE *file) + int main(int argc, char *argv[]) + { + signed char opt; +- struct timeval timeout; ++ struct timespec timeout; + daemon_idle di = { .ptimeout = &timeout }; + lvmetad_state ls = { .log_config = "" }; + daemon_state s = { +diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c +index fd73272..f1056c3 100644 +--- a/daemons/lvmpolld/lvmpolld-core.c ++++ b/daemons/lvmpolld/lvmpolld-core.c +@@ -915,7 +915,7 @@ int main(int argc, char *argv[]) + int option_index = 0; + int client = 0, server = 0; + unsigned action = ACTION_MAX; +- struct timeval timeout; ++ struct timespec timeout; + daemon_idle di = { .ptimeout = &timeout }; + struct lvmpolld_state ls = { .log_config = "" }; + daemon_state s = { +diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c +index 83f56db..53bee39 100644 +--- a/libdaemon/server/daemon-server.c ++++ b/libdaemon/server/daemon-server.c +@@ -87,7 +87,7 @@ static int _is_idle(daemon_state s) + return s.idle && s.idle->is_idle && !s.threads->next; + } + +-static struct timeval *_get_timeout(daemon_state s) ++static struct timespec *_get_timeout(daemon_state s) + { + return s.idle ? s.idle->ptimeout : NULL; + } +@@ -96,7 +96,7 @@ static void _reset_timeout(daemon_state s) + { + if (s.idle) { + s.idle->ptimeout->tv_sec = 1; +- s.idle->ptimeout->tv_usec = 0; ++ s.idle->ptimeout->tv_nsec = 0; + } + } + +@@ -561,6 +561,8 @@ void daemon_start(daemon_state s) + thread_state _threads = { .next = NULL }; + unsigned timeout_count = 0; + fd_set in; ++ sigset_t new_set, old_set; ++ int ret; + + /* + * Switch to C locale to avoid reading large locale-archive file used by +@@ -628,8 +630,7 @@ void daemon_start(daemon_state s) + if (!s.foreground) + kill(getppid(), SIGTERM); + +- /* +- * Use daemon_main for daemon-specific init and polling, or ++ /* Use daemon_main for daemon-specific init and polling, or + * use daemon_init for daemon-specific init and generic lib polling. + */ + +@@ -643,22 +644,39 @@ void daemon_start(daemon_state s) + if (!s.daemon_init(&s)) + failed = 1; + ++ if (s.socket_fd >= FD_SETSIZE) ++ failed = 1; /* FD out of available selectable set */ ++ ++ sigfillset(&new_set); ++ sigprocmask(SIG_SETMASK, NULL, &old_set); ++ + while (!failed) { + _reset_timeout(s); + FD_ZERO(&in); + FD_SET(s.socket_fd, &in); +- if (select(FD_SETSIZE, &in, NULL, NULL, _get_timeout(s)) < 0 && errno != EINTR) +- perror("select error"); ++ ++ sigprocmask(SIG_SETMASK, &new_set, NULL); ++ if (_shutdown_requested && !s.threads->next) { ++ sigprocmask(SIG_SETMASK, &old_set, NULL); ++ INFO(&s, "%s shutdown requested", s.name); ++ break; ++ } ++ ret = pselect(s.socket_fd + 1, &in, NULL, NULL, _get_timeout(s), &old_set); ++ sigprocmask(SIG_SETMASK, &old_set, NULL); ++ ++ if (ret < 0) { ++ if (errno != EINTR && errno != EAGAIN && ++ (EWOULDBLOCK == EAGAIN || errno != EWOULDBLOCK)) ++ perror("select error"); ++ continue; ++ } ++ + if (FD_ISSET(s.socket_fd, &in)) { + timeout_count = 0; + _handle_connect(s); + } +- + _reap(s, 0); + +- if (_shutdown_requested && !s.threads->next) +- break; +- + /* s.idle == NULL equals no shutdown on timeout */ + if (_is_idle(s)) { + DEBUGLOG(&s, "timeout occured"); +diff --git a/libdaemon/server/daemon-server.h b/libdaemon/server/daemon-server.h +index 2b9ceac..e77ac20 100644 +--- a/libdaemon/server/daemon-server.h ++++ b/libdaemon/server/daemon-server.h +@@ -47,7 +47,7 @@ struct timeval; + typedef struct { + volatile unsigned is_idle; + unsigned max_timeouts; +- struct timeval *ptimeout; ++ struct timespec *ptimeout; + } daemon_idle; + + struct daemon_state; +-- +2.19.1 + diff --git a/6040-libdaemon-ensure-threads-are-reaped-before-checking-.patch b/6040-libdaemon-ensure-threads-are-reaped-before-checking-.patch new file mode 100644 index 0000000..02e5321 --- /dev/null +++ b/6040-libdaemon-ensure-threads-are-reaped-before-checking-.patch @@ -0,0 +1,35 @@ +From b41b112a4bf5f674acd45f12ff4efe7fa0d1d8be Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Mon, 29 Apr 2019 13:43:36 +0200 +Subject: [PATCH] libdaemon: ensure threads are reaped before checking shutdown + +Since we are checking _shutdown_requested - we expect all threads +are finished - that is currently checked only by checking ->next ptr +being NULL - so this can be NULL only when _reap() function clears +out all already finished threads. + +I'm finding this design quite problematic in its core - but as a +'trivial hotfix' - lets _reap() linked list before check for signal. + +There is likely a large potentical for few races - but the windows is +very very small - since lvmetad has been already purged from upstream, +lets go with this hotfix. +--- + libdaemon/server/daemon-server.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c +index 8534b79..79b54d0 100644 +--- a/libdaemon/server/daemon-server.c ++++ b/libdaemon/server/daemon-server.c +@@ -655,6 +655,7 @@ void daemon_start(daemon_state s) + FD_ZERO(&in); + FD_SET(s.socket_fd, &in); + ++ _reap(s, 0); + sigprocmask(SIG_SETMASK, &new_set, NULL); + if (_shutdown_requested && !s.threads->next) { + sigprocmask(SIG_SETMASK, &old_set, NULL); +-- +1.8.3.1 + diff --git a/6041-lvmetad-fix-timeout-on-shutdown.patch b/6041-lvmetad-fix-timeout-on-shutdown.patch new file mode 100644 index 0000000..7f67bab --- /dev/null +++ b/6041-lvmetad-fix-timeout-on-shutdown.patch @@ -0,0 +1,63 @@ +From 61358d92cbf202dbb483d63a63d5adf0463bb934 Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Wed, 25 Sep 2019 17:22:49 +0200 +Subject: [PATCH 127/180] lvmetad: fix timeout on shutdown + +When lvmetad is going to be shutdown - there were 2 issue: +If there was endless stream of command contacting lvmetad - the process +would never finish - so now when we recieved SIGTERM - we are no longer +accepting new connections and we just wait till the existing ones are +finished. + +2nd. issue is that actually when we are waiting for finish of all client +threads - we basically want an usleep() and check if all threads +are already finished - proper solution would be to singal from a thread +there is some work to do for master thread - but that would be a bigger +change and since lvmetad is no longer developed - keep the change +minimal and just use pselect() as our '1sec.' sleeping call once +we are in 'shutdown' mode. + +Reported-by: wangjufeng@huawei.com +--- + libdaemon/server/daemon-server.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c +index 71f7fae..90bf055 100644 +--- a/libdaemon/server/daemon-server.c ++++ b/libdaemon/server/daemon-server.c +@@ -89,6 +89,13 @@ static int _is_idle(daemon_state s) + + static struct timespec *_get_timeout(daemon_state s) + { ++ static struct timespec _tm = { 0 }; ++ ++ if (_shutdown_requested) { ++ _tm.tv_sec = 1; ++ return &_tm; ++ } ++ + return s.idle ? s.idle->ptimeout : NULL; + } + +@@ -506,7 +513,7 @@ static int _handle_connect(daemon_state s) + socklen_t sl = sizeof(sockaddr); + + client.socket_fd = accept(s.socket_fd, (struct sockaddr *) &sockaddr, &sl); +- if (client.socket_fd < 0) { ++ if (client.socket_fd < 0 || _shutdown_requested) { + if (errno != EAGAIN || !_shutdown_requested) + ERROR(&s, "Failed to accept connection: %s.", strerror(errno)); + return 0; +@@ -671,7 +678,7 @@ void daemon_start(daemon_state s) + continue; + } + +- if (FD_ISSET(s.socket_fd, &in)) { ++ if (!_shutdown_requested && FD_ISSET(s.socket_fd, &in)) { + timeout_count = 0; + _handle_connect(s); + } +-- +2.19.1 + diff --git a/6042-devs-check-for-no-dev-when-dropping-aliases.patch b/6042-devs-check-for-no-dev-when-dropping-aliases.patch new file mode 100644 index 0000000..fe703ba --- /dev/null +++ b/6042-devs-check-for-no-dev-when-dropping-aliases.patch @@ -0,0 +1,31 @@ +From f50af80199f723f7b1970ee33ddf959ea79fcbef Mon Sep 17 00:00:00 2001 +From: David Teigland +Date: Wed, 16 Oct 2019 13:32:28 -0500 +Subject: [PATCH 134/180] devs: check for no dev when dropping aliases + +When scanning fails to find a device path and +looks for device aliases, check if the device +itself still exists to avoid a potential segfault. +--- + lib/label/label.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/lib/label/label.c b/lib/label/label.c +index 8107e33..e4a1068 100644 +--- a/lib/label/label.c ++++ b/lib/label/label.c +@@ -734,6 +734,11 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f, + retried_open = 1; + + dm_list_iterate_items_safe(devl, devl2, &reopen_devs) { ++ if (!devl->dev) { ++ dm_list_del(&devl->list); ++ continue; ++ } ++ + _drop_bad_aliases(devl->dev); + + if (dm_list_empty(&devl->dev->aliases)) { +-- +1.8.3.1 + diff --git a/6043-cov-missing-checks-of-syscalls.patch b/6043-cov-missing-checks-of-syscalls.patch new file mode 100644 index 0000000..52bfb9c --- /dev/null +++ b/6043-cov-missing-checks-of-syscalls.patch @@ -0,0 +1,84 @@ +From 67bdae069751e4779e738283e3d8a5873622bfc0 Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Fri, 1 Nov 2019 20:25:39 +0100 +Subject: [PATCH 169/180] cov: missing checks of syscalls + +Check for sigaction,sigprocmask,pthread_sigmask errors +--- + daemons/clvmd/clvmd.c | 10 ++++++---- + libdaemon/server/daemon-server.c | 9 ++++++--- + tools/toollib.c | 3 ++- + 3 files changed, 14 insertions(+), 8 deletions(-) + +diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c +index 829c5e5..e1d8a79 100644 +--- a/daemons/clvmd/clvmd.c ++++ b/daemons/clvmd/clvmd.c +@@ -887,7 +887,8 @@ static void main_loop(int cmd_timeout) + sigemptyset(&ss); + sigaddset(&ss, SIGINT); + sigaddset(&ss, SIGTERM); +- pthread_sigmask(SIG_UNBLOCK, &ss, NULL); ++ if (pthread_sigmask(SIG_UNBLOCK, &ss, NULL)) ++ log_warn("WARNING: Failed to unblock SIGCHLD."); + /* Main loop */ + while (!quit) { + fd_set in; +@@ -1731,11 +1732,12 @@ static __attribute__ ((noreturn)) void *pre_and_post_thread(void *arg) + SIGUSR2 (kills subthreads) */ + sigemptyset(&ss); + sigaddset(&ss, SIGUSR1); +- pthread_sigmask(SIG_BLOCK, &ss, NULL); +- ++ if (pthread_sigmask(SIG_BLOCK, &ss, NULL)) ++ log_warn("WARNING: Failed to block SIGUSR1."); + sigdelset(&ss, SIGUSR1); + sigaddset(&ss, SIGUSR2); +- pthread_sigmask(SIG_UNBLOCK, &ss, NULL); ++ if (pthread_sigmask(SIG_UNBLOCK, &ss, NULL)) ++ log_warn("WARNING: Failed to unblock SIGUSR2."); + + /* Loop around doing PRE and POST functions until the client goes away */ + while (!client->bits.localsock.finished) { +diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c +index 62f403a..51e5866 100644 +--- a/libdaemon/server/daemon-server.c ++++ b/libdaemon/server/daemon-server.c +@@ -663,14 +663,17 @@ void daemon_start(daemon_state s) + FD_SET(s.socket_fd, &in); + + _reap(s, 0); +- sigprocmask(SIG_SETMASK, &new_set, NULL); ++ if (sigprocmask(SIG_SETMASK, &new_set, NULL)) ++ perror("sigprocmask error"); + if (_shutdown_requested && !s.threads->next) { +- sigprocmask(SIG_SETMASK, &old_set, NULL); ++ if (sigprocmask(SIG_SETMASK, &old_set, NULL)) ++ perror("sigprocmask error"); + INFO(&s, "%s shutdown requested", s.name); + break; + } + ret = pselect(s.socket_fd + 1, &in, NULL, NULL, _get_timeout(s), &old_set); +- sigprocmask(SIG_SETMASK, &old_set, NULL); ++ if (sigprocmask(SIG_SETMASK, &old_set, NULL)) ++ perror("sigprocmask error"); + + if (ret < 0) { + if (errno != EINTR && errno != EAGAIN && +diff --git a/tools/toollib.c b/tools/toollib.c +index 42179d9..0c1c095 100644 +--- a/tools/toollib.c ++++ b/tools/toollib.c +@@ -59,7 +59,8 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm) + + log_verbose("Forking background process from command: %s", cmd->cmd_line); + +- sigaction(SIGCHLD, &act, NULL); ++ if (sigaction(SIGCHLD, &act, NULL)) ++ log_warn("WARNING: Failed to set SIGCHLD action."); + + if (!skip_lvm) + if (!sync_local_dev_names(cmd)) { /* Flush ops and reset dm cookie */ +-- +1.8.3.1 + diff --git a/6044-cov-ensure-read_ahead-is-available.patch b/6044-cov-ensure-read_ahead-is-available.patch new file mode 100644 index 0000000..d40397b --- /dev/null +++ b/6044-cov-ensure-read_ahead-is-available.patch @@ -0,0 +1,26 @@ +From f90c3d69cedf94fa094bc71cc98376d58d970223 Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Fri, 1 Nov 2019 21:01:51 +0100 +Subject: [PATCH 170/180] cov: ensure read_ahead is available + +Make sure read_ahead pointer is not NULL when quering for RA. +--- + lib/activate/dev_manager.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c +index d281b60..4e7a631 100644 +--- a/lib/activate/dev_manager.c ++++ b/lib/activate/dev_manager.c +@@ -258,7 +258,7 @@ static int _info_run(const char *dlid, struct dm_info *dminfo, + with_open_count, with_flush, 0))) + return_0; + +- if (with_read_ahead && dminfo->exists) { ++ if (with_read_ahead && read_ahead && dminfo->exists) { + if (!dm_task_get_read_ahead(dmt, read_ahead)) + goto_out; + } else if (read_ahead) +-- +2.19.1 + diff --git a/6045-lvmcache-free-resource-on-error-path.patch b/6045-lvmcache-free-resource-on-error-path.patch new file mode 100644 index 0000000..6e629f1 --- /dev/null +++ b/6045-lvmcache-free-resource-on-error-path.patch @@ -0,0 +1,33 @@ +From 34bde8b6c7e517239a05334683a09f2b5075fdcc Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Fri, 8 Nov 2019 12:51:48 +0100 +Subject: [PATCH 171/180] lvmcache: free resource on error path + +Free allocated svg on error path. +Also explicitely ignore dm_strncpy() result. +(We know it will end with failure here.) +--- + lib/cache/lvmcache.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c +index 9890325..c12ec2b 100644 +--- a/lib/cache/lvmcache.c ++++ b/lib/cache/lvmcache.c +@@ -325,10 +325,12 @@ void lvmcache_save_vg(struct volume_group *vg, int precommitted) + + dm_list_init(&svg->saved_vg_to_free); + +- dm_strncpy(svg->vgid, (const char *)vg->id.uuid, sizeof(svg->vgid)); ++ /* Ignore result code, size we intentionally short-cut & pad with 0 */ ++ (void) dm_strncpy(svg->vgid, (const char *)vg->id.uuid, sizeof(svg->vgid)); + + if (!dm_hash_insert(_saved_vg_hash, svg->vgid, svg)) { + log_error("lvmcache: failed to insert saved_vg %s", svg->vgid); ++ dm_free(svg); + return; + } + } else { +-- +1.8.3.1 + diff --git a/6046-daemons-check-for-non-zero-thread_id.patch b/6046-daemons-check-for-non-zero-thread_id.patch new file mode 100644 index 0000000..4a0f36d --- /dev/null +++ b/6046-daemons-check-for-non-zero-thread_id.patch @@ -0,0 +1,27 @@ +From bbdcdc12b2240e00f6ab8ff105e954629412b234 Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Fri, 8 Nov 2019 13:10:49 +0100 +Subject: [PATCH 173/180] daemons: check for non-zero thread_id + +Do not call pthread_join if thread_id would be 0. +--- + libdaemon/server/daemon-server.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c +index aa9ff2a..9408440 100644 +--- a/libdaemon/server/daemon-server.c ++++ b/libdaemon/server/daemon-server.c +@@ -560,7 +560,8 @@ static void _reap(daemon_state s, int waiting) + + while (ts) { + if (waiting || !ts->active) { +- if ((errno = pthread_join(ts->client.thread_id, &rv))) ++ if (ts->client.thread_id && ++ (errno = pthread_join(ts->client.thread_id, &rv))) + ERROR(&s, "pthread_join failed: %s", strerror(errno)); + last->next = ts->next; + dm_free(ts); +-- +1.8.3.1 + diff --git a/6047-revert-label_scan-remove-extra-label-scan-and-read-f.patch b/6047-revert-label_scan-remove-extra-label-scan-and-read-f.patch new file mode 100644 index 0000000..9b84d4e --- /dev/null +++ b/6047-revert-label_scan-remove-extra-label-scan-and-read-f.patch @@ -0,0 +1,28 @@ +From 7517074585ca042c0bd06481a359d617fabdc032 Mon Sep 17 00:00:00 2001 +From: wangjufeng +Date: Wed, 20 Nov 2019 17:37:03 +0800 +Subject: [PATCH] revert "label_scan: remove extra label scan and read for + orphan PVs" + +In commit 79c4971210a6337563ffa2fca08fb636423d93d4, it removed the + modification of *consistent in vg_read_orphans(), it will lead to pvs + --readonly return failure. +--- + lib/metadata/metadata.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c +index 237e57b..35f35bd 100644 +--- a/lib/metadata/metadata.c ++++ b/lib/metadata/metadata.c +@@ -3426,6 +3426,7 @@ struct volume_group *vg_read_orphans(struct cmd_context *cmd, + if (!lvmcache_foreach_pv(vginfo, _vg_read_orphan_pv, &baton)) + return_NULL; + ++ *consistent = 1; + return vg; + } + +-- +2.19.1 + diff --git a/9000-bugfix-lvm2-add-SSD.patch b/9000-bugfix-lvm2-add-SSD.patch index ba364ad..13015a2 100644 --- a/9000-bugfix-lvm2-add-SSD.patch +++ b/9000-bugfix-lvm2-add-SSD.patch @@ -3,8 +3,6 @@ From: geruijun Date: Thu, 14 Feb 2019 04:55:01 -0500 Subject: [PATCH] lvm2: add 0002-bugfix-lvm2-add-SSD.patch -DTS/AR: -reason: --- conf/example.conf.in | 1 + 1 file changed, 1 insertion(+) diff --git a/lvm2.spec b/lvm2.spec index ad1dfad..5d9ef3c 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.02.181 -Release: 3 +Release: 4 Epoch: 8 Summary: Tools for logical volume management License: GPLv2 and LGPLv2 @@ -90,6 +90,16 @@ Patch6034: 6034-mangenerator-check-strdup-was-successfull.patch Patch6035: 6035-cov-ensure-lock_type-is-not-NULL.patch Patch6036: 6036-Remove-checking-for-locked-VGs.patch Patch6037: 6037-lvm2-default-allow-changes-with-duplicate-pvs.patch +Patch6038: 6038-lvmetad-fix-sync-cache-to-lvmetad.patch +Patch6039: 6039-libdaemon-use-pselect-to-avoid-condition-checking-ra.patch +Patch6040: 6040-libdaemon-ensure-threads-are-reaped-before-checking-.patch +Patch6041: 6041-lvmetad-fix-timeout-on-shutdown.patch +Patch6042: 6042-devs-check-for-no-dev-when-dropping-aliases.patch +Patch6043: 6043-cov-missing-checks-of-syscalls.patch +Patch6044: 6044-cov-ensure-read_ahead-is-available.patch +Patch6045: 6045-lvmcache-free-resource-on-error-path.patch +Patch6046: 6046-daemons-check-for-non-zero-thread_id.patch +Patch6047: 6047-revert-label_scan-remove-extra-label-scan-and-read-f.patch Patch9000: 9000-bugfix-lvm2-add-SSD.patch Patch9001: 9001-bugfix-add-timeout-when-fail-to-wait-udev.patch @@ -534,11 +544,17 @@ fi %changelog -* Sat Nov 30 2019 zoujing - 2.02.181-3 +* Mon Dec 23 2019 openEuler Buildteam - 8:2.02.181-4 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:sync bugfix from community + +* Sat Nov 30 2019 openEuler Buildteam - 8:2.02.181-3 - Type:NA - ID:NA - SUG:NA - DESC:remove some buildrequires in spec -* Fri Sep 06 2019 wangjufeng - 2.02.181-2 +* Fri Sep 06 2019 openEuler Buildteam - 8:2.02.181-2 - Package init