public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfstests: coalesce contiguous extents in extent map output
@ 2011-04-21 18:55 Alex Elder
  2011-04-28  2:08 ` Dave Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Elder @ 2011-04-21 18:55 UTC (permalink / raw)
  To: xfs; +Cc: Alex Elder

The specific set of extent sizes allocated to a file is not always
deterministic.  In particular, sometimes a range of unwritten blocks
is covered by a single extent, while in other cases it might be
represented by multiple consecutive unwritten extents.  This can
result in spurious errors being reported in tests that check file
extent maps.

Add a filter that finds adjacent extents in what gets produced for
fiemap and bmap output and coalesces them as if all consective
extents of the same time were really just one extent.  (Note that
as implemented here this applies to all extent types, not just
unwritten extents.)

Update the golden output for test 242 to reflect the change.

Signed-off-by: Alex Elder <aelder@sgi.com>
---
 242.out      |   18 +++++++-----------
 common.punch |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 57 insertions(+), 17 deletions(-)

diff --git a/242.out b/242.out
index 9ffa207..f785163 100644
--- a/242.out
+++ b/242.out
@@ -11,15 +11,13 @@ QA output created by 242
 0: [0..39]: unwritten
 	4. hole -> data
 0: [0..7]: hole
-1: [8..15]: unwritten
-2: [16..23]: unwritten
-3: [24..31]: data
-4: [32..39]: hole
+1: [8..23]: unwritten
+2: [24..31]: data
+3: [32..39]: hole
 	5. hole -> unwritten
 0: [0..7]: hole
-1: [8..15]: unwritten
-2: [16..31]: unwritten
-3: [32..39]: hole
+1: [8..31]: unwritten
+2: [32..39]: hole
 	6. data -> hole
 0: [0..7]: data
 1: [8..23]: unwritten
@@ -37,10 +35,8 @@ QA output created by 242
 2: [32..39]: hole
 	10. hole -> data -> hole
 0: [0..7]: hole
-1: [8..15]: unwritten
-2: [16..23]: unwritten
-3: [24..31]: unwritten
-4: [32..39]: hole
+1: [8..31]: unwritten
+2: [32..39]: hole
 	11. data -> hole -> data
 0: [0..7]: data
 1: [8..31]: unwritten
diff --git a/common.punch b/common.punch
index fb20d58..c967bd8 100644
--- a/common.punch
+++ b/common.punch
@@ -177,18 +177,62 @@ _test_punch() {
 	done
 }
 
+_coalesce_extents()
+{
+	awk -F: '
+	{
+		range = $2;
+		type = $3;
+
+		split(range, bounds, "[\\[ \\.\\]]");
+		low = bounds[3];
+		high = bounds[5];
+
+		if (type != prev_type) {
+			if (prev_type != "")
+				printf("%u]:%s\n", low - 1, prev_type);
+			printf("%u: [%u..", out_count++, low);
+			prev_type = type;
+		}
+	}
+	END {
+		if (prev_type != "")
+			printf("%u]:%s\n", high, prev_type);
+	}'
+}
+
 _filter_fiemap()
 {
-    awk --posix '$3 ~ /hole/ { print $1, $2, $3; next }
-		 $5 ~ /0x[[:digit:]]*8[[:digit:]]{2}/ { print $1, $2, "unwritten"; next }
-		 $5 ~ /0x[[:digit:]]+/ {print $1, $2, "data" }'
+	awk --posix '
+		$3 ~ /hole/ {
+			print $1, $2, $3;
+			next;
+		}
+		$5 ~ /0x[[:digit:]]*8[[:digit:]]{2}/ {
+			print $1, $2, "unwritten";
+			next;
+		}
+		$5 ~ /0x[[:digit:]]+/ {
+			print $1, $2, "data";
+		}' |
+	_coalesce_extents
 }
 
 _filter_bmap()
 {
-    awk '$3 ~ /hole/ { print $1, $2, $3; next }
-         $7 ~ /10000/ { print $1, $2, "unwritten"; next }
-         $7 ~ /00000/ {print $1, $2, "data" }'
+	awk '
+		$3 ~ /hole/ {
+			print $1, $2, $3;
+			next;
+		}
+		$7 ~ /10000/ {
+			print $1, $2, "unwritten";
+			next;
+		}
+		$7 ~ /00000/ {
+	    		print $1, $2, "data"
+		}' |
+	_coalesce_extents
 }
 
 die_now()
-- 
1.7.4.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-28 17:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-21 18:55 [PATCH] xfstests: coalesce contiguous extents in extent map output Alex Elder
2011-04-28  2:08 ` Dave Chinner
2011-04-28 17:29   ` Alex Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox