[Ocfs2-tools-commits] zab commits r1174 - trunk/fsck.ocfs2

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Thu Mar 9 16:16:45 CST 2006


Author: zab
Signed-off-by: mfasheh
Date: 2006-03-09 16:16:43 -0600 (Thu, 09 Mar 2006)
New Revision: 1174

Modified:
   trunk/fsck.ocfs2/pass1.c
   trunk/fsck.ocfs2/pass2.c
Log:
o iterate over all blocks in inodes in pass1.  This lets fsck see blocks beyond 
  i_size and so notice if i_clusters doesn't cover all the clusters in the 
  extent list.
o once we do this, though, we have to be careful to avoid checking dir blocks
  byond i_size which haven't been initialized.

Signed-off-by: mfasheh



Modified: trunk/fsck.ocfs2/pass1.c
===================================================================
--- trunk/fsck.ocfs2/pass1.c	2006-03-03 00:38:02 UTC (rev 1173)
+++ trunk/fsck.ocfs2/pass1.c	2006-03-09 22:16:43 UTC (rev 1174)
@@ -737,7 +737,9 @@
 
 	ret = o2fsck_check_extents(ost, di);
 	if (ret == 0)
-		ret = ocfs2_block_iterate_inode(fs, di, 0, verify_block, &vb);
+		ret = ocfs2_block_iterate_inode(fs, di,
+					        OCFS2_BLOCK_FLAG_APPEND,
+						verify_block, &vb);
 	if (vb.vb_ret)
 		ret = vb.vb_ret;
 

Modified: trunk/fsck.ocfs2/pass2.c
===================================================================
--- trunk/fsck.ocfs2/pass2.c	2006-03-03 00:38:02 UTC (rev 1173)
+++ trunk/fsck.ocfs2/pass2.c	2006-03-09 22:16:43 UTC (rev 1174)
@@ -590,9 +590,22 @@
 	    !dirent_leaves_partial(dirent, left))
 		return 0;
 
+	verbosef("corrupt dirent: %"PRIu64" rec_len %u name_len %u\n",
+		dirent->inode, dirent->rec_len, dirent->name_len);
+
 	return 1;
 }
 
+static size_t nr_zeros(unsigned char *buf, size_t len)
+{
+	size_t ret = 0;
+
+	while(len-- > 0 && *(buf++) == 0)
+		ret++;
+
+	return ret;
+}
+
 /* this could certainly be more clever to issue reads in groups */
 static unsigned pass2_dir_block_iterate(o2fsck_dirblock_entry *dbe, 
 					void *priv_data) 
@@ -621,6 +634,17 @@
 		goto out;
 	}
 
+	/*
+	 * pass1 records all the blocks that have been allocated to the
+	 * dir so that it can verify i_clusters and make sure dirs don't
+	 * share blocks, etc.  Unfortunately allocated blocks that are
+	 * beyond i_size aren't initialized.. we special case a block of
+	 * all 0s as an uninitialized dir block, though we don't actually
+	 * make sure that it's outside i_size.
+	 */
+	if (nr_zeros(dd->buf, dd->fs->fs_blocksize) == dd->fs->fs_blocksize)
+		return 0;
+
 	verbosef("dir block %"PRIu64"\n", dbe->e_blkno);
 
 	while (offset < dd->fs->fs_blocksize) {




More information about the Ocfs2-tools-commits mailing list