]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: fix false dd conv=sparse failure on newer XFS
authorPádraig Brady <P@draigBrady.com>
Fri, 11 Apr 2014 22:44:13 +0000 (23:44 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 11 Apr 2014 22:52:08 +0000 (23:52 +0100)
* tests/dd/sparse.sh: When testing that a hole is created,
use an existing sparse destination file, so that we're
not write extending the file size, and thus avoiding
speculative preallocation which can result in smaller
holes than requested.
Workaround suggested by Brian Foster

THANKS.in
tests/dd/sparse.sh

index e7298ef6e2002cb73e99ee13406e136364e9efe7..a92540adc3c9fc25ae70f1c4042c2683eab4b55b 100644 (file)
--- a/THANKS.in
+++ b/THANKS.in
@@ -95,6 +95,7 @@ Bjorn Helgaas                       helgaas@rsn.hp.com
 Bob McCracken                       kerouac@ravenet.com
 Branden Robinson                    branden@necrotic.deadbeast.net
 Brendan O'Dea                       bod@compusol.com.au
+Brian Foster                        bfoster@redhat.com
 Brian Kimball                       bfk@footbag.org
 Brian M. Carlson                    sandals@crustytoothpaste.ath.cx
 Brian Silverman                     bsilverman@conceptxdesign.com
index 06efc7017d22fae900927fe543bb7812e242176f..a7e90d2be0fa92212c997a52238008f0e2f3ed4c 100755 (executable)
@@ -61,8 +61,15 @@ if test $(kb_alloc file.in) -gt 3000; then
   dd if=file.in of=file.out bs=2M conv=sparse
   test 2500 -lt $(kb_alloc file.out) || fail=1
 
+  # Note we recreate a sparse file first to avoid
+  # speculative preallocation seen in XFS, where a write() that
+  # extends a file can preallocate some extra space that
+  # a subsequent seek will not convert to a hole.
+  rm -f file.out
+  truncate --size=3M file.out
+
   # Ensure that this 1MiB string of NULs *is* converted to a hole.
-  dd if=file.in of=file.out bs=1M conv=sparse
+  dd if=file.in of=file.out bs=1M conv=sparse,notrunc
   test $(kb_alloc file.out) -lt 2500 || fail=1
 
 fi