From: Askar Safin <safinaskar@gmail.com>
To: mpatocka@redhat.com
Cc: Dell.Client.Kernel@dell.com, agk@redhat.com, brauner@kernel.org,
dm-devel@lists.linux.dev, ebiggers@kernel.org, kix@kix.es,
linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org,
linux-crypto@vger.kernel.org, linux-lvm@lists.linux.dev,
linux-mm@kvack.org, linux-pm@vger.kernel.org,
linux-raid@vger.kernel.org, lvm-devel@lists.linux.dev,
milan@mazyland.cz, msnitzer@redhat.com, mzxreary@0pointer.de,
nphamcs@gmail.com, pavel@ucw.cz, rafael@kernel.org,
ryncsn@gmail.com, torvalds@linux-foundation.org
Subject: Re: [RFC PATCH 2/2] swsusp: make it possible to hibernate to device mapper devices
Date: Wed, 14 Jan 2026 10:27:05 +0300 [thread overview]
Message-ID: <20260114072705.2798057-1-safinaskar@gmail.com> (raw)
In-Reply-To: <b32d0701-4399-9c5d-ecc8-071162df97a7@redhat.com>
Mikulas Patocka <mpatocka@redhat.com>:
> Askar Safin requires swap and hibernation on the dm-integrity device mapper
> target because he needs to protect his data.
Now I see that your approach is valid. (But some small changes are needed.)
[[ TL;DR: you approach is good. I kindly ask you to continue with this patch.
Needed changes are in section "Needed changes". ]]
Let me explain why I initially rejected your patch and why now I think it is good.
= Why I rejected =
In your patch "notify_swap_device" call located before "pm_restrict_gfp_mask".
But "pm_restrict_gfp_mask" is call, which forbids further swapping. I. e.
we still can swap till "pm_restrict_gfp_mask" call!
Thus "notify_swap_device" should be moved after "pm_restrict_gfp_mask" call.
But then I thought about more complex storage hierarchies. For example,
swap on top of some dm device on top of loop device on top of some filesystem
on top of some another dm device, etc.
If we have such hierarchy, then hibernating dm devices should be intertwined
with freezing of filesystems, which happens in "filesystems_freeze" call.
But "filesystems_freeze" call located before "pm_restrict_gfp_mask" call, so
here we got contradiction.
In other words, we should satisfy this 3 things at the same time:
- Hibernating of dm devices should happen inside "filesystems_freeze" call
intermixed with freezing of filesystems
- Hibernating of dm devices should happen after "pm_restrict_gfp_mask" call
- "pm_restrict_gfp_mask" is located after "filesystems_freeze" call in current
kernel
These 3 points obviously contradict to each other.
So in this point I gave up.
The only remaining solution (as I thought at that time) was to move
"filesystems_freeze" after "pm_restrict_gfp_mask" call (or to move
"pm_restrict_gfp_mask" before "filesystems_freeze").
But:
- Freezing of filesystem might require memory. It is bad idea to call
"filesystems_freeze" after we forbid to swap
- This would be pretty big change to the kernel. I'm not sure that my
small use case justifies such change
So in this point I totally gave up.
= Why now I think your patch is good =
But then I found this your email:
https://lore.kernel.org/all/3f3d871a-6a86-354f-f83d-a871793a4a47@redhat.com/ .
And now I see that complex hierarchies, such as described above, are not
supported anyway!
This fully ruins my argument above.
And this means that your patch in fact works!
= Needed changes =
Please, move "notify_swap_device" after "pm_restrict_gfp_mask".
Also: you introduced new operation to target_type: hibernate.
I'm not sure we need this operation, we already have presuspend
and postsuspend. In my personal hacky patch I simply added
"dm_bufio_client_reset" to the end of "dm_integrity_postsuspend",
and it worked. But I'm not sure about this point, i. e. if
you think that we need "hibernate", then go with it.
--
Askar Safin
next prev parent reply other threads:[~2026-01-14 7:27 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 11:29 dm bug: hibernate to swap located on dm-integrity doesn't work (how to get data redundancy for swap?) Askar Safin
2025-10-23 20:42 ` Milan Broz
2025-10-24 16:31 ` Askar Safin
2025-10-24 17:50 ` Milan Broz
2025-10-25 5:26 ` Askar Safin
2025-10-27 8:08 ` Askar Safin
[not found] ` <4cd2d217-f97d-4923-b852-4f8746456704@mazyland.cz>
2025-10-24 10:23 ` [PATCH] pm-hibernate: flush block device cache when hibernating Mikulas Patocka
2025-10-27 8:42 ` Askar Safin
2025-10-31 19:29 ` Mikulas Patocka
2025-10-31 19:33 ` [PATCH 1/2] pm-hibernate: flush disk cache when suspending Mikulas Patocka
2025-11-03 15:53 ` Askar Safin
2025-11-22 13:51 ` Milan Broz
2025-11-22 20:33 ` Askar Safin
2025-11-22 22:47 ` Askar Safin
2025-11-24 19:51 ` Mikulas Patocka
2025-10-31 19:35 ` [RFC PATCH 2/2] swsusp: make it possible to hibernate to device mapper devices Mikulas Patocka
2025-11-30 0:56 ` Askar Safin
2025-12-17 23:18 ` Askar Safin
2025-12-22 15:03 ` Milan Broz
2025-12-22 22:24 ` Askar Safin
2025-12-23 1:41 ` Askar Safin
2025-12-23 5:29 ` Askar Safin
2025-12-23 6:33 ` Askar Safin
2026-01-14 7:27 ` Askar Safin [this message]
2025-10-29 13:31 ` [PATCH] pm-hibernate: flush block device cache when hibernating Rafael J. Wysocki
2025-10-29 14:38 ` Christoph Hellwig
2025-10-29 16:31 ` Mikulas Patocka
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=20260114072705.2798057-1-safinaskar@gmail.com \
--to=safinaskar@gmail.com \
--cc=Dell.Client.Kernel@dell.com \
--cc=agk@redhat.com \
--cc=brauner@kernel.org \
--cc=dm-devel@lists.linux.dev \
--cc=ebiggers@kernel.org \
--cc=kix@kix.es \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-lvm@lists.linux.dev \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=lvm-devel@lists.linux.dev \
--cc=milan@mazyland.cz \
--cc=mpatocka@redhat.com \
--cc=msnitzer@redhat.com \
--cc=mzxreary@0pointer.de \
--cc=nphamcs@gmail.com \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=ryncsn@gmail.com \
--cc=torvalds@linux-foundation.org \
/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