[Suspend2][ 05/20] [Suspend2] Get the amount of storage needed for the image proper.

Nigel Cunningham
2006-06-26T22:35:23Z

Calculate the amount of storage required for the image proper, possibly
taking into account the expected compression ratio and possibly also
ignoring the extra pagedir1 allowance.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

kernel/power/prepare_image.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/kernel/power/prepare_image.c b/kernel/power/prepare_image.c
index 271f904..9f1eb74 100644
--- a/kernel/power/prepare_image.c
+++ b/kernel/power/prepare_image.c
@@ -107,3 +107,16 @@ static void get_extra_pd1_allowance(void
MIN_EXTRA_PAGES_ALLOWANCE);
}

+/*
+ * Amount of storage needed, possibly taking into account the
+ * expected compression ratio and possibly also ignoring our
+ * allowance for extra pages.
+ */
+static long main_storage_needed(int use_ecr,
+ int ignore_extra_pd1_allow)
+{
+ return ((pagedir1.pageset_size + pagedir2.pageset_size +
+ (ignore_extra_pd1_allow ? 0 : extra_pd1_pages_allowance)) *
+ (use_ecr ? suspend_expected_compression_ratio() : 100) / 100);