[Ocfs2-tools-devel] [PATCH 47/50] fswreck: Add basic corruption for refcount_list.
Tao Ma
tao.ma at oracle.com
Mon Jan 11 07:31:33 PST 2010
Add corruption for refcount_list:
REFCOUNT_LIST_COUNT, REFCOUNT_LIST_USED, REFCOUNT_CLUSTER_RANGE,
REFCOUNT_CLUSTER_COLLISION and REFCOUNT_LIST_EMPTY.
Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
fswreck/corrupt.c | 5 ++++
fswreck/include/fsck_type.h | 9 ++++++-
fswreck/main.c | 10 +++++++
fswreck/refcount.c | 56 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 79 insertions(+), 1 deletions(-)
diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
index 951e4f5..df3cdad 100644
--- a/fswreck/corrupt.c
+++ b/fswreck/corrupt.c
@@ -480,6 +480,11 @@ void corrupt_refcount(ocfs2_filesys *fs, enum fsck_type type, uint16_t slotnum)
case RB_PARENT:
case REFCOUNT_BLOCK_INVALID:
case REFCOUNT_ROOT_BLOCK_INVALID:
+ case REFCOUNT_LIST_COUNT:
+ case REFCOUNT_LIST_USED:
+ case REFCOUNT_CLUSTER_RANGE:
+ case REFCOUNT_CLUSTER_COLLISION:
+ case REFCOUNT_LIST_EMPTY:
func = mess_up_refcount_tree_block;
break;
default:
diff --git a/fswreck/include/fsck_type.h b/fswreck/include/fsck_type.h
index d34d2a9..7781a26 100644
--- a/fswreck/include/fsck_type.h
+++ b/fswreck/include/fsck_type.h
@@ -143,6 +143,11 @@ enum fsck_type
RB_PARENT,
REFCOUNT_BLOCK_INVALID,
REFCOUNT_ROOT_BLOCK_INVALID,
+ REFCOUNT_LIST_COUNT,
+ REFCOUNT_LIST_USED,
+ REFCOUNT_CLUSTER_RANGE,
+ REFCOUNT_CLUSTER_COLLISION,
+ REFCOUNT_LIST_EMPTY,
NUM_FSCK_TYPE
};
@@ -231,6 +236,8 @@ enum fsck_type
* refcount tree error: EXTENT_MARKED_REFCOUNTED, REFCOUNT_FLAG_INVALID,
* REFCOUNT_LOC_INVALID, RB_BLKNO, RB_GEN, RB_GEN_FIX,
* RB_PARENT, REFCOUNT_BLOCK_INVALID,
- * REFCOUNT_ROOT_BLOCK_INVALID
+ * REFCOUNT_ROOT_BLOCK_INVALID, REFCOUNT_LIST_COUNT,
+ * REFCOUNT_LIST_USED, REFCOUNT_CLUSTER_RANGE,
+ * REFCOUNT_CLUSTER_COLLISION, REFCOUNT_LIST_EMPTY
*/
#endif
diff --git a/fswreck/main.c b/fswreck/main.c
index 00285a2..68b390a 100644
--- a/fswreck/main.c
+++ b/fswreck/main.c
@@ -278,6 +278,16 @@ static struct prompt_code prompt_codes[NUM_FSCK_TYPE] = {
"Corrupt a refcount block's rf_parent"),
define_prompt_code(REFCOUNT_ROOT_BLOCK_INVALID, corrupt_refcount,
"Corrupt a refcount block's rf_parent"),
+ define_prompt_code(REFCOUNT_LIST_COUNT, corrupt_refcount,
+ "corrupt the refcount list in a refcount block"),
+ define_prompt_code(REFCOUNT_LIST_USED, corrupt_refcount,
+ "corrupt the refcount list in a refcount block"),
+ define_prompt_code(REFCOUNT_CLUSTER_RANGE, corrupt_refcount,
+ "corrupt the refcount list in a refcount block"),
+ define_prompt_code(REFCOUNT_CLUSTER_COLLISION, corrupt_refcount,
+ "corrupt the refcount list in a refcount block"),
+ define_prompt_code(REFCOUNT_LIST_EMPTY, corrupt_refcount,
+ "corrupt the refcount list in a refcount block"),
};
#undef define_prompt_code
diff --git a/fswreck/refcount.c b/fswreck/refcount.c
index a955f44..816e663 100644
--- a/fswreck/refcount.c
+++ b/fswreck/refcount.c
@@ -174,6 +174,54 @@ static void damage_refcount_block(ocfs2_filesys *fs, enum fsck_type type,
}
}
+static void damage_refcount_list(ocfs2_filesys *fs, enum fsck_type type,
+ struct ocfs2_refcount_block *rb)
+{
+ uint32_t oldno;
+ uint64_t oldblkno;
+
+ switch (type) {
+ case REFCOUNT_LIST_COUNT:
+ oldno = rb->rf_records.rl_count;
+ rb->rf_records.rl_count *= 2;
+ fprintf(stdout, "REFCOUNT_LIST_COUNT: Corrupt refcount block #"
+ "%"PRIu64", change rl_count from %u to %u\n",
+ (uint64_t)rb->rf_blkno, oldno, rb->rf_records.rl_count);
+ break;
+ case REFCOUNT_LIST_USED:
+ oldno = rb->rf_records.rl_used;
+ rb->rf_records.rl_used = 2 * rb->rf_records.rl_count;
+ fprintf(stdout, "REFCOUNT_LIST_USED: Corrupt refcount block #"
+ "%"PRIu64", change rl_used from %u to %u\n",
+ (uint64_t)rb->rf_blkno, oldno, rb->rf_records.rl_used);
+ break;
+ case REFCOUNT_CLUSTER_RANGE:
+ oldblkno = rb->rf_records.rl_recs[0].r_cpos;
+ rb->rf_records.rl_recs[0].r_cpos = fs->fs_clusters + 1;
+ fprintf(stdout, "REFCOUNT_CLUSTER_RANGE, Corrupt refcount "
+ "block #%"PRIu64", change recs[0] from %"PRIu64
+ " to %"PRIu64"\n", (uint64_t)rb->rf_blkno, oldblkno,
+ (uint64_t)rb->rf_records.rl_recs[0].r_cpos);
+ break;
+ case REFCOUNT_CLUSTER_COLLISION:
+ oldblkno = rb->rf_records.rl_recs[0].r_cpos;
+ rb->rf_records.rl_recs[0].r_cpos = fs->fs_clusters - 1;
+ fprintf(stdout, "REFCOUNT_CLUSTER_COLLISION, Corrupt refcount "
+ "block #%"PRIu64", change recs[0] from %"PRIu64
+ " to %"PRIu64"\n", (uint64_t)rb->rf_blkno, oldblkno,
+ (uint64_t)rb->rf_records.rl_recs[0].r_cpos);
+ break;
+ case REFCOUNT_LIST_EMPTY:
+ oldno = rb->rf_records.rl_used;
+ rb->rf_records.rl_used = 0;
+ fprintf(stdout, "REFCOUNT_LIST_EMPTY: Corrupt refcount block #"
+ "%"PRIu64", change rl_used from %u to 0\n",
+ (uint64_t)rb->rf_blkno, oldno);
+ break;
+ default:
+ FSWRK_FATAL("Invalid type=%d", type);
+ }
+}
void mess_up_refcount_tree_block(ocfs2_filesys *fs, enum fsck_type type,
uint64_t blkno)
{
@@ -238,6 +286,14 @@ void mess_up_refcount_tree_block(ocfs2_filesys *fs, enum fsck_type type,
damage_refcount_block(fs, type, rb1);
damage_refcount_block(fs, type, rb2);
break;
+ case REFCOUNT_LIST_COUNT:
+ case REFCOUNT_LIST_USED:
+ case REFCOUNT_CLUSTER_RANGE:
+ case REFCOUNT_CLUSTER_COLLISION:
+ case REFCOUNT_LIST_EMPTY:
+ damage_refcount_list(fs, type, rb1);
+ damage_refcount_list(fs, type, rb2_leaf);
+ break;
default:
FSWRK_FATAL("Invalid type[%d]\n", type);
}
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list