[Ocfs2-tools-devel] [PATCH 8/8] Fix extent block ECC

Goldwyn Rodrigues rgoldwyn at gmail.com
Mon Aug 1 10:58:57 PDT 2011


Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>
---
 fsck.ocfs2/extent.c               |   14 +++++++++++++-
 fsck.ocfs2/fsck.ocfs2.checks.8.in |    9 +++++++++
 libocfs2/extents.c                |    2 +-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/fsck.ocfs2/extent.c b/fsck.ocfs2/extent.c
index 0075319..7eac0d9 100644
--- a/fsck.ocfs2/extent.c
+++ b/fsck.ocfs2/extent.c
@@ -70,7 +70,19 @@ static errcode_t check_eb(o2fsck_state *ost, struct
extent_info *ei,
 	}

 	ret = ocfs2_read_extent_block_nocheck(ost->ost_fs, blkno, buf);
-	if (ret) {
+	if (ret == OCFS2_ET_BAD_ECC) {
+		if (prompt(ost, PY, PR_EXTENT_BLOCK_INVALID_ECC,
+				"Extent block %"PRIu64" has invalid ECC. "
+				"This means either the ECC is incorrect or"
+				" the extent block is corrupt. Fix ECC?"
+				" Answering \"n\" will invalidate the "
+				"extent block. ", blkno))
+			changed = 1;
+		else {
+			*is_valid = 0;
+			goto out;
+		}
+	} else if (ret) {
 		com_err(whoami, ret, "reading extent block at %"PRIu64" in "
 			"owner %"PRIu64" for verification", blkno, owner);
 		if (ret == OCFS2_ET_BAD_EXTENT_BLOCK_MAGIC)
diff --git a/fsck.ocfs2/fsck.ocfs2.checks.8.in
b/fsck.ocfs2/fsck.ocfs2.checks.8.in
index 21448e5..1e8b6c5 100644
--- a/fsck.ocfs2/fsck.ocfs2.checks.8.in
+++ b/fsck.ocfs2/fsck.ocfs2.checks.8.in
@@ -1155,6 +1155,15 @@ the read operation.
 Answering yes will recalculate the ECC and write the inode with the
 calculated ECC.

+.SS "EXTENT_BLOCK_INVALID_ECC"
+The extent block has incorrect Error Correcting Code (ECC). ECC is capable of
+correcting corruption upto 1 bit per block. Any corruptions higher that this
+may indicate corruption. In this case the filesystem reports an error with
+the read operation.
+
+Answering yes will recalculate the ECC and write the extent block with the
+calculated ECC.
+
 .SH "SEE ALSO"
 .BR fsck.ocfs2(8)

diff --git a/libocfs2/extents.c b/libocfs2/extents.c
index d72ae66..c876f8e 100644
--- a/libocfs2/extents.c
+++ b/libocfs2/extents.c
@@ -136,7 +136,7 @@ errcode_t ocfs2_read_extent_block_nocheck(ocfs2_filesys *fs,
 	eb = (struct ocfs2_extent_block *)blk;

 	ret = ocfs2_validate_meta_ecc(fs, blk, &eb->h_check);
-	if (ret)
+	if (ret && (ret != OCFS2_ET_BAD_ECC))
 		goto out;

 	if (memcmp(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE,
-- 
1.7.6



More information about the Ocfs2-tools-devel mailing list