summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/cp/sparse-fiemap13
-rw-r--r--tests/filefrag-extent-compare53
2 files changed, 37 insertions, 29 deletions
diff --git a/tests/cp/sparse-fiemap b/tests/cp/sparse-fiemap
index a2460a086..73448ecfa 100755
--- a/tests/cp/sparse-fiemap
+++ b/tests/cp/sparse-fiemap
@@ -69,15 +69,14 @@ for i in $(seq 1 2 21); do
-e 'for (1..'$j') { sysseek (*F, $n, 1)' \
-e '&& syswrite (*F, chr($_)x$n) or die "$!"}' > j1 || fail=1
- # Note the explicit fdatasync is used here as
- # it was seen that `filefrag -s` (FIEMAP_FLAG_SYNC) was
- # ineffective on ext4 loopback on Linux 2.6.35.10-72.fc14.i686
- dd if=/dev/null of=j1 conv=notrunc,fdatasync
+ # Note there is an implicit sync performed by cp to
+ # work around bugs in EXT4 and BTRFS before Linux 2.6.38
+ # Note also the -s parameter to the filefrag commands below
+ # for the same reasons.
cp --sparse=always j1 j2 || fail=1
- dd if=/dev/null of=j2 conv=notrunc,fdatasync
cmp j1 j2 || fail=1
- if ! filefrag -v j1 | grep -F extent >/dev/null; then
+ if ! filefrag -vs j1 | grep -F extent >/dev/null; then
test $skip != 1 && warn_ 'skipping part; you lack filefrag'
skip=1
else
@@ -98,7 +97,7 @@ for i in $(seq 1 2 21); do
# exclude the physical block numbers; they always differ
filefrag -v j1 > ff1 || framework_failure
- filefrag -v j2 > ff2 || framework_failure
+ filefrag -vs j2 > ff2 || framework_failure
{ f ff1; f ff2; } | $PERL $abs_top_srcdir/tests/filefrag-extent-compare ||
fail=1
fi
diff --git a/tests/filefrag-extent-compare b/tests/filefrag-extent-compare
index 3c095d52f..2c33584e5 100644
--- a/tests/filefrag-extent-compare
+++ b/tests/filefrag-extent-compare
@@ -28,30 +28,39 @@ my @b;
foreach my $i (0..@A/2-1) { $a[$i] = { L_BLK => $A[2*$i], LEN => $A[2*$i+1] } };
foreach my $i (0..@B/2-1) { $b[$i] = { L_BLK => $B[2*$i], LEN => $B[2*$i+1] } };
+# Merge adjacent extents in array E.
+sub merge_extents($)
+{
+ my ($e) = @_;
+
+ my $i = 0;
+ while (1)
+ {
+ !defined $e->[$i+1]
+ and last;
+ $e->[$i]->{L_BLK} + $e->[$i]->{LEN} != $e->[$i+1]->{L_BLK}
+ and ++$i, next;
+
+ $e->[$i]->{LEN} += $e->[$i+1]->{LEN};
+ # Remove $e->[$i+1]
+ splice @$e, $i+1, 1;
+ }
+}
+
+merge_extents \@a;
+merge_extents \@b;
+
+@a == @b
+ or die "$ME: extent counts differ, even after adjustment\n";
+
my $i = 0;
-my $j = 0;
-while (1)
- {
- !defined $a[$i] && !defined $b[$j]
- and exit 0;
- defined $a[$i] && defined $b[$j]
- or die "\@a and \@b have different lengths, even after adjustment\n";
- ($a[$i]->{L_BLK} == $b[$j]->{L_BLK}
- && $a[$i]->{LEN} == $b[$j]->{LEN})
- and next;
- ($a[$i]->{LEN} < $b[$j]->{LEN}
- && exists $a[$i+1] && $a[$i]->{LEN} + $a[$i+1]->{LEN} == $b[$j]->{LEN})
- and ++$i, next;
- exists $b[$j+1] && $a[$i]->{LEN} == $b[$i]->{LEN} + $b[$i+1]->{LEN}
- and ++$j, next;
- die "differing extent:\n"
- . " [$i]=$a[$i]->{L_BLK} $a[$i]->{LEN}\n"
- . " [$j]=$b[$j]->{L_BLK} $b[$j]->{LEN}\n"
- }
-continue
+while (defined $a[$i])
{
- ++$i;
- ++$j;
+ $a[$i]->{L_BLK} == $b[$i]->{L_BLK} && $a[$i]->{LEN} == $b[$i]->{LEN}
+ or die "$ME: differing extent:\n"
+ . " [$i]=$a[$i]->{L_BLK} $a[$i]->{LEN}\n"
+ . " [$i]=$b[$i]->{L_BLK} $b[$i]->{LEN}\n";
+ $i++;
}
### Setup "GNU" style for perl-mode and cperl-mode.