From: NeilBrown Date: Tue, 3 May 2011 05:47:09 +0000 (+1000) Subject: FORMAT CHANGE use crc32 instead of toy checksum for cluster head X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=1564bb35d79bd981605b5b629d8308ebce690007;p=LaFS.git FORMAT CHANGE use crc32 instead of toy checksum for cluster head Signed-off-by: NeilBrown --- diff --git a/cluster.c b/cluster.c index 7ab4043..6233fb8 100644 --- a/cluster.c +++ b/cluster.c @@ -42,6 +42,7 @@ */ #include "lafs.h" +#include #include #include @@ -1073,17 +1074,12 @@ lafs_cluster_update_abort(struct update_handle *uh) int lafs_calc_cluster_csum(struct cluster_head *head) { unsigned int oldcsum = head->checksum; - unsigned long long newcsum = 0; unsigned long csum; - int i; - unsigned int *superc = (unsigned int *) head; - head->checksum = 0; - for (i = 0; i < le16_to_cpu(head->Hlength)/4; i++) - newcsum += le32_to_cpu(superc[i]); - csum = (newcsum & 0xffffffff) + (newcsum>>32); + head->checksum = 0; + csum = crc32_le(0, (unsigned char *)head, le16_to_cpu(head->Hlength)); head->checksum = oldcsum; - return cpu_to_le32(csum); + return csum; } /*------------------------------------------------------------------------