[Ocfs2-tools-devel] [PATCH 7/8] Mess up extent block ECC
Goldwyn Rodrigues
rgoldwyn at gmail.com
Mon Aug 1 10:58:54 PDT 2011
Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>
---
fswreck/corrupt.c | 3 +++
fswreck/extent.c | 13 +++++++++++--
fswreck/include/fsck_type.h | 1 +
fswreck/main.c | 2 ++
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
index 86c2b47..eac28a0 100644
--- a/fswreck/corrupt.c
+++ b/fswreck/corrupt.c
@@ -71,6 +71,9 @@ void corrupt_file(ocfs2_filesys *fs, enum fsck_type
type, uint16_t slotnum)
case EB_GEN_FIX:
func = mess_up_extent_block;
break;
+ case EB_INVALID_ECC:
+ func = mess_up_extent_block;
+ break;
case EXTENT_EB_INVALID:
func = mess_up_extent_block;
break;
diff --git a/fswreck/extent.c b/fswreck/extent.c
index e36deb9..279ee24 100644
--- a/fswreck/extent.c
+++ b/fswreck/extent.c
@@ -206,12 +206,21 @@ static void damage_extent_block(ocfs2_filesys
*fs, uint64_t blkno,
"change blkno from %d to %d\n",
blkno, oldno, eb->h_list.l_next_free_rec);
break;
+ case EB_INVALID_ECC:
+ eb->h_check.bc_crc32e ^= 15;
+ eb->h_check.bc_ecc ^= 7;
+ fprintf(stdout, "EB_INVALID_ECC: Corrupt "
+ "inode#%"PRIu64", extent block %"
+ PRIu64"\n", blkno,
+ (unsigned long )eb->h_blkno);
+ break;
default:
FSWRK_FATAL("Invalid type=%d", type);
}
- ret = ocfs2_write_extent_block(fs, el->l_recs[0].e_blkno,
- extbuf);
+ ocfs2_swap_extent_block_from_cpu(fs, eb);
+ ret = io_write_block(fs->fs_io, el->l_recs[0].e_blkno, 1,
+ extbuf);
if (ret)
FSWRK_COM_FATAL(progname, ret);
diff --git a/fswreck/include/fsck_type.h b/fswreck/include/fsck_type.h
index a5c3989..bdafa6f 100644
--- a/fswreck/include/fsck_type.h
+++ b/fswreck/include/fsck_type.h
@@ -164,6 +164,7 @@ enum fsck_type
DUP_CLUSTERS_ADD_REFCOUNT,
SUPERBLOCK_INVALID_ECC,
INODE_INVALID_ECC,
+ EB_INVALID_ECC,
NUM_FSCK_TYPE
};
diff --git a/fswreck/main.c b/fswreck/main.c
index 5584459..e2f7258 100644
--- a/fswreck/main.c
+++ b/fswreck/main.c
@@ -57,6 +57,8 @@ static struct prompt_code prompt_codes[NUM_FSCK_TYPE] = {
define_prompt_code(EB_GEN_FIX, corrupt_file,
"Corrupt an extent block's generation number "
"so that fsck.ocfs2 can fix it"),
+ define_prompt_code(EB_INVALID_ECC, corrupt_file,
+ "Corrupt an extent block's ECC"),
define_prompt_code(EXTENT_EB_INVALID, corrupt_file,
"Corrupt an extent block's generation number"),
define_prompt_code(EXTENT_MARKED_UNWRITTEN, corrupt_file,
--
1.7.6
More information about the Ocfs2-tools-devel
mailing list