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>
This commit is contained in:
Barry Song 2012-01-09 12:56:23 +08:00 committed by Rafael J. Wysocki
parent a029db4398
commit ee34a37049

View File

@ -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); pr_debug("PM: Free swap pages: %u\n", free_swap);
required = PAGES_FOR_IO + ((flags & SF_NOCOMPRESS_MODE) ? required = PAGES_FOR_IO + nr_pages;
nr_pages : (nr_pages * LZO_CMP_PAGES) / LZO_UNC_PAGES + 1);
return free_swap > required; return free_swap > required;
} }
@ -802,10 +801,12 @@ int swsusp_write(unsigned int flags)
printk(KERN_ERR "PM: Cannot get swap writer\n"); printk(KERN_ERR "PM: Cannot get swap writer\n");
return error; return error;
} }
if (!enough_swap(pages, flags)) { if (flags & SF_NOCOMPRESS_MODE) {
printk(KERN_ERR "PM: Not enough free swap\n"); if (!enough_swap(pages, flags)) {
error = -ENOSPC; printk(KERN_ERR "PM: Not enough free swap\n");
goto out_finish; error = -ENOSPC;
goto out_finish;
}
} }
memset(&snapshot, 0, sizeof(struct snapshot_handle)); memset(&snapshot, 0, sizeof(struct snapshot_handle));
error = snapshot_read_next(&snapshot); error = snapshot_read_next(&snapshot);