From 2c2cd24b4bd01c1ed79104c87d829768e61f41e2 Mon Sep 17 00:00:00 2001 From: Nigel Cunningham Date: Tue, 1 May 2007 14:17:15 +1000 Subject: [PATCH] [Suspend2] Fix checksumming support. Revert modifications unintentionally backported to 2.6.18 which break checksumming. Signed-off-by: Nigel Cunningham --- kernel/power/checksum.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/kernel/power/checksum.c b/kernel/power/checksum.c index b9267c04be8..dcb6a5f8f80 100644 --- a/kernel/power/checksum.c +++ b/kernel/power/checksum.c @@ -35,8 +35,7 @@ static char suspend_checksum_name[32] = "md5"; #define CHECKSUMS_PER_PAGE ((PAGE_SIZE - sizeof(void *)) / CHECKSUM_SIZE) -static struct crypto_hash *suspend_checksum_transform; -static struct hash_desc desc; +static struct crypto_tfm *suspend_checksum_transform; static int pages_allocated; static unsigned long page_list; @@ -58,9 +57,8 @@ static int suspend_num_resaved = 0; static void suspend_checksum_cleanup(int ending_cycle) { if (ending_cycle && suspend_checksum_transform) { - crypto_free_hash(suspend_checksum_transform); + crypto_free_tfm(suspend_checksum_transform); suspend_checksum_transform = NULL; - desc.tfm = NULL; } } @@ -81,7 +79,7 @@ static int suspend_checksum_prepare(int starting_cycle) return 1; } - suspend_checksum_transform = crypto_alloc_hash(suspend_checksum_name, 0, 0); + suspend_checksum_transform = crypto_alloc_tfm(suspend_checksum_name, 0); if (IS_ERR(suspend_checksum_transform)) { printk("Suspend2: Failed to initialise the %s checksum algorithm: %ld.\n", suspend_checksum_name, @@ -90,9 +88,6 @@ static int suspend_checksum_prepare(int starting_cycle) return 1; } - desc.tfm = suspend_checksum_transform; - desc.flags = 0; - return 0; } @@ -293,7 +288,6 @@ void calculate_check_checksums(int check) suspend_num_resaved = 0; BITMAP_FOR_EACH_SET(pageset2_map, pfn) { - int ret; if (index % CHECKSUMS_PER_PAGE) { this_checksum += CHECKSUM_SIZE; } else { @@ -302,9 +296,10 @@ void calculate_check_checksums(int check) } PRINTK("Put checksum for page %3d %p in %lx.\n", index, page_address(pfn_to_page(pfn)), this_checksum); sg_set_buf(&sg[0], page_address(pfn_to_page(pfn)), PAGE_SIZE); + crypto_digest_init(suspend_checksum_transform); if (check) { - ret = crypto_hash_digest(&desc, sg, - PAGE_SIZE, current_checksum); + crypto_digest_update(suspend_checksum_transform, sg, 1); + crypto_digest_final(suspend_checksum_transform, current_checksum); if (memcmp(current_checksum, (char *) this_checksum, CHECKSUM_SIZE)) { SetPageResave(pfn_to_page(pfn)); printk("Page %d changed. Saving in atomic copy." @@ -315,12 +310,9 @@ void calculate_check_checksums(int check) if (test_action_state(SUSPEND_ABORT_ON_RESAVE_NEEDED)) set_result_state(SUSPEND_ABORTED); } - } else - ret = crypto_hash_digest(&desc, sg, - PAGE_SIZE, (char *) this_checksum); - if (ret) { - printk("Digest failed. Returned %d.\n", ret); - return; + } else { + crypto_digest_update(suspend_checksum_transform, sg, 1); + crypto_digest_final(suspend_checksum_transform, (char *) this_checksum); } index++; } -- 2.11.4.GIT