]> git.neil.brown.name Git - LaFS.git/commitdiff
FORMAT CHANGE use crc32 instead of toy checksum for cluster head
authorNeilBrown <neilb@suse.de>
Tue, 3 May 2011 05:47:09 +0000 (15:47 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 3 May 2011 05:47:09 +0000 (15:47 +1000)
Signed-off-by: NeilBrown <neilb@suse.de>
cluster.c

index 7ab404311cd6adb9161f829ee9e7ce33b68fd97c..6233fb817e4605c5742b89913fa2113263a849cf 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -42,6 +42,7 @@
  */
 
 #include       "lafs.h"
+#include       <linux/crc32.h>
 #include       <linux/random.h>
 #include       <linux/slab.h>
 
@@ -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;
 }
 
 /*------------------------------------------------------------------------