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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Jan 17 16:48:56 CST 2005


Author: zab
Date: 2005-01-17 16:48:53 -0600 (Mon, 17 Jan 2005)
New Revision: 557

Modified:
   trunk/fsck.ocfs2/fsck.ocfs2.checks.8.in
   trunk/fsck.ocfs2/pass1.c
Log:
o teach fsck.ocfs2 to understand fast links


Modified: trunk/fsck.ocfs2/fsck.ocfs2.checks.8.in
===================================================================
--- trunk/fsck.ocfs2/fsck.ocfs2.checks.8.in	2005-01-17 22:19:24 UTC (rev 556)
+++ trunk/fsck.ocfs2/fsck.ocfs2.checks.8.in	2005-01-17 22:48:53 UTC (rev 557)
@@ -333,6 +333,15 @@
 Answering yes implies that the inode is still valid and resets its dtime
 to zero.
 
+.SS "LINK_FAST_DATA"
+The target name for a symbolic link is stored either as file contents for
+that inode or in the inode structure itself on disk.  Only small destination
+names are stored in the inode structure.  The i_blocks field of the inode 
+indicates that the name is stored in the inode when it is zero.  An inode
+was found that has both i_blocks set to zero and file contents. 
+
+Answering yes clears the inode and so deletes the link.
+
 .SS "LINK_NULLTERM"
 The targets of links on disk must be null terminated.  A link was found
 whose target wasn't null terminated. 

Modified: trunk/fsck.ocfs2/pass1.c
===================================================================
--- trunk/fsck.ocfs2/pass1.c	2005-01-17 22:19:24 UTC (rev 556)
+++ trunk/fsck.ocfs2/pass1.c	2005-01-17 22:48:53 UTC (rev 557)
@@ -482,12 +482,41 @@
 {
 	ocfs2_dinode *di = vb->vb_di;
 	o2fsck_state *ost = vb->vb_ost;
-	uint64_t expected;
+	uint64_t expected, link_max;
+	char *null;
 
 	verbosef("found a link: num %"PRIu64" last %"PRIu64" len "
 		"%"PRIu64" null %d\n", vb->vb_num_blocks, 
 		vb->vb_last_block, vb->vb_link_len, vb->vb_saw_link_null);
 
+	if (di->i_clusters == 0 && vb->vb_num_blocks > 0 &&
+	    prompt(ost, PY, PR_LINK_FAST_DATA,
+		   "Symlink inode %"PRIu64" claims to be a fast symlink "
+		   "but has file data.  Clear the inode?", di->i_blkno)) {
+		vb->vb_clear = 1;
+		return;
+	}
+
+	/* if we're a fast link we doctor the verifying_blocks book-keeping
+	 * to satisfy the following checks */
+	if (di->i_clusters == 0) {
+		link_max = ost->ost_fs->fs_blocksize - 
+			   offsetof(typeof(*di), id2.i_symlink);
+
+		null = memchr(di->id2.i_symlink, 0, link_max);
+
+		if (null != NULL) {
+			vb->vb_saw_link_null = 1;
+			vb->vb_link_len = (char *)null - 
+					  (char *)di->id2.i_symlink;
+		} else
+			vb->vb_link_len = link_max;
+
+		expected = 0;
+	} else
+		expected = ocfs2_blocks_in_bytes(ost->ost_fs,
+						 vb->vb_link_len + 1);
+
 	/* XXX this could offer to null terminate */
 	if (!vb->vb_saw_link_null) {
 		if (prompt(ost, PY, PR_LINK_NULLTERM,
@@ -499,7 +528,6 @@
 		}
 	}
 
-	expected = ocfs2_blocks_in_bytes(ost->ost_fs, vb->vb_link_len + 1);
 
 	if (di->i_size != vb->vb_link_len) {
 		if (prompt(ost, PY, PR_LINK_SIZE,



More information about the Ocfs2-tools-commits mailing list