Many of the "count-the-holes" tests (008, 012, etc) do writes that extend the
file and hence allocation patterns are dependent on speculative allocation
beyond EOF behaviour. Hence if we change that behaviour, these tests all fail
because there is a different pattern of holes.
Make the tests independent of EOF preallocation behaviour by first truncating
the file to the size the test is defined to use. This prevents speculative
prealocation from occurring, and hence changes in such behaviour will not cause
the tests to fail.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
file=$1
holes=$2
let writes=$holes+1
file=$1
holes=$2
let writes=$holes+1
+ let fsize=$(($writes * 0x100000))
+
+ # prevent EOF preallocation from affecting results
+ xfs_io -f $file -c "truncate $fsize"
offset=0
for i in `seq 0 $writes`; do
offset=0
for i in `seq 0 $writes`; do
perror("open");
return 1;
}
perror("open");
return 1;
}
+
+ /*
+ * Avoid allocation patterns being perturbed by different speculative
+ * preallocation beyond EOF configurations by first truncating the file
+ * to the expected maximum file size.
+ */
+ if (ftruncate(fd, filesize) < 0) {
+ perror("ftruncate");
+ exit(EXIT_FAILURE);
+ }
+
for (i = 0; i < count; i++) {
writeblks(fd, filesize, blocksize, interleave, i, rev);
}
for (i = 0; i < count; i++) {
writeblks(fd, filesize, blocksize, interleave, i, rev);
}
memset(buffer, 0, blocksize);
}
memset(buffer, 0, blocksize);
}
+ /*
+ * Avoid allocation patterns being perturbed by different speculative
+ * preallocation beyond EOF configurations by first truncating the file
+ * to the expected maximum file size.
+ */
+ if (ftruncate(fd, filesize) < 0) {
+ perror("ftruncate");
+ exit(EXIT_FAILURE);
+ }
+
do {
if (verbose && ((count % 100) == 0)) {
printf(".");
do {
if (verbose && ((count % 100) == 0)) {
printf(".");