From: Barry Song <Barry.Song@csr.com>
To: rjw@sisk.pl, pavel@ucw.cz
Cc: linux-pm@lists.linux-foundation.org, workgroup.linux@csr.com,
linux-arm-kernel@lists.infradead.org,
Barry Song <Baohua.Song@csr.com>
Subject: [PATCH] PM:Hibernation: drop the check of swap space size for compressed image
Date: Mon, 9 Jan 2012 12:56:23 +0800 [thread overview]
Message-ID: <1326084983-22237-1-git-send-email-Barry.Song@csr.com> (raw)
From: Barry Song <Baohua.Song@csr.com>
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>
---
kernel/power/swap.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 11a594c..c8306a5 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -774,8 +774,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;
}
@@ -803,10 +802,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);
--
1.7.1
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
next reply other threads:[~2012-01-09 4:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-09 4:56 Barry Song [this message]
2012-01-09 10:10 ` [PATCH] PM:Hibernation: drop the check of swap space size for compressed image Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1326084983-22237-1-git-send-email-Barry.Song@csr.com \
--to=barry.song@csr.com \
--cc=Baohua.Song@csr.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
--cc=workgroup.linux@csr.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox