linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: Maksim Fomin <maxim@fomin.one>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: Hibernation into swap file
Date: Sun, 5 May 2019 12:08:57 +0300	[thread overview]
Message-ID: <596643ce-64f8-121f-3319-676e58d700e7@gmail.com> (raw)
In-Reply-To: <aeo6MlQ5-4Bg33XbJZWCvdhKuo0Cgca_eNE4xv7rqzCzgvyxG-cobpf8R3bGdh6VT2LLPcXlZu69EyL_rV8K7gRLQ4HtYIyXnWCWb3zR6UM=@fomin.one>

05.05.2019 10:50, Maksim Fomin пишет:
> Good day.
> 
> Since 5.0 btrfs supports swap files. Does it support hibernation into
> a swap file?
> 
> With kernel version 5.0.10 (archlinux) and btrfs-progs 4.20.2
> (unlikely to be relevant, but still) when I try to hibernate with
> systemctl or by directly manipulating '/sys/power/resume' and
> '/sys/power/resume_offset', the kernel logs:
> 
> PM: Cannot find swap device, try swapon -a PM: Cannot get swap
> writer
> 

How exactly do you compute resume_offset? What are exact commands you
ise to initiate hibernation? systemctl will likely not work anyway as
systemd is using FIEMAP which returns logical offset of file extents in
btrfs address space, not physical offset on containing device. You will
need to jump from extent vaddr to device offset manually.

> After digging into this issue I suspect that currently btrfs does not
> support hibernation into swap file (or does it?). Furthermore, I
> suspect that kernel mechanism of accessing swap file via
> 'resume_offset' is unreliable in btrfs case because it is more likely
> (comparing to other fs) to move files across filesystem which
> invalidates swap file offset, so the whole idea is dubious. So,
> 
> 1) does btrfs supports hibernation into swap file? 2) is there
> mechanism to lock swap file?
> 

btrfs performs some checks before allowing file as swap and it also
implicitly locks it during swap usage. Note that btrfs will disable
snapshots of subvolume with swapfile.

File also must be using single allocation profile. There is no way to
force allocation profile for individual file I am aware of in case
filesytem defaults to something else. Also for multi-device btrfs I am
not aware of any way to force allocation of file on specific physical
device, and this is required to use file as swap on btrfs. So you are
likely restricted to single device single data profile.

Finally you are not allowed to mount any filesystem read-write (or
replay any pending log/journal) before doing resume. Does btrfs support
"true" read-only mount, which is guaranteed to not change filesystem
state in any way?


  reply	other threads:[~2019-05-05  9:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-05  7:50 Hibernation into swap file Maksim Fomin
2019-05-05  9:08 ` Andrei Borzenkov [this message]
2019-05-06  5:40   ` Chris Murphy
2019-05-06 18:25     ` Maksim Fomin
2019-05-09  6:13       ` Andrei Borzenkov
2019-05-09 17:04         ` Maksim Fomin
2019-05-06 11:32 ` David Sterba
2020-01-23 17:20   ` Chris Murphy
2020-01-24  4:03     ` Andrei Borzenkov
2020-01-27 19:25     ` Omar Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=596643ce-64f8-121f-3319-676e58d700e7@gmail.com \
    --to=arvidjaar@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=maxim@fomin.one \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).