CuiMingFu / zumastor

Automatically exported from code.google.com/p/zumastor
0 stars 1 forks source link

wrong checksum recorded in commit block #165

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In ddsnapd.c, we calculate each commit block's checksum and record it to
detect journal corruption. But the current code uses only the first
sb->metadata.asi->allocsize_bits bytes instead of the whole block. So it
won't detect any corruption happened at other place in a commit block. We
also got ""corrupt journal block"" error during replay_journal when using a
small chunk size (e.g., 512) because the recorded checksum is outside of
sb->metadata.asi->allocsize_bits bytes.

Here is the proposed fix.

@@ -404,7 +423,7 @@ static int is_commit_block(struct commit
 static u32 checksum_block(struct superblock *sb, u32 *data)
 {
        int i, sum = 0;
-       for (i = 0; i < sb->metadata.asi->allocsize_bits >> 2; i++)
+       for (i = 0; i < 1 << (sb->metadata.asi->allocsize_bits - 2); i++)
                sum += data[i];
        return sum;
 }

Jiaying

Original issue reported on code.google.com by jiahotc...@gmail.com on 11 Jul 2008 at 12:29

GoogleCodeExporter commented 9 years ago
Can you write a cbtb test that exposes this bug?

Original comment by daniel.r...@gmail.com on 11 Jul 2008 at 12:46