This is _NOT_ a bug. Hibernate is suspend to disk which in other words
is suspend to swap space. And when you boot with resume=<swap_dev> arg.,
it would restore back from swap partition/file.

Its not the same as suspend to ram. In your case, you don't have swap space for 
the kernel to checkpoint the memory pages.
So it bailed out as expected with the error: "Not enough free swap"

File: kernel/power/hibernate.c:
 Function: hibernate:

  if (in_suspend) { => when you are in suspend mode during hibernate
(not restore)

  [...SNIPPED...]
        pr_debug("PM: writing image.\n");
        error = swsusp_write(flags);
        swsusp_free();
        if (!error)
            power_down();
     [...SNIPPED...]
}

So as seen above, swsusp_write is failing for your case with ENOSPC as
you are out of swap. This occurs when swsusp_write checkpoints each of
the memory snapshot to the swap.

File: kernel/power/swap.c:
Function: swsusp_write:
[...snipped...]

  pages = snapshot_get_image_size();
    error = get_swap_writer(&handle);
    if (error) {
        printk(KERN_ERR "PM: Cannot get swap writer\n");
        return error;
    }
    if (!enough_swap(pages)) {
        printk(KERN_ERR "PM: Not enough free swap\n"); ->NOTE
        error = -ENOSPC;
        goto out_finish;
    }
=============================
The memory image to be snapshotted to swap is greater than the available swap. 
If swsusp_write or write of image to swap doesn't fail, then you should have 
hibernated successfully and power_down function should have been invoked by the 
kernel from hibernate routine which won't return as your system would be halted.

But on error, its expected.

I reproduced the problem  pretty easily on my laptop running a 2.6.36-rc8 
compiled kernel on FC12. 
It has nothing to do with Ubuntu.

I already had a swap partition of 8 gig but linux swap management is
excellent and you can easily create and enable/disable swap
files/partitions on the fly.

#  create a swap file of 1 gig for my 4 gig ram

dd if=/dev/zero of=swapfile bs=1M count=1024

# make swap signature

mkswap swapfile

# enable swap file

swapon swapfile

# confirm

cat /proc/swaps # shows 2 swaps for me

# now disable the existing swap partition of 8 gig that I had and fall
back to the 1 gig swap file to try and suspend to disk (hibernate)

swapoff /dev/sda2 # my swap partition of 8 gig

## At this point, my swap is managed by the 1 gig swapfile which would
be insufficient for hibernation. So go for the kill

echo disk >/sys/power/state

## Boom. hibernate fails and dmesg shows the "No free swap" error as
expected that bailed out the hibernate from checkpointing memory to disk

Next I did a resize of the swapfile to 8 gig, and it proceeded.  On
restart of the machine, you can pass: resume=<swapfile> or partition_dev
(/dev/sda2) typically done automatically for the system swap (1 swap
typical) to restore from the checkpointed or hibernated state.

So take a chill pill as its not a bug but a feature :)

Regards,
-Karthick

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/844791

Title:
  Hibernate returns to lock screen on a Lenovo T400 running Ubuntu 11.04

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/844791/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to