Merge pull request #14241 from keszybz/resume-timeout

Bump resume timeout to infinity
This commit is contained in:
Lennart Poettering 2019-12-17 10:34:43 +01:00 committed by GitHub
commit c16782577b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 23 deletions

View file

@ -366,7 +366,7 @@ static int create_disk(
r = generator_write_timeouts(arg_dest, device, name, options, &filtered);
if (r < 0)
return r;
log_warning_errno(r, "Failed to write device timeout drop-in: %m");
if (filtered) {
filtered_escaped = specifier_escape(filtered);
@ -419,11 +419,11 @@ static int create_disk(
return r;
if (!noauto && !nofail) {
r = write_drop_in(arg_dest, dmname, 90, "device-timeout",
"# Automatically generated by systemd-cryptsetup-generator \n\n"
r = write_drop_in(arg_dest, dmname, 40, "device-timeout",
"# Automatically generated by systemd-cryptsetup-generator\n\n"
"[Unit]\nJobTimeoutSec=0");
if (r < 0)
return log_error_errno(r, "Failed to write device drop-in: %m");
log_warning_errno(r, "Failed to write device timeout drop-in: %m");
}
return 0;
@ -650,7 +650,6 @@ static int add_proc_cmdline_devices(void) {
crypto_device *d;
HASHMAP_FOREACH(d, arg_disks, i) {
const char *options;
_cleanup_free_ char *device = NULL;
if (!d->create)
@ -666,14 +665,11 @@ static int add_proc_cmdline_devices(void) {
if (!device)
return log_oom();
if (d->options)
options = d->options;
else if (arg_default_options)
options = arg_default_options;
else
options = "timeout=0";
r = create_disk(d->name, device, d->keyfile ?: arg_default_keyfile, d->keydev, options);
r = create_disk(d->name,
device,
d->keyfile ?: arg_default_keyfile,
d->keydev,
d->options ?: arg_default_options);
if (r < 0)
return r;
}

View file

@ -5,6 +5,7 @@
#include <unistd.h>
#include "alloc-util.h"
#include "dropin.h"
#include "fstab-util.h"
#include "generator.h"
#include "log.h"
@ -68,18 +69,18 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
}
static int process_resume(void) {
_cleanup_free_ char *name = NULL, *lnk = NULL;
const char *opts;
_cleanup_free_ char *service_unit = NULL, *device_unit = NULL, *lnk = NULL;
int r;
if (!arg_resume_device)
return 0;
r = unit_name_from_path_instance("systemd-hibernate-resume", arg_resume_device, ".service", &name);
r = unit_name_from_path_instance("systemd-hibernate-resume", arg_resume_device, ".service",
&service_unit);
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
lnk = strjoin(arg_dest, "/" SPECIAL_SYSINIT_TARGET ".wants/", name);
lnk = strjoin(arg_dest, "/" SPECIAL_SYSINIT_TARGET ".wants/", service_unit);
if (!lnk)
return log_oom();
@ -87,12 +88,21 @@ static int process_resume(void) {
if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-hibernate-resume@.service", lnk) < 0)
return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
if (arg_resume_options)
opts = arg_resume_options;
else
opts = arg_root_options;
r = unit_name_from_path(arg_resume_device, ".device", &device_unit);
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
r = generator_write_timeouts(arg_dest, arg_resume_device, arg_resume_device, opts, NULL);
r = write_drop_in(arg_dest, device_unit, 40, "device-timeout",
"# Automatically generated by systemd-cryptsetup-generator\n\n"
"[Unit]\nJobTimeoutSec=0");
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in: %m");
r = generator_write_timeouts(arg_dest,
arg_resume_device,
arg_resume_device,
arg_resume_options ?: arg_root_options,
NULL);
if (r < 0)
return r;

View file

@ -237,10 +237,12 @@ int generator_write_timeouts(
return log_error_errno(r, "Failed to make unit name from path: %m");
return write_drop_in_format(dir, unit, 50, "device-timeout",
"# Automatically generated by %s\n\n"
"# Automatically generated by %s\n"
"# from supplied options \"%s\"\n\n"
"[Unit]\n"
"JobRunningTimeoutSec=%s",
program_invocation_short_name,
opts,
timeout);
}