aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power
diff options
context:
space:
mode:
authorBarry Song <Baohua.Song@csr.com>2012-01-09 12:56:23 +0800
committerRafael J. Wysocki <rjw@sisk.pl>2012-01-14 00:41:37 +0100
commitee34a37049114303011e154478c63b977bcff24c (patch)
treeb33342752535473f07742206395049233579d12b /kernel/power
parenta029db43986e23677498ab4d84bb61b05de83484 (diff)
downloadkernel_goldelico_gta04-ee34a37049114303011e154478c63b977bcff24c.zip
kernel_goldelico_gta04-ee34a37049114303011e154478c63b977bcff24c.tar.gz
kernel_goldelico_gta04-ee34a37049114303011e154478c63b977bcff24c.tar.bz2
PM / Hibernate: Drop the check of swap space size for compressed image
For compressed image, the space required is not known until we finish compressing and writing all pages. This patch drops the check, and if swap space is not enough finally, system can still restore to normal after writing swap fails for compressed images. Signed-off-by: Barry Song <Baohua.Song@csr.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/swap.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 3739ecc..8742fd0 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -773,8 +773,7 @@ static int enough_swap(unsigned int nr_pages, unsigned int flags)
pr_debug("PM: Free swap pages: %u\n", free_swap);
- required = PAGES_FOR_IO + ((flags & SF_NOCOMPRESS_MODE) ?
- nr_pages : (nr_pages * LZO_CMP_PAGES) / LZO_UNC_PAGES + 1);
+ required = PAGES_FOR_IO + nr_pages;
return free_swap > required;
}
@@ -802,10 +801,12 @@ int swsusp_write(unsigned int flags)
printk(KERN_ERR "PM: Cannot get swap writer\n");
return error;
}
- if (!enough_swap(pages, flags)) {
- printk(KERN_ERR "PM: Not enough free swap\n");
- error = -ENOSPC;
- goto out_finish;
+ if (flags & SF_NOCOMPRESS_MODE) {
+ if (!enough_swap(pages, flags)) {
+ printk(KERN_ERR "PM: Not enough free swap\n");
+ error = -ENOSPC;
+ goto out_finish;
+ }
}
memset(&snapshot, 0, sizeof(struct snapshot_handle));
error = snapshot_read_next(&snapshot);