[Ocfs2-tools-commits] zab commits r427 - in trunk: debugfs.ocfs2 fsck.ocfs2 fsck.ocfs2/include libocfs2 libocfs2/include mkfs.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Nov 19 17:02:15 CST 2004


Author: zab
Date: 2004-11-19 17:02:13 -0600 (Fri, 19 Nov 2004)
New Revision: 427

Modified:
   trunk/debugfs.ocfs2/dump.c
   trunk/fsck.ocfs2/extent.c
   trunk/fsck.ocfs2/fsck.c
   trunk/fsck.ocfs2/include/fsck.h
   trunk/fsck.ocfs2/pass0.c
   trunk/fsck.ocfs2/pass1.c
   trunk/libocfs2/alloc.c
   trunk/libocfs2/include/ocfs2_fs.h
   trunk/mkfs.ocfs2/mkfs.c
Log:
o check the generation numbers of inodes, group descs, and
  extent blocks.


Modified: trunk/debugfs.ocfs2/dump.c
===================================================================
--- trunk/debugfs.ocfs2/dump.c	2004-11-19 21:32:51 UTC (rev 426)
+++ trunk/debugfs.ocfs2/dump.c	2004-11-19 23:02:13 UTC (rev 427)
@@ -143,6 +143,8 @@
 	fprintf(out, "\tInode: %"PRIu64"   Mode: 0%0o   Generation: %u\n",
 	        in->i_blkno, mode, in->i_generation);
 
+	fprintf(out, "\tFS Generation: %u\n",in->i_fs_generation);
+
 	fprintf(out, "\tType: %s   Flags: %s\n", str, flags->str);
 
 	pw = getpwuid(in->i_uid);

Modified: trunk/fsck.ocfs2/extent.c
===================================================================
--- trunk/fsck.ocfs2/extent.c	2004-11-19 21:32:51 UTC (rev 426)
+++ trunk/fsck.ocfs2/extent.c	2004-11-19 23:02:13 UTC (rev 427)
@@ -100,6 +100,24 @@
 		changed = 1;
 	}
 
+	if (eb->h_fs_generation != ost->ost_fs_generation) {
+		if (prompt(ost, PY, "An extent block at %"PRIu64" in inode "
+			   "%"PRIu64" has a generation of %x which doesn't "
+			   "match the volume's generation of %x.  Consider "
+			   "this extent block invalid?", blkno, di->i_blkno,
+			   eb->h_fs_generation, ost->ost_fs_generation)) {
+
+			*is_valid = 0;
+			goto out;
+		}
+		if (prompt(ost, PY, "Update the extent block's generation to "
+			   "match the volume?")) {
+
+			eb->h_fs_generation = ost->ost_fs_generation;
+			changed = 1;
+		}
+	}
+
 	/* XXX worry about suballoc node/bit */
 	/* XXX worry about next_leaf_blk */
 

Modified: trunk/fsck.ocfs2/fsck.c
===================================================================
--- trunk/fsck.ocfs2/fsck.c	2004-11-19 21:32:51 UTC (rev 426)
+++ trunk/fsck.ocfs2/fsck.c	2004-11-19 23:02:13 UTC (rev 427)
@@ -142,7 +142,8 @@
 
 static errcode_t check_superblock(char *whoami, o2fsck_state *ost)
 {
-	ocfs2_super_block *sb = OCFS2_RAW_SB(ost->ost_fs->fs_super);
+	ocfs2_dinode *di = ost->ost_fs->fs_super;
+	ocfs2_super_block *sb = OCFS2_RAW_SB(di);
 	errcode_t ret = 0;
 
 	if (sb->s_max_nodes == 0) {
@@ -158,6 +159,8 @@
 			"flags");
 	}
 
+	ost->ost_fs_generation = di->i_fs_generation;
+
 	/* XXX do we want checking for different revisions of ocfs2? */
 
 	return ret;

Modified: trunk/fsck.ocfs2/include/fsck.h
===================================================================
--- trunk/fsck.ocfs2/include/fsck.h	2004-11-19 21:32:51 UTC (rev 426)
+++ trunk/fsck.ocfs2/include/fsck.h	2004-11-19 23:02:13 UTC (rev 427)
@@ -51,6 +51,8 @@
 
 	o2fsck_dirblocks	ost_dirblocks;
 
+	uint32_t	ost_fs_generation;
+
 	struct rb_root	ost_dir_parents;
 
 	unsigned	ost_ask:1,	/* confirm with the user */

Modified: trunk/fsck.ocfs2/pass0.c
===================================================================
--- trunk/fsck.ocfs2/pass0.c	2004-11-19 21:32:51 UTC (rev 426)
+++ trunk/fsck.ocfs2/pass0.c	2004-11-19 23:02:13 UTC (rev 427)
@@ -68,9 +68,9 @@
 	uint16_t	cs_cpg;
 };
 
-static errcode_t check_group_desc(o2fsck_state *ost, ocfs2_dinode *di,
-				  struct chain_state *cs, ocfs2_group_desc *bg,
-				  uint64_t blkno)
+static int check_group_desc(o2fsck_state *ost, ocfs2_dinode *di,
+			    struct chain_state *cs, ocfs2_group_desc *bg,
+			    uint64_t blkno)
 {
 	int changed = 0;
 
@@ -86,9 +86,26 @@
 		   strlen(OCFS2_GROUP_DESC_SIGNATURE))) {
 		printf("Group descriptor at block %"PRIu64" has an invalid "
 			"signature.\n", blkno);
-		return OCFS2_ET_BAD_GROUP_DESC_MAGIC;
+		return 1;
 	}
 
+	if (bg->bg_generation != ost->ost_fs_generation) {
+		if (prompt(ost, PY, "Group descriptor at block %"PRIu64" has "
+			   "a generation of %"PRIx32" which doesn't match the "
+			   "volume's generation of %"PRIx32".  Delete this "
+			   "group descriptor?", blkno, bg->bg_generation,
+			   ost->ost_fs_generation)) {
+
+			return 1;
+		}
+		if (prompt(ost, PY, "Update the descriptor's generation to "
+			   "match the volume?")) {
+
+			bg->bg_generation = ost->ost_fs_generation;
+			changed = 1;
+		}
+	}
+
 	/* XXX maybe for advanced pain we could check to see if these 
 	 * kinds of descs have valid generations for the inodes they
 	 * reference */
@@ -230,16 +247,13 @@
 		goto out;
 	}
 
-	ret = check_group_desc(ost, di, cs, bg, blkno);
-	if (ret) {
-		if (prompt(ost, PY, "Chain %d in allocator at inode %"PRIu64" "
-			   "refers to an invalid descriptor block at "
-			   "%"PRIu64".  Truncate the chain by removing this "
-			   "reference?", cs->cs_chain_no, di->i_blkno,
-			   blkno)) {
-			cbr->cb_new_next_blkno = 1;
-			cbr->cb_next_blkno = 0;
-		}
+	if (check_group_desc(ost, di, cs, bg, blkno) &&
+	    prompt(ost, PY, "Chain %d in allocator at inode %"PRIu64" refers "
+		   "to an invalid descriptor block at %"PRIu64".  Truncate "
+		   "the chain by removing this reference?", cs->cs_chain_no,
+		   di->i_blkno, blkno)) {
+		cbr->cb_new_next_blkno = 1;
+		cbr->cb_next_blkno = 0;
 	}
 
 out:

Modified: trunk/fsck.ocfs2/pass1.c
===================================================================
--- trunk/fsck.ocfs2/pass1.c	2004-11-19 21:32:51 UTC (rev 426)
+++ trunk/fsck.ocfs2/pass1.c	2004-11-19 23:02:13 UTC (rev 427)
@@ -48,6 +48,7 @@
  * 	make sure the inode's dtime/count/valid match in update_inode_alloc
  * 	more carefully track cluster use in conjunction with pass 0
  * 	handle local alloc inodes for realsies
+ * 	free an inodes chains and extents and such if we free it
  */
 #include <string.h>
 #include <inttypes.h>
@@ -164,7 +165,9 @@
 
 /* Check the basics of the ocfs2_dinode itself.  If we find problems
  * we clear the VALID flag and the caller will see that and update
- * inode allocations and write the inode to disk. */
+ * inode allocations and write the inode to disk. 
+ *
+ * XXX the o2fsck_write_inode helpers need to be fixed here*/
 static void o2fsck_verify_inode_fields(ocfs2_filesys *fs, o2fsck_state *ost, 
 				       uint64_t blkno, ocfs2_dinode *di)
 {
@@ -172,6 +175,28 @@
 
 	verbosef("checking inode %"PRIu64"'s fields\n", blkno);
 
+	if (!(di->i_flags & OCFS2_VALID_FL))
+		goto out;
+
+	if (di->i_fs_generation != ost->ost_fs_generation) {
+		if (prompt(ost, PY, "Inode read from block %"PRIu64" looks "
+			   "like it is valid but it has a generation of %x "
+			   "that doesn't match the current volume's "
+			   "generation of %x.  This is probably a harmless "
+			   "old inode.  Mark it deleted?", blkno, 
+			   di->i_fs_generation, ost->ost_fs_generation)) {
+
+			clear = 1;
+			goto out;
+		}
+		if (prompt(ost, PY, "Update the inode's generation to match "
+			  "the volume?")) {
+
+			di->i_fs_generation = ost->ost_fs_generation;
+			o2fsck_write_inode(ost, blkno, di);
+		}
+	}
+
 	/* do we want to detect and delete corrupt system dir/files here
 	 * so we can recreate them later ? */
 
@@ -698,8 +723,7 @@
 
 		/* scanners have to skip over uninitialized inodes */
 		if (!memcmp(di->i_signature, OCFS2_INODE_SIGNATURE,
-		    strlen(OCFS2_INODE_SIGNATURE)) &&
-		    di->i_flags & OCFS2_VALID_FL) {
+		    strlen(OCFS2_INODE_SIGNATURE))) {
 			o2fsck_verify_inode_fields(fs, ost, blkno, di);
 
 			/* XXX be able to mark the blocks in the inode as 

Modified: trunk/libocfs2/alloc.c
===================================================================
--- trunk/libocfs2/alloc.c	2004-11-19 21:32:51 UTC (rev 426)
+++ trunk/libocfs2/alloc.c	2004-11-19 23:02:13 UTC (rev 427)
@@ -193,6 +193,7 @@
 	di->i_flags = flags;
 	ocfs2_init_inode(fs, di, gd_blkno, *ino);
 	di->i_flags |= OCFS2_SYSTEM_FL;
+	di->i_fs_generation = fs->fs_super->i_fs_generation;
 
 	ret = ocfs2_write_inode(fs, *ino, buf);
 

Modified: trunk/libocfs2/include/ocfs2_fs.h
===================================================================
--- trunk/libocfs2/include/ocfs2_fs.h	2004-11-19 21:32:51 UTC (rev 426)
+++ trunk/libocfs2/include/ocfs2_fs.h	2004-11-19 23:02:13 UTC (rev 427)
@@ -275,7 +275,7 @@
 					   extent_header belongs to */
 	__u16 h_suballoc_bit;		/* Bit offset in suballocater
 					   block group */
-	__u32 h_reserved2;
+	__u32 h_fs_generation;		/* Must match super block */
 	__u64 h_blkno;			/* Offset on disk, in blocks */
 /*20*/	__u64 h_reserved3;
 	__u64 h_next_leaf_blk;		/* Offset on disk, in blocks,
@@ -370,7 +370,9 @@
 /*50*/	__u64 i_blkno;			/* Offset on disk, in blocks */
 	__u64 i_last_eb_blk;		/* Pointer to last extent
 					   block */
-/*60*/	__u64 i_reserved1[11];
+/*60*/	__u32 i_fs_generation;		/* Generation per fs-instance */
+	__u32 i_reserved0;		/* Generation per fs-instance */
+/*68*/	__u64 i_reserved1[10];
 /*B8*/	union {
 		__u64 i_pad1;		/* Generic way to refer to this
 					   64bit union */

Modified: trunk/mkfs.ocfs2/mkfs.c
===================================================================
--- trunk/mkfs.ocfs2/mkfs.c	2004-11-19 21:32:51 UTC (rev 426)
+++ trunk/mkfs.ocfs2/mkfs.c	2004-11-19 23:02:13 UTC (rev 427)
@@ -1469,6 +1469,7 @@
 	di->i_suballoc_node = cpu_to_le16((__u16)-1);
 	di->i_suballoc_bit = cpu_to_le16((__u16)-1);
 	di->i_generation = cpu_to_le32(s->vol_generation);
+	di->i_fs_generation = cpu_to_le32(s->vol_generation);
 
 	di->i_atime = 0;
 	di->i_ctime = cpu_to_le64(s->format_time);
@@ -1539,6 +1540,7 @@
 
 	strcpy(di->i_signature, OCFS2_INODE_SIGNATURE);
 	di->i_generation = cpu_to_le32(s->vol_generation);
+	di->i_fs_generation = cpu_to_le32(s->vol_generation);
 	di->i_suballoc_node = cpu_to_le16(-1);
         di->i_suballoc_bit = cpu_to_le16(rec->suballoc_bit);
 	di->i_blkno = cpu_to_le64(rec->fe_off >> s->blocksize_bits);



More information about the Ocfs2-tools-commits mailing list