* [PATCH] xfsqa: make hole tests independent of speculative allocation patterns
@ 2010-12-21 9:02 Dave Chinner
2010-12-21 16:46 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Dave Chinner @ 2010-12-21 9:02 UTC (permalink / raw)
To: xfs
From: Dave Chinner <dchinner@redhat.com>
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>
---
203 | 4 ++++
src/holes.c | 11 +++++++++++
src/randholes.c | 10 ++++++++++
3 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/203 b/203
index 6fae361..be69dfa 100755
--- a/203
+++ b/203
@@ -36,6 +36,10 @@ _write_holes()
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
diff --git a/src/holes.c b/src/holes.c
index 1ad5093..3be8a66 100644
--- a/src/holes.c
+++ b/src/holes.c
@@ -79,6 +79,17 @@ main(int argc, char *argv[])
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);
}
diff --git a/src/randholes.c b/src/randholes.c
index b7c89b3..b43da81 100644
--- a/src/randholes.c
+++ b/src/randholes.c
@@ -208,6 +208,16 @@ writeblks(char *fname, int fd, size_t alignment)
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(".");
--
1.7.2.3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] xfsqa: make hole tests independent of speculative allocation patterns
2010-12-21 9:02 [PATCH] xfsqa: make hole tests independent of speculative allocation patterns Dave Chinner
@ 2010-12-21 16:46 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2010-12-21 16:46 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
On Tue, Dec 21, 2010 at 08:02:00PM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> 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>
Looks good and fixes the test failure I saw with the dirty release
counter patch.
Reviewed-by: Christoph Hellwig <hch@lst.de>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-21 16:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-21 9:02 [PATCH] xfsqa: make hole tests independent of speculative allocation patterns Dave Chinner
2010-12-21 16:46 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox