From f4d4e0424353f1b91d7a82e9689484560d934a41 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 12 2020 12:35:13 +0000 Subject: import systemd-219-73.el7_8.6 --- diff --git a/SOURCES/0813-sd-bus-when-attached-to-an-sd-event-loop-disconnect-.patch b/SOURCES/0813-sd-bus-when-attached-to-an-sd-event-loop-disconnect-.patch new file mode 100644 index 0000000..32d6eb2 --- /dev/null +++ b/SOURCES/0813-sd-bus-when-attached-to-an-sd-event-loop-disconnect-.patch @@ -0,0 +1,106 @@ +From e525ce5713f8263258c2cdf687adc67108425f6a Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 15 Dec 2017 22:24:16 +0100 +Subject: [PATCH] sd-bus: when attached to an sd-event loop, disconnect on + processing errors + +If we can't process the bus for some reason we shouldn't just disable +the event source, but log something and give up on the connection. Hence +do that, and disconnect. + +(cherry-picked from commit 5ae37ad833583e6c1c7765767b7f8360afca3b07) + +Resolves: #1817504 +--- + src/libsystemd/sd-bus/sd-bus.c | 45 +++++++++++++++++++++------------- + 1 file changed, 28 insertions(+), 17 deletions(-) + +diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c +index 44ed2c7497..2c8cc66367 100644 +--- a/src/libsystemd/sd-bus/sd-bus.c ++++ b/src/libsystemd/sd-bus/sd-bus.c +@@ -3037,8 +3037,10 @@ static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userd + assert(bus); + + r = sd_bus_process(bus, NULL); +- if (r < 0) +- return r; ++ if (r < 0) { ++ log_debug_errno(r, "Processing of bus failed, closing down: %m"); ++ bus_enter_closing(bus); ++ } + + return 1; + } +@@ -3050,8 +3052,10 @@ static int time_callback(sd_event_source *s, uint64_t usec, void *userdata) { + assert(bus); + + r = sd_bus_process(bus, NULL); +- if (r < 0) +- return r; ++ if (r < 0) { ++ log_debug_errno(r, "Processing of bus failed, closing down: %m"); ++ bus_enter_closing(bus); ++ } + + return 1; + } +@@ -3065,38 +3069,45 @@ static int prepare_callback(sd_event_source *s, void *userdata) { + assert(bus); + + e = sd_bus_get_events(bus); +- if (e < 0) +- return e; ++ if (e < 0) { ++ r = e; ++ goto fail; ++ } + + if (bus->output_fd != bus->input_fd) { + + r = sd_event_source_set_io_events(bus->input_io_event_source, e & POLLIN); + if (r < 0) +- return r; ++ goto fail; + + r = sd_event_source_set_io_events(bus->output_io_event_source, e & POLLOUT); +- if (r < 0) +- return r; +- } else { ++ } else + r = sd_event_source_set_io_events(bus->input_io_event_source, e); +- if (r < 0) +- return r; +- } ++ if (r < 0) ++ goto fail; + + r = sd_bus_get_timeout(bus, &until); + if (r < 0) +- return r; ++ goto fail; + if (r > 0) { + int j; + + j = sd_event_source_set_time(bus->time_event_source, until); +- if (j < 0) +- return j; ++ if (j < 0) { ++ r = j; ++ goto fail; ++ } + } + + r = sd_event_source_set_enabled(bus->time_event_source, r > 0); + if (r < 0) +- return r; ++ goto fail; ++ ++ return 1; ++ ++fail: ++ log_debug_errno(r, "Preparing of bus events failed, closing down: %m"); ++ bus_enter_closing(bus); + + return 1; + } diff --git a/SOURCES/0814-sd-journal-close-journal-files-that-were-deleted-by-.patch b/SOURCES/0814-sd-journal-close-journal-files-that-were-deleted-by-.patch new file mode 100644 index 0000000..03e1dd2 --- /dev/null +++ b/SOURCES/0814-sd-journal-close-journal-files-that-were-deleted-by-.patch @@ -0,0 +1,75 @@ +From f813fe0bebb2dddf0fe961527c6e840b88d49dc3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michal=20Sekleta=CC=81r?= +Date: Tue, 4 Feb 2020 14:23:14 +0100 +Subject: [PATCH] sd-journal: close journal files that were deleted by journald + before we've setup inotify watch + +(cherry-picked from commit 28ca867abdb20d0e4ac1901e2ed669cdb41ea3f6) + +Fixes #14695 + +Related: #1820073 +--- + src/journal/journal-file.c | 2 +- + src/journal/journal-file.h | 1 + + src/journal/sd-journal.c | 15 +++++++++++++++ + 3 files changed, 17 insertions(+), 1 deletion(-) + +diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c +index cf8dad3fcd..86a7e2642a 100644 +--- a/src/journal/journal-file.c ++++ b/src/journal/journal-file.c +@@ -337,7 +337,7 @@ static int journal_file_verify_header(JournalFile *f) { + return 0; + } + +-static int journal_file_fstat(JournalFile *f) { ++int journal_file_fstat(JournalFile *f) { + assert(f); + assert(f->fd >= 0); + +diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h +index 37749c4459..ee9772b9bb 100644 +--- a/src/journal/journal-file.h ++++ b/src/journal/journal-file.h +@@ -139,6 +139,7 @@ int journal_file_open( + + int journal_file_set_offline(JournalFile *f); + void journal_file_close(JournalFile *j); ++int journal_file_fstat(JournalFile *j); + + int journal_file_open_reliably( + const char *fname, +diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c +index 004fe646d4..09466df810 100644 +--- a/src/journal/sd-journal.c ++++ b/src/journal/sd-journal.c +@@ -2386,6 +2386,8 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) { + assert_return(!journal_pid_changed(j), -ECHILD); + + if (j->inotify_fd < 0) { ++ Iterator i; ++ JournalFile *f; + + /* This is the first invocation, hence create the + * inotify watch */ +@@ -2393,6 +2395,19 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) { + if (r < 0) + return r; + ++ /* Server might have done some vacuuming while we weren't watching. ++ Get rid of the deleted files now so they don't stay around indefinitely. */ ++ ORDERED_HASHMAP_FOREACH(f, j->files, i) { ++ r = journal_file_fstat(f); ++ if (r < 0) { ++ log_error("Failed to fstat() journal file '%s' : %m", f->path); ++ continue; ++ } ++ ++ if (f->last_stat.st_nlink <= 0) ++ remove_file_real(j, f); ++ } ++ + /* The journal might have changed since the context + * object was created and we weren't watching before, + * hence don't wait for anything, and return diff --git a/SOURCES/0815-sd-journal-remove-the-dead-code-and-actually-fix-146.patch b/SOURCES/0815-sd-journal-remove-the-dead-code-and-actually-fix-146.patch new file mode 100644 index 0000000..b083bc7 --- /dev/null +++ b/SOURCES/0815-sd-journal-remove-the-dead-code-and-actually-fix-146.patch @@ -0,0 +1,42 @@ +From fadf2a316458ac262f3d5f690bd481fac2d4e566 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michal=20Sekleta=CC=81r?= +Date: Fri, 27 Mar 2020 17:01:59 +0100 +Subject: [PATCH] sd-journal: remove the dead code and actually fix #14695 + +journal_file_fstat() returns an error if we call it on already unlinked +journal file and hence we never reach remove_file_real() which is the +entire point. + +I must have made some mistake while testing the fix that got me thinking +the issue is gone while opposite was true. + +Fixes #14695 + +(cherry-picked from commit 8581b9f9732d4c158bb5f773230a65ce77f2c292) + +Resolves: #1820073 +--- + src/journal/sd-journal.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c +index 09466df810..1f03c8e8ba 100644 +--- a/src/journal/sd-journal.c ++++ b/src/journal/sd-journal.c +@@ -2399,13 +2399,12 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) { + Get rid of the deleted files now so they don't stay around indefinitely. */ + ORDERED_HASHMAP_FOREACH(f, j->files, i) { + r = journal_file_fstat(f); +- if (r < 0) { ++ if (r == -EIDRM) ++ remove_file_real(j, f); ++ else if (r < 0) { + log_error("Failed to fstat() journal file '%s' : %m", f->path); + continue; + } +- +- if (f->last_stat.st_nlink <= 0) +- remove_file_real(j, f); + } + + /* The journal might have changed since the context diff --git a/SOURCES/0816-swap-adjust-swap.c-in-a-similar-way-to-what-we-just-.patch b/SOURCES/0816-swap-adjust-swap.c-in-a-similar-way-to-what-we-just-.patch new file mode 100644 index 0000000..f15b4d8 --- /dev/null +++ b/SOURCES/0816-swap-adjust-swap.c-in-a-similar-way-to-what-we-just-.patch @@ -0,0 +1,260 @@ +From 6181124fac6fbfd83e12fbe5f0068da826ab5772 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 25 Sep 2017 19:53:19 +0200 +Subject: [PATCH] swap: adjust swap.c in a similar way to what we just did to + mount.c + +Also drop the redundant states and make all similar changes too. +Thankfully the swap.c state engine is much simpler than mount.c's, hence +this should be easier to digest. + +(cherry picked from commit 50864457e1bc5f7a4ab2fd02e1565bc5d135d2f3) +(cherry picked from commit 714dbded2ac725e1e2e6b61a289c118dae555dee) + +Related: #1821261 +--- + src/core/swap.c | 96 +++++++++++++++++++++++-------------------------- + src/core/swap.h | 2 -- + 2 files changed, 44 insertions(+), 54 deletions(-) + +diff --git a/src/core/swap.c b/src/core/swap.c +index 4a5e882332..c9cce3d945 100644 +--- a/src/core/swap.c ++++ b/src/core/swap.c +@@ -49,8 +49,6 @@ static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = { + [SWAP_ACTIVATING_DONE] = UNIT_ACTIVE, + [SWAP_ACTIVE] = UNIT_ACTIVE, + [SWAP_DEACTIVATING] = UNIT_DEACTIVATING, +- [SWAP_ACTIVATING_SIGTERM] = UNIT_DEACTIVATING, +- [SWAP_ACTIVATING_SIGKILL] = UNIT_DEACTIVATING, + [SWAP_DEACTIVATING_SIGTERM] = UNIT_DEACTIVATING, + [SWAP_DEACTIVATING_SIGKILL] = UNIT_DEACTIVATING, + [SWAP_FAILED] = UNIT_FAILED +@@ -490,8 +488,6 @@ static void swap_set_state(Swap *s, SwapState state) { + s->state = state; + + if (state != SWAP_ACTIVATING && +- state != SWAP_ACTIVATING_SIGTERM && +- state != SWAP_ACTIVATING_SIGKILL && + state != SWAP_ACTIVATING_DONE && + state != SWAP_DEACTIVATING && + state != SWAP_DEACTIVATING_SIGTERM && +@@ -538,8 +534,6 @@ static int swap_coldplug(Unit *u, Hashmap *deferred_work) { + return 0; + + if (new_state == SWAP_ACTIVATING || +- new_state == SWAP_ACTIVATING_SIGTERM || +- new_state == SWAP_ACTIVATING_SIGKILL || + new_state == SWAP_ACTIVATING_DONE || + new_state == SWAP_DEACTIVATING || + new_state == SWAP_DEACTIVATING_SIGTERM || +@@ -682,6 +676,15 @@ static void swap_enter_active(Swap *s, SwapResult f) { + swap_set_state(s, SWAP_ACTIVE); + } + ++static void swap_enter_dead_or_active(Swap *s, SwapResult f) { ++ assert(s); ++ ++ if (s->from_proc_swaps) ++ swap_enter_active(s, f); ++ else ++ swap_enter_dead(s, f); ++} ++ + static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) { + int r; + +@@ -693,8 +696,7 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) { + r = unit_kill_context( + UNIT(s), + &s->kill_context, +- (state != SWAP_ACTIVATING_SIGTERM && state != SWAP_DEACTIVATING_SIGTERM) ? +- KILL_KILL : KILL_TERMINATE, ++ state != SWAP_DEACTIVATING_SIGTERM ? KILL_KILL : KILL_TERMINATE, + -1, + s->control_pid, + false); +@@ -707,18 +709,16 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) { + goto fail; + + swap_set_state(s, state); +- } else if (state == SWAP_ACTIVATING_SIGTERM) +- swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, SWAP_SUCCESS); +- else if (state == SWAP_DEACTIVATING_SIGTERM) ++ } else if (state == SWAP_DEACTIVATING_SIGTERM && s->kill_context.send_sigkill) + swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, SWAP_SUCCESS); + else +- swap_enter_dead(s, SWAP_SUCCESS); ++ swap_enter_dead_or_active(s, SWAP_SUCCESS); + + return; + + fail: + log_unit_warning_errno(UNIT(s)->id, r, "%s failed to kill processes: %m", UNIT(s)->id); +- swap_enter_dead(s, SWAP_FAILURE_RESOURCES); ++ swap_enter_dead_or_active(s, SWAP_FAILURE_RESOURCES); + } + + static void swap_enter_activating(Swap *s) { +@@ -781,7 +781,7 @@ static void swap_enter_activating(Swap *s) { + + fail: + log_unit_warning_errno(UNIT(s)->id, r, "%s failed to run 'swapon' task: %m", UNIT(s)->id); +- swap_enter_dead(s, SWAP_FAILURE_RESOURCES); ++ swap_enter_dead_or_active(s, SWAP_FAILURE_RESOURCES); + } + + static void swap_enter_deactivating(Swap *s) { +@@ -811,7 +811,7 @@ static void swap_enter_deactivating(Swap *s) { + + fail: + log_unit_warning_errno(UNIT(s)->id, r, "%s failed to run 'swapoff' task: %m", UNIT(s)->id); +- swap_enter_active(s, SWAP_FAILURE_RESOURCES); ++ swap_enter_dead_or_active(s, SWAP_FAILURE_RESOURCES); + } + + static int swap_start(Unit *u) { +@@ -824,11 +824,10 @@ static int swap_start(Unit *u) { + + if (s->state == SWAP_DEACTIVATING || + s->state == SWAP_DEACTIVATING_SIGTERM || +- s->state == SWAP_DEACTIVATING_SIGKILL || +- s->state == SWAP_ACTIVATING_SIGTERM || +- s->state == SWAP_ACTIVATING_SIGKILL) ++ s->state == SWAP_DEACTIVATING_SIGKILL) + return -EAGAIN; + ++ /* Already on it! */ + if (s->state == SWAP_ACTIVATING) + return 0; + +@@ -854,22 +853,30 @@ static int swap_stop(Unit *u) { + + assert(s); + +- if (s->state == SWAP_DEACTIVATING || +- s->state == SWAP_DEACTIVATING_SIGTERM || +- s->state == SWAP_DEACTIVATING_SIGKILL || +- s->state == SWAP_ACTIVATING_SIGTERM || +- s->state == SWAP_ACTIVATING_SIGKILL) ++ switch (s->state) { ++ ++ case SWAP_DEACTIVATING: ++ case SWAP_DEACTIVATING_SIGTERM: ++ case SWAP_DEACTIVATING_SIGKILL: ++ /* Already on it */ ++ return 0; ++ ++ case SWAP_ACTIVATING: ++ case SWAP_ACTIVATING_DONE: ++ /* There's a control process pending, directly enter kill mode */ ++ swap_enter_signal(s, SWAP_DEACTIVATING_SIGTERM, SWAP_SUCCESS); + return 0; + +- assert(s->state == SWAP_ACTIVATING || +- s->state == SWAP_ACTIVATING_DONE || +- s->state == SWAP_ACTIVE); ++ case SWAP_ACTIVE: ++ if (detect_container(NULL) > 0) ++ return -EPERM; + +- if (detect_container(NULL) > 0) +- return -EPERM; ++ swap_enter_deactivating(s); ++ return 1; + +- swap_enter_deactivating(s); +- return 1; ++ default: ++ assert_not_reached("Unexpected state."); ++ } + } + + static int swap_serialize(Unit *u, FILE *f, FDSet *fds) { +@@ -1002,10 +1009,8 @@ static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) { + + case SWAP_ACTIVATING: + case SWAP_ACTIVATING_DONE: +- case SWAP_ACTIVATING_SIGTERM: +- case SWAP_ACTIVATING_SIGKILL: + +- if (f == SWAP_SUCCESS) ++ if (f == SWAP_SUCCESS || s->from_proc_swaps) + swap_enter_active(s, f); + else + swap_enter_dead(s, f); +@@ -1015,7 +1020,7 @@ static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) { + case SWAP_DEACTIVATING_SIGKILL: + case SWAP_DEACTIVATING_SIGTERM: + +- swap_enter_dead(s, f); ++ swap_enter_dead_or_active(s, f); + break; + + default: +@@ -1037,7 +1042,7 @@ static int swap_dispatch_timer(sd_event_source *source, usec_t usec, void *userd + case SWAP_ACTIVATING: + case SWAP_ACTIVATING_DONE: + log_unit_warning(UNIT(s)->id, "%s activation timed out. Stopping.", UNIT(s)->id); +- swap_enter_signal(s, SWAP_ACTIVATING_SIGTERM, SWAP_FAILURE_TIMEOUT); ++ swap_enter_signal(s, SWAP_DEACTIVATING_SIGTERM, SWAP_FAILURE_TIMEOUT); + break; + + case SWAP_DEACTIVATING: +@@ -1045,30 +1050,19 @@ static int swap_dispatch_timer(sd_event_source *source, usec_t usec, void *userd + swap_enter_signal(s, SWAP_DEACTIVATING_SIGTERM, SWAP_FAILURE_TIMEOUT); + break; + +- case SWAP_ACTIVATING_SIGTERM: +- if (s->kill_context.send_sigkill) { +- log_unit_warning(UNIT(s)->id, "%s activation timed out. Killing.", UNIT(s)->id); +- swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, SWAP_FAILURE_TIMEOUT); +- } else { +- log_unit_warning(UNIT(s)->id, "%s activation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id); +- swap_enter_dead(s, SWAP_FAILURE_TIMEOUT); +- } +- break; +- + case SWAP_DEACTIVATING_SIGTERM: + if (s->kill_context.send_sigkill) { +- log_unit_warning(UNIT(s)->id, "%s deactivation timed out. Killing.", UNIT(s)->id); ++ log_unit_warning(UNIT(s)->id, "Swap process timed out. Killing."); + swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, SWAP_FAILURE_TIMEOUT); + } else { +- log_unit_warning(UNIT(s)->id, "%s deactivation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id); +- swap_enter_dead(s, SWAP_FAILURE_TIMEOUT); ++ log_unit_warning(UNIT(s)->id, "Swap process timed out. Skipping SIGKILL. Ignoring."); ++ swap_enter_dead_or_active(s, SWAP_FAILURE_TIMEOUT); + } + break; + +- case SWAP_ACTIVATING_SIGKILL: + case SWAP_DEACTIVATING_SIGKILL: + log_unit_warning(UNIT(s)->id, "%s swap process still around after SIGKILL. Ignoring.", UNIT(s)->id); +- swap_enter_dead(s, SWAP_FAILURE_TIMEOUT); ++ swap_enter_dead_or_active(s, SWAP_FAILURE_TIMEOUT); + break; + + default: +@@ -1428,8 +1422,6 @@ static const char* const swap_state_table[_SWAP_STATE_MAX] = { + [SWAP_ACTIVATING_DONE] = "activating-done", + [SWAP_ACTIVE] = "active", + [SWAP_DEACTIVATING] = "deactivating", +- [SWAP_ACTIVATING_SIGTERM] = "activating-sigterm", +- [SWAP_ACTIVATING_SIGKILL] = "activating-sigkill", + [SWAP_DEACTIVATING_SIGTERM] = "deactivating-sigterm", + [SWAP_DEACTIVATING_SIGKILL] = "deactivating-sigkill", + [SWAP_FAILED] = "failed" +diff --git a/src/core/swap.h b/src/core/swap.h +index 914a2dbccd..f46873b5e1 100644 +--- a/src/core/swap.h ++++ b/src/core/swap.h +@@ -34,8 +34,6 @@ typedef enum SwapState { + SWAP_ACTIVATING_DONE, /* /sbin/swapon is running, and the swap is done. */ + SWAP_ACTIVE, + SWAP_DEACTIVATING, +- SWAP_ACTIVATING_SIGTERM, +- SWAP_ACTIVATING_SIGKILL, + SWAP_DEACTIVATING_SIGTERM, + SWAP_DEACTIVATING_SIGKILL, + SWAP_FAILED, diff --git a/SOURCES/0817-swap-finish-the-secondary-swap-units-jobs-if-deactiv.patch b/SOURCES/0817-swap-finish-the-secondary-swap-units-jobs-if-deactiv.patch new file mode 100644 index 0000000..4c1fbc3 --- /dev/null +++ b/SOURCES/0817-swap-finish-the-secondary-swap-units-jobs-if-deactiv.patch @@ -0,0 +1,80 @@ +From 8877bffec31185b58ffa867d59ae0da213fae080 Mon Sep 17 00:00:00 2001 +From: HATAYAMA Daisuke +Date: Wed, 24 Jul 2019 23:54:48 -0400 +Subject: [PATCH] swap: finish the secondary swap units' jobs if deactivation + of the primary swap unit fails + +Currently, if deactivation of the primary swap unit fails: + + # LANG=C systemctl --no-pager stop dev-mapper-fedora\\x2dswap.swap + Job for dev-mapper-fedora\x2dswap.swap failed. + See "systemctl status "dev-mapper-fedora\\x2dswap.swap"" and "journalctl -xe" for details. + +then there are still the running stop jobs for all the secondary swap units +that follow the primary one: + + # systemctl list-jobs + JOB UNIT TYPE STATE + 3233 dev-disk-by\x2duuid-2dc8b9b1\x2da0a5\x2d44d8\x2d89c4\x2d6cdd26cd5ce0.swap stop running + 3232 dev-dm\x2d1.swap stop running + 3231 dev-disk-by\x2did-dm\x2duuid\x2dLVM\x2dyuXWpCCIurGzz2nkGCVnUFSi7GH6E3ZcQjkKLnF0Fil0RJmhoLN8fcOnDybWCMTj.swap stop running + 3230 dev-disk-by\x2did-dm\x2dname\x2dfedora\x2dswap.swap stop running + 3234 dev-fedora-swap.swap stop running + + 5 jobs listed. + +This remains endlessly because their JobTimeoutUSec is infinity: + + # LANG=C systemctl show -p JobTimeoutUSec dev-fedora-swap.swap + JobTimeoutUSec=infinity + +If this issue happens during system shutdown, the system shutdown appears to +get hang and the system will be forcibly shutdown or rebooted 30 minutes later +by the following configuration: + + # grep -E "^JobTimeout" /usr/lib/systemd/system/reboot.target + JobTimeoutSec=30min + JobTimeoutAction=reboot-force + +The scenario in the real world seems that there is some service unit with +KillMode=none, processes whose memory is being swapped out are not killed +during stop operation in the service unit and then swapoff command fails. + +On the other hand, it works well in successful case of swapoff command because +the secondary jobs monitor /proc/swaps file and can detect deletion of the +corresponding swap file. + +This commit fixes the issue by finishing the secondary swap units' jobs if +deactivation of the primary swap unit fails. + +Fixes: #11577 +(cherry picked from commit 9c1f969d40f84d5cc98d810bab8b24148b2d8928) +(cherry picked from commit 1e5b6b9930db88c3a5fb464bad13853885ea82f1) + +Resolves: #1821261 +--- + src/core/swap.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/src/core/swap.c b/src/core/swap.c +index c9cce3d945..ff27936142 100644 +--- a/src/core/swap.c ++++ b/src/core/swap.c +@@ -679,9 +679,15 @@ static void swap_enter_active(Swap *s, SwapResult f) { + static void swap_enter_dead_or_active(Swap *s, SwapResult f) { + assert(s); + +- if (s->from_proc_swaps) ++ if (s->from_proc_swaps) { ++ Swap *other; ++ + swap_enter_active(s, f); +- else ++ ++ LIST_FOREACH_OTHERS(same_devnode, other, s) ++ if (UNIT(other)->job) ++ swap_enter_dead_or_active(other, f); ++ } else + swap_enter_dead(s, f); + } + diff --git a/SOURCES/9999-Update-kernel-install-script-by-backporting-fedora-p.patch b/SOURCES/9999-Update-kernel-install-script-by-backporting-fedora-p.patch deleted file mode 100644 index c42f0b6..0000000 --- a/SOURCES/9999-Update-kernel-install-script-by-backporting-fedora-p.patch +++ /dev/null @@ -1,57 +0,0 @@ -From c49c37d5e26bf71a97d5194d390f80d3e71758e1 Mon Sep 17 00:00:00 2001 -From: systemd team -Date: Tue, 23 Apr 2019 10:46:19 -0300 -Subject: [PATCH] Update kernel-install script by backporting fedora patches - ---- - src/kernel-install/kernel-install | 30 +++++++++++++++++------------- - 1 file changed, 17 insertions(+), 13 deletions(-) - -diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install -index f1c74de..d860701 100755 ---- a/src/kernel-install/kernel-install -+++ b/src/kernel-install/kernel-install -@@ -73,23 +73,27 @@ KERNEL_IMAGE="$2" - - if [[ -x /sbin/new-kernel-pkg ]]; then - KERNEL_DIR="${KERNEL_IMAGE%/*}" -- if [[ "${KERNEL_DIR}" != "/boot" ]]; then -- for i in \ -- "$KERNEL_IMAGE" \ -- "$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac" \ -- "$KERNEL_DIR"/System.map \ -- "$KERNEL_DIR"/config \ -- "$KERNEL_DIR"/zImage.stub \ -- "$KERNEL_DIR"/dtb \ -- ; do -- [[ -e "$i" ]] || continue -- cp -a "$i" "/boot/${i##*/}-${KERNEL_VERSION}" -- done -- fi - - [[ "$KERNEL_VERSION" == *\+* ]] && flavor=-"${KERNEL_VERSION##*+}" - case "$COMMAND" in - add) -+ if [[ "${KERNEL_DIR}" != "/boot" ]]; then -+ for i in \ -+ "$KERNEL_IMAGE" \ -+ "$KERNEL_DIR"/System.map \ -+ "$KERNEL_DIR"/config \ -+ "$KERNEL_DIR"/zImage.stub \ -+ "$KERNEL_DIR"/dtb \ -+ ; do -+ [[ -e "$i" ]] || continue -+ cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}" -+ done -+ # hmac is .vmlinuz-.hmac so needs a special treatment -+ i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac" -+ if [[ -e "$i" ]]; then -+ cp -aT "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac" -+ fi -+ fi - /sbin/new-kernel-pkg --package "kernel${flavor}" --install "$KERNEL_VERSION" || exit $? - /sbin/new-kernel-pkg --package "kernel${flavor}" --mkinitrd --dracut --depmod --update "$KERNEL_VERSION" || exit $? - /sbin/new-kernel-pkg --package "kernel${flavor}" --rpmposttrans "$KERNEL_VERSION" || exit $? --- -1.8.3.1 - diff --git a/SPECS/systemd.spec b/SPECS/systemd.spec index 35169ae..805d5a9 100644 --- a/SPECS/systemd.spec +++ b/SPECS/systemd.spec @@ -7,7 +7,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 219 -Release: 73%{?dist}.5 +Release: 73%{?dist}.6 # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: A System and Service Manager @@ -851,8 +851,11 @@ Patch0809: 0809-mount-when-allocating-a-Mount-object-based-on-proc-s.patch Patch0810: 0810-core-enforce-a-ratelimiter-when-stopping-units-due-t.patch Patch0811: 0811-core-rework-StopWhenUnneeded-logic.patch Patch0812: 0812-fix-the-fix-for-1691511.patch - -Patch9999: 9999-Update-kernel-install-script-by-backporting-fedora-p.patch +Patch0813: 0813-sd-bus-when-attached-to-an-sd-event-loop-disconnect-.patch +Patch0814: 0814-sd-journal-close-journal-files-that-were-deleted-by-.patch +Patch0815: 0815-sd-journal-remove-the-dead-code-and-actually-fix-146.patch +Patch0816: 0816-swap-adjust-swap.c-in-a-similar-way-to-what-we-just-.patch +Patch0817: 0817-swap-finish-the-secondary-swap-units-jobs-if-deactiv.patch %global num_patches %{lua: c=0; for i,p in ipairs(patches) do c=c+1; end; print(c);} @@ -1830,6 +1833,13 @@ fi %{_mandir}/man8/systemd-resolved.* %changelog +* Mon Apr 06 2020 systemd maintenance team - 219-73.6 +- sd-bus: when attached to an sd-event loop, disconnect on processing errors (#1817504) +- sd-journal: close journal files that were deleted by journald before we've setup inotify watch (#1820073) +- sd-journal: remove the dead code and actually fix #14695 (#1820073) +- swap: adjust swap.c in a similar way to what we just did to mount.c (#1821261) +- swap: finish the secondary swap units' jobs if deactivation of the primary swap unit fails (#1821261) + * Tue Mar 17 2020 systemd maintenance team - 219-73.5 - core: enforce a ratelimiter when stopping units due to StopWhenUnneeded=1 (#1810576) - core: rework StopWhenUnneeded= logic (#1810576)