Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee34a370 authored by Barry Song's avatar Barry Song Committed by Rafael J. Wysocki
Browse files

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: default avatarBarry Song <Baohua.Song@csr.com>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent a029db43
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -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,11 +801,13 @@ int swsusp_write(unsigned int flags)
		printk(KERN_ERR "PM: Cannot get swap writer\n");
		return error;
	}
	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);
	if (error < PAGE_SIZE) {