diff mbox series

[RFC,12/12] PM / hibernate: update the resume offset on SNAPSHOT_SET_SWAP_AREA

Message ID 20180612205619.28156-13-anchalag@amazon.com
State RFC, archived
Delegated to: David Miller
Headers show
Series Enable PM hibernation on guest VMs | expand

Commit Message

Anchal Agarwal June 12, 2018, 8:56 p.m. UTC
From: Aleksei Besogonov <cyberax@amazon.com>

The SNAPSHOT_SET_SWAP_AREA is supposed to be used to set the hibernation
offset on a running kernel to enable hibernating to a swap file.
However, it doesn't actually update the swsusp_resume_block variable. As
a result, the hibernation fails at the last step (after all the data is
written out) in the validation of the swap signature in
mark_swapfiles().

Before this patch, the command line processing was the only place where
swsusp_resume_block was set.

Signed-off-by: Aleksei Besogonov <cyberax@amazon.com>
Signed-off-by: Munehisa Kamata <kamatam@amazon.com>
Signed-off-by: Anchal Agarwal <anchalag@amazon.com>
Reviewed-by: Munehisa Kamata <kamatam@amazon.com>
Reviewed-by: Eduardo Valentin <eduval@amazon.com>
---
 kernel/power/user.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Pavel Machek June 14, 2018, 7:45 p.m. UTC | #1
Hi!

> From: Aleksei Besogonov <cyberax@amazon.com>
> 
> The SNAPSHOT_SET_SWAP_AREA is supposed to be used to set the hibernation
> offset on a running kernel to enable hibernating to a swap file.
> However, it doesn't actually update the swsusp_resume_block variable. As
> a result, the hibernation fails at the last step (after all the data is
> written out) in the validation of the swap signature in
> mark_swapfiles().
> 
> Before this patch, the command line processing was the only place where
> swsusp_resume_block was set.

Are you saying that suspend-to-file was broken, even on
non-virtualized systems?

If so, we may this to go in first...
								Pavel
Besogonov, Aleksei June 14, 2018, 7:50 p.m. UTC | #2
(sorry for top-posting)

Well, not completely broken. It just required a restart for the offset setting to take an effect.

On 6/14/18, 12:46, "Pavel Machek" <pavel@ucw.cz> wrote:

    Hi!
    
    > From: Aleksei Besogonov <cyberax@amazon.com>
    > 
    > The SNAPSHOT_SET_SWAP_AREA is supposed to be used to set the hibernation
    > offset on a running kernel to enable hibernating to a swap file.
    > However, it doesn't actually update the swsusp_resume_block variable. As
    > a result, the hibernation fails at the last step (after all the data is
    > written out) in the validation of the swap signature in
    > mark_swapfiles().
    > 
    > Before this patch, the command line processing was the only place where
    > swsusp_resume_block was set.
    
    Are you saying that suspend-to-file was broken, even on
    non-virtualized systems?
    
    If so, we may this to go in first...
    								Pavel
    								
    -- 
    (english) http://www.livejournal.com/~pavelmachek
    (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
diff mbox series

Patch

diff --git a/kernel/power/user.c b/kernel/power/user.c
index abd2255..b522a42 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -379,8 +379,12 @@  static long snapshot_ioctl(struct file *filp, unsigned int cmd,
 			if (swdev) {
 				offset = swap_area.offset;
 				data->swap = swap_type_of(swdev, offset, NULL);
-				if (data->swap < 0)
+				if (data->swap < 0) {
 					error = -ENODEV;
+				} else {
+					swsusp_resume_device = swdev;
+					swsusp_resume_block = offset;
+				}
 			} else {
 				data->swap = -1;
 				error = -EINVAL;