diff options
Diffstat (limited to 'fs/ocfs2/blockcheck.c')
-rw-r--r-- | fs/ocfs2/blockcheck.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/fs/ocfs2/blockcheck.c b/fs/ocfs2/blockcheck.c index c7ee03c2222..0725e605465 100644 --- a/fs/ocfs2/blockcheck.c +++ b/fs/ocfs2/blockcheck.c | |||
@@ -422,45 +422,46 @@ int ocfs2_block_check_validate(void *data, size_t blocksize, | |||
422 | struct ocfs2_blockcheck_stats *stats) | 422 | struct ocfs2_blockcheck_stats *stats) |
423 | { | 423 | { |
424 | int rc = 0; | 424 | int rc = 0; |
425 | struct ocfs2_block_check check; | 425 | u32 bc_crc32e; |
426 | u16 bc_ecc; | ||
426 | u32 crc, ecc; | 427 | u32 crc, ecc; |
427 | 428 | ||
428 | ocfs2_blockcheck_inc_check(stats); | 429 | ocfs2_blockcheck_inc_check(stats); |
429 | 430 | ||
430 | check.bc_crc32e = le32_to_cpu(bc->bc_crc32e); | 431 | bc_crc32e = le32_to_cpu(bc->bc_crc32e); |
431 | check.bc_ecc = le16_to_cpu(bc->bc_ecc); | 432 | bc_ecc = le16_to_cpu(bc->bc_ecc); |
432 | 433 | ||
433 | memset(bc, 0, sizeof(struct ocfs2_block_check)); | 434 | memset(bc, 0, sizeof(struct ocfs2_block_check)); |
434 | 435 | ||
435 | /* Fast path - if the crc32 validates, we're good to go */ | 436 | /* Fast path - if the crc32 validates, we're good to go */ |
436 | crc = crc32_le(~0, data, blocksize); | 437 | crc = crc32_le(~0, data, blocksize); |
437 | if (crc == check.bc_crc32e) | 438 | if (crc == bc_crc32e) |
438 | goto out; | 439 | goto out; |
439 | 440 | ||
440 | ocfs2_blockcheck_inc_failure(stats); | 441 | ocfs2_blockcheck_inc_failure(stats); |
441 | mlog(ML_ERROR, | 442 | mlog(ML_ERROR, |
442 | "CRC32 failed: stored: 0x%x, computed 0x%x. Applying ECC.\n", | 443 | "CRC32 failed: stored: 0x%x, computed 0x%x. Applying ECC.\n", |
443 | (unsigned int)check.bc_crc32e, (unsigned int)crc); | 444 | (unsigned int)bc_crc32e, (unsigned int)crc); |
444 | 445 | ||
445 | /* Ok, try ECC fixups */ | 446 | /* Ok, try ECC fixups */ |
446 | ecc = ocfs2_hamming_encode_block(data, blocksize); | 447 | ecc = ocfs2_hamming_encode_block(data, blocksize); |
447 | ocfs2_hamming_fix_block(data, blocksize, ecc ^ check.bc_ecc); | 448 | ocfs2_hamming_fix_block(data, blocksize, ecc ^ bc_ecc); |
448 | 449 | ||
449 | /* And check the crc32 again */ | 450 | /* And check the crc32 again */ |
450 | crc = crc32_le(~0, data, blocksize); | 451 | crc = crc32_le(~0, data, blocksize); |
451 | if (crc == check.bc_crc32e) { | 452 | if (crc == bc_crc32e) { |
452 | ocfs2_blockcheck_inc_recover(stats); | 453 | ocfs2_blockcheck_inc_recover(stats); |
453 | goto out; | 454 | goto out; |
454 | } | 455 | } |
455 | 456 | ||
456 | mlog(ML_ERROR, "Fixed CRC32 failed: stored: 0x%x, computed 0x%x\n", | 457 | mlog(ML_ERROR, "Fixed CRC32 failed: stored: 0x%x, computed 0x%x\n", |
457 | (unsigned int)check.bc_crc32e, (unsigned int)crc); | 458 | (unsigned int)bc_crc32e, (unsigned int)crc); |
458 | 459 | ||
459 | rc = -EIO; | 460 | rc = -EIO; |
460 | 461 | ||
461 | out: | 462 | out: |
462 | bc->bc_crc32e = cpu_to_le32(check.bc_crc32e); | 463 | bc->bc_crc32e = cpu_to_le32(bc_crc32e); |
463 | bc->bc_ecc = cpu_to_le16(check.bc_ecc); | 464 | bc->bc_ecc = cpu_to_le16(bc_ecc); |
464 | 465 | ||
465 | return rc; | 466 | return rc; |
466 | } | 467 | } |
@@ -528,7 +529,8 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr, | |||
528 | struct ocfs2_blockcheck_stats *stats) | 529 | struct ocfs2_blockcheck_stats *stats) |
529 | { | 530 | { |
530 | int i, rc = 0; | 531 | int i, rc = 0; |
531 | struct ocfs2_block_check check; | 532 | u32 bc_crc32e; |
533 | u16 bc_ecc; | ||
532 | u32 crc, ecc, fix; | 534 | u32 crc, ecc, fix; |
533 | 535 | ||
534 | BUG_ON(nr < 0); | 536 | BUG_ON(nr < 0); |
@@ -538,21 +540,21 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr, | |||
538 | 540 | ||
539 | ocfs2_blockcheck_inc_check(stats); | 541 | ocfs2_blockcheck_inc_check(stats); |
540 | 542 | ||
541 | check.bc_crc32e = le32_to_cpu(bc->bc_crc32e); | 543 | bc_crc32e = le32_to_cpu(bc->bc_crc32e); |
542 | check.bc_ecc = le16_to_cpu(bc->bc_ecc); | 544 | bc_ecc = le16_to_cpu(bc->bc_ecc); |
543 | 545 | ||
544 | memset(bc, 0, sizeof(struct ocfs2_block_check)); | 546 | memset(bc, 0, sizeof(struct ocfs2_block_check)); |
545 | 547 | ||
546 | /* Fast path - if the crc32 validates, we're good to go */ | 548 | /* Fast path - if the crc32 validates, we're good to go */ |
547 | for (i = 0, crc = ~0; i < nr; i++) | 549 | for (i = 0, crc = ~0; i < nr; i++) |
548 | crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); | 550 | crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); |
549 | if (crc == check.bc_crc32e) | 551 | if (crc == bc_crc32e) |
550 | goto out; | 552 | goto out; |
551 | 553 | ||
552 | ocfs2_blockcheck_inc_failure(stats); | 554 | ocfs2_blockcheck_inc_failure(stats); |
553 | mlog(ML_ERROR, | 555 | mlog(ML_ERROR, |
554 | "CRC32 failed: stored: %u, computed %u. Applying ECC.\n", | 556 | "CRC32 failed: stored: %u, computed %u. Applying ECC.\n", |
555 | (unsigned int)check.bc_crc32e, (unsigned int)crc); | 557 | (unsigned int)bc_crc32e, (unsigned int)crc); |
556 | 558 | ||
557 | /* Ok, try ECC fixups */ | 559 | /* Ok, try ECC fixups */ |
558 | for (i = 0, ecc = 0; i < nr; i++) { | 560 | for (i = 0, ecc = 0; i < nr; i++) { |
@@ -565,7 +567,7 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr, | |||
565 | bhs[i]->b_size * 8, | 567 | bhs[i]->b_size * 8, |
566 | bhs[i]->b_size * 8 * i); | 568 | bhs[i]->b_size * 8 * i); |
567 | } | 569 | } |
568 | fix = ecc ^ check.bc_ecc; | 570 | fix = ecc ^ bc_ecc; |
569 | for (i = 0; i < nr; i++) { | 571 | for (i = 0; i < nr; i++) { |
570 | /* | 572 | /* |
571 | * Try the fix against each buffer. It will only affect | 573 | * Try the fix against each buffer. It will only affect |
@@ -578,19 +580,19 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr, | |||
578 | /* And check the crc32 again */ | 580 | /* And check the crc32 again */ |
579 | for (i = 0, crc = ~0; i < nr; i++) | 581 | for (i = 0, crc = ~0; i < nr; i++) |
580 | crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); | 582 | crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); |
581 | if (crc == check.bc_crc32e) { | 583 | if (crc == bc_crc32e) { |
582 | ocfs2_blockcheck_inc_recover(stats); | 584 | ocfs2_blockcheck_inc_recover(stats); |
583 | goto out; | 585 | goto out; |
584 | } | 586 | } |
585 | 587 | ||
586 | mlog(ML_ERROR, "Fixed CRC32 failed: stored: %u, computed %u\n", | 588 | mlog(ML_ERROR, "Fixed CRC32 failed: stored: %u, computed %u\n", |
587 | (unsigned int)check.bc_crc32e, (unsigned int)crc); | 589 | (unsigned int)bc_crc32e, (unsigned int)crc); |
588 | 590 | ||
589 | rc = -EIO; | 591 | rc = -EIO; |
590 | 592 | ||
591 | out: | 593 | out: |
592 | bc->bc_crc32e = cpu_to_le32(check.bc_crc32e); | 594 | bc->bc_crc32e = cpu_to_le32(bc_crc32e); |
593 | bc->bc_ecc = cpu_to_le16(check.bc_ecc); | 595 | bc->bc_ecc = cpu_to_le16(bc_ecc); |
594 | 596 | ||
595 | return rc; | 597 | return rc; |
596 | } | 598 | } |