Blame SOURCES/coreutils-8.22-xfs-tests.patch

522fea
From: Pádraig Brady <pbrady@redhat.com>
522fea
522fea
Avoid false failure due to speculative preallocation on XFS
522fea
Avoid false failure due to delayed allocation on BTRFS
522fea
522fea
diff -Naur coreutils-8.22.orig/tests/dd/sparse.sh coreutils-8.22/tests/dd/sparse.sh
522fea
--- coreutils-8.22.orig/tests/dd/sparse.sh	2013-12-04 14:48:30.000000000 +0000
522fea
+++ coreutils-8.22/tests/dd/sparse.sh	2015-05-19 21:24:55.139941789 +0000
522fea
@@ -58,11 +58,18 @@
522fea
 
522fea
   # Ensure NUL blocks smaller than the block size are not made sparse.
522fea
   # Here, with a 2MiB block size, dd's conv=sparse must *not* introduce a hole.
522fea
-  dd if=file.in of=file.out bs=2M conv=sparse
522fea
+  dd if=file.in of=file.out bs=2M conv=sparse,fsync
522fea
   test 2500 -lt $(kb_alloc file.out) || fail=1
522fea
 
522fea
+  # Note we recreate a sparse file first to avoid
522fea
+  # speculative preallocation seen in XFS, where a write() that
522fea
+  # extends a file can preallocate some extra space that
522fea
+  # a subsequent seek will not convert to a hole.
522fea
+  rm -f file.out
522fea
+  truncate --size=3M file.out
522fea
+
522fea
   # Ensure that this 1MiB string of NULs *is* converted to a hole.
522fea
-  dd if=file.in of=file.out bs=1M conv=sparse
522fea
+  dd if=file.in of=file.out bs=1M conv=sparse,notrunc,fsync
522fea
   test $(kb_alloc file.out) -lt 2500 || fail=1
522fea
 
522fea
 fi