public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: Maksim Fomin <maxim@fomin.one>,
	Chris Murphy <lists@colorremedies.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: Hibernation into swap file
Date: Thu, 9 May 2019 09:13:20 +0300	[thread overview]
Message-ID: <60258f5c-e78e-da10-fa19-29038803e160@gmail.com> (raw)
In-Reply-To: <BbXmRr84cUaKIXCRo64oHylITD5VfRS5r1IeI3r2kNC-6gMrgJTyTU8MriZHfFwCilQBXXUNfQ3G3dcFxLs6FyP1KnjkcCsmVh3xZmAdR9Q=@fomin.one>

06.05.2019 21:25, Maksim Fomin пишет:
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Monday, 6 May 2019 г., 8:40, Chris Murphy <lists@colorremedies.com> wrote:
> 
>> On Sun, May 5, 2019 at 3:09 AM Andrei Borzenkov arvidjaar@gmail.com wrote:
>>
>>> 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.
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/power/swsusp-and-swap-files.txt?h=v5.0.13
>>
>> This says the resume_offset= is an "offset, in <PAGE_SIZE> units,
>> from the beginning of the partition which holds the swap file"
>>
>> Use filefrag (uses FIEMAP) to get the virtual address, multiply by
>> 4KIB to get bytes, and plug that into
>>
>> btrfs-map-logical -l vaddrbyte <dev>
>>
>> The physical number returned is also in bytes. Normally to get LBA
>> you'd divide by 512 (for anything other than a 4Kn drive), but if I
>> understand the kernel document correctly, it needs to be in x86_64
>> page size, so divide by 4096 instead.
>>
>>
>>
>> Chris Murphy
> 
> Thanks everybody for clarification! After several attempts to create 1-extent file it appears that btrfs can do this only for files around 500-600 MiB which is low for my practical needs. If swap file is increased to 1-1.5 GiB, then there is non-contigous extents problem.

Swap files (also used for hibernation) are not required to be contiguous.

> 
> In any case, since swap file can be (with high probability) moved across filesystem, then 1) offset configuration cannot be stored (should be reconfigured for each hibernation) and 2) there is risk that kernel writes directly to disk at wrong place and will corrupt the filesystem. I don't like this feature.

I think we need to allow at least some amount of trust to developers and
expect that this feature would not be released if it had such an obvious
problem.

Of course bug happens and it surely needs wider testing.

> 
> Best regards,
> Maksim Fomin
> 


  reply	other threads:[~2019-05-09  6:13 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
2019-05-06  5:40   ` Chris Murphy
2019-05-06 18:25     ` Maksim Fomin
2019-05-09  6:13       ` Andrei Borzenkov [this message]
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=60258f5c-e78e-da10-fa19-29038803e160@gmail.com \
    --to=arvidjaar@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@colorremedies.com \
    --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