Skip to content

fix(sleep): follow-ups for hibernate-util device handling#70

Open
deepin-ci-robot wants to merge 1 commit into
deepin-community:masterfrom
deepin-ci-robot:backport/fix-sleep-hibernation-device-follow-ups
Open

fix(sleep): follow-ups for hibernate-util device handling#70
deepin-ci-robot wants to merge 1 commit into
deepin-community:masterfrom
deepin-ci-robot:backport/fix-sleep-hibernation-device-follow-ups

Conversation

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

Summary

Backport upstream PR systemd/systemd#30641 with follow-up fixes for hibernate-util:

  • sleep: don't log duplicate errorwrite_resume_config() already logs the error on its own, so remove the duplicate log_error_errno() call in the caller.
  • hibernate-util: use blockdev path for HibernationDevice.path — The path field could spuriously contain the swapfile path instead of the block device path. Now correctly resolves the blockdev path when using a swapfile.
  • hibernate-util: remove unused code — All callers of write_resume_config() now pass non-NULL device, so the NULL fallback code path is removed.

Changes

  • Add debian/patches/fix-sleep-hibernation-device-follow-ups.patch
  • Modify debian/patches/series
  • Modify debian/changelog

Upstream

sleep: don't log duplicate error when write_resume_config() fails
as it already logs the error on its own.

hibernate-util: make sure we use blockdev path for
HibernationDevice.path. Before this, the field could spuriously
contain the path of the swapfile instead of the block device.

hibernate-util: remove unused code in write_resume_config() where
device could be NULL, as all callers now pass non-NULL device.

Changes:
  - Add debian/patches/fix-sleep-hibernation-device-follow-ups.patch
  - Modify debian/patches/series
  - Modify debian/changelog

Upstream: systemd/systemd#30641

Generated-By: glm-5-turbo
Co-Authored-By: deepin-ci-robot <packages@deepin.org>
@github-actions

Copy link
Copy Markdown

TAG Bot

TAG: 255.2-4deepin37
EXISTED: no
DISTRIBUTION: unstable

@deepin-ci-robot

Copy link
Copy Markdown
Contributor Author

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign yukarichiba for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lionheartyu

Copy link
Copy Markdown
Contributor

Patch 1/3 — 修复 swapfile 场景下的设备路径

当休眠使用的是 swapfile(而非swap 分区)时,HibernationDevice.path 之前存的是 swapfile 的文件路径(如 /swapfile),而写入 /sys/power/resume 需要的是底层块设备路径(如 /dev/sda)。补丁在 swapfile 场景下调用 device_path_make_canonical() 将 devno 转换成正确的块设备路径。

Patch 2/3 — 清理 write_resume_config 的冗余代码

Patch 1/3 已经确保传入的 device 参数始终是块设备路径,所以 write_resume_config 里if (!device) 的兜底逻辑不再需要,删掉。同时修复了一个格式化字符串 bug:原来用 %" PRIu64 " 打印 offset(整数),改为打印已格式化好的 offset_str(字符串),错误日志更准确。

Patch 3/3 — 去掉重复的错误日志

write_resume_config() 内部已经会记录错误,调用处再log_error_errno 一次会导致同一个错误打印两遍,删掉外层的重复日志。

对系统的实际影响:使用 swapfile 休眠时,内核/sys/power/resume 能收到正确的块设备路径,休眠恢复才能正常工作;之前可能因路径错误导致唤醒失败。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants