PM / hibernate: Add CONFIG_HIBERNATION_IMAGE_REUSE

By default this hibernation image is erased after either a successful or
unsuccessful hibernation restore sequeunce. Since filesystem contents on
disk are not part of the hibernation image, failure to create a new
hibernation image every boot can lead to filesystem corruption.

Conversely, if the usecase can guarantee that the filesystem is not ever
modified, the same hibernation image can be reused. This prevents
creating additional hibernation images unncesarily.

For more details, refer to the description of CONFIG_HIBERNATION for
booting without resuming.

Change-Id: I4a8d5aba170bbf00f837804c2df26d8d8d682af2
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
This commit is contained in:
Patrick Daly 2018-03-27 15:27:27 -07:00
parent 86485b57e2
commit 699bed2294
2 changed files with 19 additions and 0 deletions

View File

@ -77,6 +77,23 @@ config HIBERNATION
For more information take a look at <file:Documentation/power/swsusp.txt>.
config HIBERNATION_IMAGE_REUSE
bool "Reuse hibernation image"
depends on HIBERNATION
---help---
By default this hibernation image is erased after either a
successful or unsuccessful hibernation restore sequeunce. Since
filesystem contents on disk are not part of the hibernation
image, failure to create a new hibernation image every boot can
lead to filesystem corruption.
Conversely, if the usecase can guarantee that the filesystem is
not ever modified, the same hibernation image can be reused. This
prevents creating additional hibernation images unncesarily.
For more details, refer to the description of CONFIG_HIBERNATION
for booting without resuming.
config ARCH_SAVE_PAGE_KEYS
bool

View File

@ -1540,10 +1540,12 @@ int swsusp_check(void)
if (!memcmp(HIBERNATE_SIG, swsusp_header->sig, 10)) {
memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
#ifndef CONFIG_HIBERNATION_IMAGE_REUSE
/* Reset swap signature now */
error = hib_submit_io(REQ_OP_WRITE, REQ_SYNC,
swsusp_resume_block,
swsusp_header, NULL);
#endif
} else {
error = -EINVAL;
}