Proposed patch for xfsprogs

C. Linus Hicks linush at mindspring.com
Sat Feb 27 16:54:10 CST 2010


During my recent experience with having to reconstruct parts of an XFS
filesystem that got corrupted as a result of several bad blocks, I found
that some of the information displayed using "blockget -v" was pretty
useless, and I am proposing the following code change to introduce a
slight summarization.

Repeating lines of "setting block <foo> to <bar>" and "setting inode to
<foo> for {,rt}block <bar>" will be summarized down to two lines.



--- a/xfsprogs-3.1.1/db/check.c	2010-01-29 14:46:13.000000000 -0500
+++ b/xfsprogs-3.1.1/db/check.c	2010-02-27 17:02:14.111418960 -0500
@@ -1509,6 +1509,7 @@
 {
 	xfs_extlen_t	i;
 	int		mayprint;
+	int		isfirst = 1;
 	char		*p;
 
 	if (!check_range(agno, agbno, len))  {
@@ -1520,10 +1521,15 @@
 	mayprint = verbose | blist_size;
 	for (i = 0, p = &dbmap[agno][agbno]; i < len; i++, p++) {
 		*p = (char)type2;
-		if (mayprint && (verbose || CHECK_BLISTA(agno, agbno + i)))
+		if (isfirst && mayprint && (verbose || CHECK_BLISTA(agno, agbno + i))) {
 			dbprintf(_("setting block %u/%u to %s\n"), agno, agbno + i,
 				typename[type2]);
+			isfirst = 0;
+		}
 	}
+	if ((len > 1) && mayprint && (verbose || CHECK_BLISTA(agno, agbno + i)))
+		dbprintf(_("    ... until %u/%u\n"),
+				agno, agbno + len - 1);
 }
 
 static void
@@ -4544,6 +4550,7 @@
 {
 	xfs_extlen_t	i;
 	inodata_t	**idp;
+	int		isfirst = 1;
 	int		mayprint;
 
 	if (!check_inomap(agno, agbno, len, id->ino))
@@ -4551,11 +4558,16 @@
 	mayprint = verbose | id->ilist | blist_size;
 	for (i = 0, idp = &inomap[agno][agbno]; i < len; i++, idp++) {
 		*idp = id;
-		if (mayprint &&
-		    (verbose || id->ilist || CHECK_BLISTA(agno, agbno + i)))
+		if (isfirst && mayprint &&
+		    (verbose || id->ilist || CHECK_BLISTA(agno, agbno + i))) {
 			dbprintf(_("setting inode to %lld for block %u/%u\n"),
 				id->ino, agno, agbno + i);
+			isfirst = 0;
+		}
 	}
+	if ((len > 1) && mayprint && 
+	    (verbose || id->ilist || CHECK_BLISTA(agno, agbno + i)))
+		dbprintf(_("\t\t      ... until %u/%u\n"), agno, agbno + len - 1);
 }
 
 static void
@@ -4575,6 +4587,7 @@
 {
 	xfs_extlen_t	i;
 	inodata_t	**idp;
+	int		isfirst = 1;
 	int		mayprint;
 
 	if (!check_rinomap(bno, len, id->ino))
@@ -4584,10 +4597,16 @@
 	     i < len;
 	     i++, idp++) {
 		*idp = id;
-		if (mayprint && (verbose || id->ilist || CHECK_BLIST(bno + i)))
+		if (isfirst && mayprint &&
+		    (verbose || id->ilist || CHECK_BLIST(bno + i))) {
 			dbprintf(_("setting inode to %lld for rtblock %llu\n"),
 				id->ino, bno + i);
+			isfirst = 0;
+		}
 	}
+	if ((len > 1) && mayprint &&
+	    (verbose || id->ilist || CHECK_BLIST(bno + i)))
+		dbprintf(_("\t\t      ... until %llu\n"), bno + len - 1);
 }
 
 static void





More information about the xfs mailing list