Commit ee34a37049114303011e154478c63b977bcff24c

Authored by Barry Song
Committed by Rafael J. Wysocki
1 parent a029db4398

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>

Showing 1 changed file with 7 additions and 6 deletions Side-by-side Diff

... ... @@ -773,8 +773,7 @@
773 773  
774 774 pr_debug("PM: Free swap pages: %u\n", free_swap);
775 775  
776   - required = PAGES_FOR_IO + ((flags & SF_NOCOMPRESS_MODE) ?
777   - nr_pages : (nr_pages * LZO_CMP_PAGES) / LZO_UNC_PAGES + 1);
  776 + required = PAGES_FOR_IO + nr_pages;
778 777 return free_swap > required;
779 778 }
780 779  
... ... @@ -802,10 +801,12 @@
802 801 printk(KERN_ERR "PM: Cannot get swap writer\n");
803 802 return error;
804 803 }
805   - if (!enough_swap(pages, flags)) {
806   - printk(KERN_ERR "PM: Not enough free swap\n");
807   - error = -ENOSPC;
808   - goto out_finish;
  804 + if (flags & SF_NOCOMPRESS_MODE) {
  805 + if (!enough_swap(pages, flags)) {
  806 + printk(KERN_ERR "PM: Not enough free swap\n");
  807 + error = -ENOSPC;
  808 + goto out_finish;
  809 + }
809 810 }
810 811 memset(&snapshot, 0, sizeof(struct snapshot_handle));
811 812 error = snapshot_read_next(&snapshot);