mirror of
https://github.com/systemd/systemd.git
synced 2025-01-07 21:18:41 +03:00
shared/hibernate-util: drop support for kernels lacking /sys/power/resume_offset
The current fallback path is actually unreliable, given the kernel *supports* setting the resume offset through cmdline after all, but just not exposed under /sys/. For v258 let's drop it hence. I didn't bump the baseline to 4.17, but merely documented new requirement in README, because there's certainly more compat stuff to drop between 4.3 and 4.17, and README is a useful list for things to kill. We'll get to 5.4 eventually.
This commit is contained in:
parent
733bc1aee8
commit
de69879b62
2
README
2
README
@ -36,7 +36,7 @@ REQUIREMENTS:
|
||||
≥ 4.10 for cgroup-bpf egress and ingress hooks
|
||||
≥ 4.11 for nsfs
|
||||
≥ 4.15 for cgroup-bpf device hook and cpu controller in cgroup v2
|
||||
≥ 4.17 for cgroup-bpf socket address hooks
|
||||
≥ 4.17 for cgroup-bpf socket address hooks and /sys/power/resume_offset
|
||||
≥ 4.20 for PSI (used by systemd-oomd)
|
||||
≥ 5.2 for cgroup freezer
|
||||
≥ 5.3 for bounded loops in BPF program
|
||||
|
@ -146,19 +146,14 @@ static int read_resume_config(dev_t *ret_devno, uint64_t *ret_offset) {
|
||||
return log_debug_errno(r, "Failed to parse /sys/power/resume devno '%s': %m", devno_str);
|
||||
|
||||
r = read_one_line_file("/sys/power/resume_offset", &offset_str);
|
||||
if (r == -ENOENT) {
|
||||
log_debug_errno(r, "Kernel does not expose resume_offset, skipping.");
|
||||
offset = UINT64_MAX;
|
||||
} else if (r < 0)
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to read /sys/power/resume_offset: %m");
|
||||
else {
|
||||
r = safe_atou64(offset_str, &offset);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r,
|
||||
"Failed to parse /sys/power/resume_offset '%s': %m", offset_str);
|
||||
}
|
||||
|
||||
if (devno == 0 && offset > 0 && offset != UINT64_MAX)
|
||||
r = safe_atou64(offset_str, &offset);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to parse /sys/power/resume_offset '%s': %m", offset_str);
|
||||
|
||||
if (devno == 0 && offset > 0)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENOMEDIUM),
|
||||
"Found populated /sys/power/resume_offset (%" PRIu64 ") but /sys/power/resume is not set, refusing.",
|
||||
offset);
|
||||
@ -375,10 +370,9 @@ int find_suitable_hibernation_device_full(HibernationDevice *ret_device, uint64_
|
||||
|
||||
if (resume_config_devno > 0) {
|
||||
if (swap->devno == resume_config_devno &&
|
||||
(!swap->swapfile || resume_config_offset == UINT64_MAX || swap->offset == resume_config_offset)) {
|
||||
(!swap->swapfile || swap->offset == resume_config_offset)) {
|
||||
/* /sys/power/resume (resume=) is set, and the calculated swap file offset
|
||||
* matches with /sys/power/resume_offset. If /sys/power/resume_offset is not
|
||||
* exposed, we can't do proper check anyway, so use the found swap file too. */
|
||||
* matches with /sys/power/resume_offset. */
|
||||
entry = swap;
|
||||
break;
|
||||
}
|
||||
@ -496,28 +490,16 @@ int write_resume_config(dev_t devno, uint64_t offset, const char *device) {
|
||||
devno_str = FORMAT_DEVNUM(devno);
|
||||
xsprintf(offset_str, "%" PRIu64, offset);
|
||||
|
||||
/* We write the offset first since it's safer. Note that this file is only available in 4.17+, so
|
||||
* fail gracefully if it doesn't exist and we're only overwriting it with 0. */
|
||||
r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
if (r == -ENOENT) {
|
||||
if (offset != 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Can't configure swap file offset %s, kernel does not support /sys/power/resume_offset. Refusing.",
|
||||
offset_str);
|
||||
|
||||
log_warning_errno(r, "/sys/power/resume_offset is unavailable, skipping writing swap file offset.");
|
||||
} else if (r < 0)
|
||||
return log_error_errno(r,
|
||||
"Failed to write swap file offset %s to /sys/power/resume_offset for device '%s': %m",
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to write swap file offset %s to /sys/power/resume_offset for device '%s': %m",
|
||||
offset_str, device);
|
||||
else
|
||||
log_debug("Wrote resume_offset=%s for device '%s' to /sys/power/resume_offset.",
|
||||
offset_str, device);
|
||||
log_debug("Wrote resume_offset=%s for device '%s' to /sys/power/resume_offset.",
|
||||
offset_str, device);
|
||||
|
||||
r = write_string_file("/sys/power/resume", devno_str, WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
if (r < 0)
|
||||
return log_error_errno(r,
|
||||
"Failed to write device '%s' (%s) to /sys/power/resume: %m",
|
||||
return log_error_errno(r, "Failed to write device '%s' (%s) to /sys/power/resume: %m",
|
||||
device, devno_str);
|
||||
log_debug("Wrote resume=%s for device '%s' to /sys/power/resume.", devno_str, device);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user