[Ocfs2-tools-commits] taoma commits r1289 - in trunk/fswreck: . include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Feb 8 17:29:06 PST 2007


Author: taoma
Date: 2007-02-08 17:29:00 -0800 (Thu, 08 Feb 2007)
New Revision: 1289

Modified:
   trunk/fswreck/corrupt.c
   trunk/fswreck/group.c
   trunk/fswreck/include/group.h
   trunk/fswreck/include/main.h
   trunk/fswreck/main.c
Log:
Add a new corrupt code 43 in fswreck.
This will create two errors: CLUSTER_ALLOC_BIT and GROUP_FREE_BITS.
For more details, see http://oss.oracle.com/bugzilla/show_bug.cgi?id=841

Signed-off-by:mfasheh

Modified: trunk/fswreck/corrupt.c
===================================================================
--- trunk/fswreck/corrupt.c	2007-02-03 00:58:10 UTC (rev 1288)
+++ trunk/fswreck/corrupt.c	2007-02-09 01:29:00 UTC (rev 1289)
@@ -218,6 +218,9 @@
 	case CORRUPT_GROUP_LIST:
 		func = mess_up_group_list;
 		break;
+	case CORRUPT_CLUSTER_AND_GROUP_DESC:
+		func = mess_up_cluster_group_desc;
+		break;
 	default:
 		FSWRK_FATAL("Invalid code=%d", code);
 	}

Modified: trunk/fswreck/group.c
===================================================================
--- trunk/fswreck/group.c	2007-02-03 00:58:10 UTC (rev 1288)
+++ trunk/fswreck/group.c	2007-02-09 01:29:00 UTC (rev 1289)
@@ -258,3 +258,50 @@
 
 	mess_up_group_desc(fs, slotnum, types, ARRAY_ELEMENTS(types));
 }
+
+/* We will allocate some clusters and corrupt the group descriptor
+ * which stores the clusters and makes fsck run into error.
+ */
+void mess_up_cluster_group_desc(ocfs2_filesys *fs, uint16_t slotnum)
+{
+	errcode_t ret;
+	uint32_t found, start_cluster, old_free_bits, request = 100;
+	uint64_t start_blk;
+	uint64_t bg_blk;
+	int cpg;
+	char *buf = NULL;
+	struct ocfs2_group_desc *bg;
+
+	ret = ocfs2_new_clusters(fs, 1, request, &start_blk, &found);
+	if (ret)
+		FSWRK_COM_FATAL(progname, ret);
+
+	start_cluster = ocfs2_blocks_to_clusters(fs, start_blk);
+	cpg = ocfs2_group_bitmap_size(fs->fs_blocksize) * 8;
+	bg_blk = ocfs2_which_cluster_group(fs, cpg, start_cluster);
+
+	ret = ocfs2_malloc_block(fs->fs_io, &buf);
+	if (ret)
+		FSWRK_COM_FATAL(progname, ret);
+
+	ret = ocfs2_read_group_desc(fs, bg_blk, buf);
+	if (ret)
+		FSWRK_COM_FATAL(progname, ret);
+
+	bg = (struct ocfs2_group_desc *)buf;
+
+	old_free_bits = bg->bg_free_bits_count;
+	bg->bg_free_bits_count = bg->bg_bits + 10;
+
+	ret = ocfs2_write_group_desc(fs, bg_blk, buf);
+	if (ret)
+		FSWRK_COM_FATAL(progname, ret);
+
+	fprintf(stdout, "Corrput CLUSTER and GROUP_FREE_BITS: "
+		"Allocating %u clusters and change group[%"PRIu64"]'s free bits"
+		" from %u to %u\n",
+		found, bg_blk, old_free_bits, bg->bg_free_bits_count);
+
+	if (buf)
+		ocfs2_free(&buf);
+}

Modified: trunk/fswreck/include/group.h
===================================================================
--- trunk/fswreck/include/group.h	2007-02-03 00:58:10 UTC (rev 1288)
+++ trunk/fswreck/include/group.h	2007-02-09 01:29:00 UTC (rev 1289)
@@ -28,5 +28,6 @@
 void mess_up_group_minor(ocfs2_filesys *fs, uint16_t slotnum);
 void mess_up_group_gen(ocfs2_filesys *fs, uint16_t slotnum);
 void mess_up_group_list(ocfs2_filesys *fs, uint16_t slotnum);
+void mess_up_cluster_group_desc(ocfs2_filesys *fs, uint16_t slotnum);
 
 #endif		/* __GROUP_H */

Modified: trunk/fswreck/include/main.h
===================================================================
--- trunk/fswreck/include/main.h	2007-02-03 00:58:10 UTC (rev 1288)
+++ trunk/fswreck/include/main.h	2007-02-09 01:29:00 UTC (rev 1289)
@@ -106,6 +106,7 @@
 	CORRUPT_DIR_ENT,
 	CORRUPT_DIR_PARENT_DUP,
 	CORRUPT_DIR_NOT_CONNECTED,
+	CORRUPT_CLUSTER_AND_GROUP_DESC,
 	MAX_CORRUPT
 	
 };

Modified: trunk/fswreck/main.c
===================================================================
--- trunk/fswreck/main.c	2007-02-03 00:58:10 UTC (rev 1288)
+++ trunk/fswreck/main.c	2007-02-09 01:29:00 UTC (rev 1289)
@@ -87,7 +87,8 @@
  	{ &corrupt_file,	"Dirent dot error: DIRENT_DOTTY_DUP, DIRENT_NOT_DOTTY, DIRENT_DOT_INODE, DIRENT_DOT_EXCESS"},
 	{ &corrupt_file,	"Dirent field error: DIRENT_ZERO, DIRENT_NAME_CHARS,DIRENT_INODE_RANGE, DIRENT_INODE_FREE, DIRENT_TYPE, DIRENT_DUPLICATE, DIRENT_LENGTH"}, 
 	{ &corrupt_file,	"Directory parent duplicate error: DIR_PARENT_DUP"},
-	{ &corrupt_file,	"Directory not connected error: DIR_NOT_CONNECTED"}
+	{ &corrupt_file,	"Directory not connected error: DIR_NOT_CONNECTED"},
+	{ &corrupt_group_desc,	"Create an error of GROUP_FREE_BITS and CLUSTER_ALLOC_BITS, simulate bug841 in oss.oracle.com/bugzilla"}
 };
 
 static int corrupt[MAX_CORRUPT];




More information about the Ocfs2-tools-commits mailing list