aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2008-06-09 15:01:00 +0000
committerRafael J. Wysocki <rjw@sisk.pl>2008-06-09 15:01:00 +0000
commitd0f2bb44e11295d21807829cc1bc55d8e40f87a4 (patch)
treef298ac3008a34c9cc6bcd3eb181689159ad3a871
parentf971f5be2e4e93bb84af9147f1759f2b9226d6c6 (diff)
downloadsuspend-utils-d0f2bb44e11295d21807829cc1bc55d8e40f87a4.tar.gz
If compression is used and the image is not compressible, we may need to
save more than the image size of data and that should be taken into account when computing handle.swap_needed in write_image().
-rw-r--r--suspend.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/suspend.c b/suspend.c
index 5a6aee9..6ccac78 100644
--- a/suspend.c
+++ b/suspend.c
@@ -975,6 +975,11 @@ static int write_image(int snapshot_fd, int resume_fd)
real_size = image_size;
handle.swap_needed = image_size;
+ if (do_compress) {
+ /* This is necessary in case the image is not compressible */
+ handle.swap_needed += round_up_page_size(
+ (handle.swap_needed >> 4) + 67);
+ }
if (!enough_swap(&handle)) {
fprintf(stderr, "%s: Not enough free swap\n", my_name);
error = -ENOSPC;