Skip to content

systemctl hibernate does not hibernate on swapfile on Btrfs after kernel 5.0 #11939

@helloworld1

Description

@helloworld1

systemd version the issue has been seen with
241.7

Used distribution
Archlinux

Expected behaviour you didn't see
systemctl hibernate should hibernate on swap file on Btrfs after kernel 5.0

Unexpected behaviour you saw
Btrfs supports swapfile after kernel 5.0. echo disk > /sys/power/state works fine to hibernate but systemctl hibernate failed.
Since Btrfs is using virtual physical offset of the file. The current logic in sleep.c does not get the correct physical offset of the file. The resume_offset kernel parameter is also ignored and overriden by systemd so it is unable to get the correct offset.

offset = fiemap->fm_extents[0].fe_physical / page_size();

Steps to reproduce the problem

  1. Create swapfile on btrfs according to man 5 btrfs
  2. Activate swap file in fstab
  3. Calculate the physical offset of swapfile and add kernel parameter
    resume=/dev/nvme1n1p2 resume_offset=52761856
  4. echo disk > /sys/power/state works fine to hibernate
  5. systemctl hibernate failed.
    [ 26.828436] PM: Cannot find swap device, try swapon -a
    [ 26.828441] PM: Cannot get swap writer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions