Skip to content

Commit

Permalink
PM / Hibernate: Drop the check of swap space size for compressed image
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Barry Song authored and Rafael J. Wysocki committed Jan 13, 2012
1 parent a029db4 commit ee34a37
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions kernel/power/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ee34a37

Please sign in to comment.