Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309992
b: refs/heads/master
c: 1db5df9
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro committed May 30, 2012
1 parent 3a88e47 commit 296671c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f6a5690324d5ab9c33bbc0a6b4cc59c7fa34eeec
refs/heads/master: 1db5df98faaf7aa6c25bc7d9703342d13678452a
42 changes: 22 additions & 20 deletions trunk/fs/ocfs2/blockcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,45 +422,46 @@ int ocfs2_block_check_validate(void *data, size_t blocksize,
struct ocfs2_blockcheck_stats *stats)
{
int rc = 0;
struct ocfs2_block_check check;
u32 bc_crc32e;
u16 bc_ecc;
u32 crc, ecc;

ocfs2_blockcheck_inc_check(stats);

check.bc_crc32e = le32_to_cpu(bc->bc_crc32e);
check.bc_ecc = le16_to_cpu(bc->bc_ecc);
bc_crc32e = le32_to_cpu(bc->bc_crc32e);
bc_ecc = le16_to_cpu(bc->bc_ecc);

memset(bc, 0, sizeof(struct ocfs2_block_check));

/* Fast path - if the crc32 validates, we're good to go */
crc = crc32_le(~0, data, blocksize);
if (crc == check.bc_crc32e)
if (crc == bc_crc32e)
goto out;

ocfs2_blockcheck_inc_failure(stats);
mlog(ML_ERROR,
"CRC32 failed: stored: 0x%x, computed 0x%x. Applying ECC.\n",
(unsigned int)check.bc_crc32e, (unsigned int)crc);
(unsigned int)bc_crc32e, (unsigned int)crc);

/* Ok, try ECC fixups */
ecc = ocfs2_hamming_encode_block(data, blocksize);
ocfs2_hamming_fix_block(data, blocksize, ecc ^ check.bc_ecc);
ocfs2_hamming_fix_block(data, blocksize, ecc ^ bc_ecc);

/* And check the crc32 again */
crc = crc32_le(~0, data, blocksize);
if (crc == check.bc_crc32e) {
if (crc == bc_crc32e) {
ocfs2_blockcheck_inc_recover(stats);
goto out;
}

mlog(ML_ERROR, "Fixed CRC32 failed: stored: 0x%x, computed 0x%x\n",
(unsigned int)check.bc_crc32e, (unsigned int)crc);
(unsigned int)bc_crc32e, (unsigned int)crc);

rc = -EIO;

out:
bc->bc_crc32e = cpu_to_le32(check.bc_crc32e);
bc->bc_ecc = cpu_to_le16(check.bc_ecc);
bc->bc_crc32e = cpu_to_le32(bc_crc32e);
bc->bc_ecc = cpu_to_le16(bc_ecc);

return rc;
}
Expand Down Expand Up @@ -528,7 +529,8 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr,
struct ocfs2_blockcheck_stats *stats)
{
int i, rc = 0;
struct ocfs2_block_check check;
u32 bc_crc32e;
u16 bc_ecc;
u32 crc, ecc, fix;

BUG_ON(nr < 0);
Expand All @@ -538,21 +540,21 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr,

ocfs2_blockcheck_inc_check(stats);

check.bc_crc32e = le32_to_cpu(bc->bc_crc32e);
check.bc_ecc = le16_to_cpu(bc->bc_ecc);
bc_crc32e = le32_to_cpu(bc->bc_crc32e);
bc_ecc = le16_to_cpu(bc->bc_ecc);

memset(bc, 0, sizeof(struct ocfs2_block_check));

/* Fast path - if the crc32 validates, we're good to go */
for (i = 0, crc = ~0; i < nr; i++)
crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size);
if (crc == check.bc_crc32e)
if (crc == bc_crc32e)
goto out;

ocfs2_blockcheck_inc_failure(stats);
mlog(ML_ERROR,
"CRC32 failed: stored: %u, computed %u. Applying ECC.\n",
(unsigned int)check.bc_crc32e, (unsigned int)crc);
(unsigned int)bc_crc32e, (unsigned int)crc);

/* Ok, try ECC fixups */
for (i = 0, ecc = 0; i < nr; i++) {
Expand All @@ -565,7 +567,7 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr,
bhs[i]->b_size * 8,
bhs[i]->b_size * 8 * i);
}
fix = ecc ^ check.bc_ecc;
fix = ecc ^ bc_ecc;
for (i = 0; i < nr; i++) {
/*
* Try the fix against each buffer. It will only affect
Expand All @@ -578,19 +580,19 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr,
/* And check the crc32 again */
for (i = 0, crc = ~0; i < nr; i++)
crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size);
if (crc == check.bc_crc32e) {
if (crc == bc_crc32e) {
ocfs2_blockcheck_inc_recover(stats);
goto out;
}

mlog(ML_ERROR, "Fixed CRC32 failed: stored: %u, computed %u\n",
(unsigned int)check.bc_crc32e, (unsigned int)crc);
(unsigned int)bc_crc32e, (unsigned int)crc);

rc = -EIO;

out:
bc->bc_crc32e = cpu_to_le32(check.bc_crc32e);
bc->bc_ecc = cpu_to_le16(check.bc_ecc);
bc->bc_crc32e = cpu_to_le32(bc_crc32e);
bc->bc_ecc = cpu_to_le16(bc_ecc);

return rc;
}
Expand Down

0 comments on commit 296671c

Please sign in to comment.