[Ocfs2-tools-devel] [PATCH 1/2] looped chain - Add corruption in fswreck

Goldwyn Rodrigues rgoldwyn at gmail.com
Tue Mar 2 15:28:23 PST 2010


Add CHAIN_LOOP corruption in fswreck.
The loop is created by pointing the gd->bg_next_group to self.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>
Acked-by: Mark Fasheh <mfasheh at suse.com>

--- 
diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
index 8f943c0..4d25561 100644
--- a/fswreck/corrupt.c
+++ b/fswreck/corrupt.c
@@ -374,6 +374,9 @@ void corrupt_group_desc(ocfs2_filesys *fs, enum fsck_type type,
 	case GROUP_FREE_BITS:
 		func = mess_up_group_minor;
 		break;
+	case CHAIN_LOOP:
+		func = mess_up_group_minor;
+		break;
 	case GROUP_GEN:
 		func = mess_up_group_gen;
 		break;
diff --git a/fswreck/group.c b/fswreck/group.c
index aa0298c..15ce61d 100644
--- a/fswreck/group.c
+++ b/fswreck/group.c
@@ -176,6 +176,12 @@ static void damage_group_desc(ocfs2_filesys *fs, uint64_t blkno,
 			bg->bg_chain, (bg->bg_chain + 10));
 		bg->bg_chain += 10;
 		break;
+	case CHAIN_LOOP:
+		fprintf(stdout, "Corrput GROUP_LOOP: "
+			"change group next from %"PRIu64" to %"PRIu64"\n",
+			bg->bg_next_group, cr->c_blkno);
+		bg->bg_next_group = cpu_to_le64(cr->c_blkno);
+		break;
 	case GROUP_FREE_BITS:
 		fprintf(stdout, "Corrput GROUP_FREE_BITS: "
 			"change group free bits from %u to %u\n",
diff --git a/fswreck/include/fsck_type.h b/fswreck/include/fsck_type.h
index 1d2113f..ed145ab 100644
--- a/fswreck/include/fsck_type.h
+++ b/fswreck/include/fsck_type.h
@@ -55,6 +55,7 @@ enum fsck_type
 	GROUP_BLKNO,
 	GROUP_CHAIN,
 	GROUP_FREE_BITS,
+	CHAIN_LOOP,
 	CHAIN_COUNT,
 	CHAIN_NEXT_FREE,
 	CHAIN_EMPTY,
diff --git a/fswreck/main.c b/fswreck/main.c
index ae8836c..e46d91e 100644
--- a/fswreck/main.c
+++ b/fswreck/main.c
@@ -206,6 +206,9 @@ static struct prompt_code prompt_codes[NUM_FSCK_TYPE] = {
 			   "Corrupt chain group's chain where it was in"),
 	define_prompt_code(GROUP_FREE_BITS, corrupt_group_desc,
 			   "Corrupt chain group's free bits"),
+	define_prompt_code(CHAIN_LOOP, corrupt_group_desc,
+			   "Corrupt group's next to point to self so "
+			   "chain falls in a loop"),
 	define_prompt_code(GROUP_GEN, corrupt_group_desc,
 			   "Corrupt chain group's generation"),
 	define_prompt_code(GROUP_UNEXPECTED_DESC, corrupt_group_desc,




More information about the Ocfs2-tools-devel mailing list