[PATCH] fstests: convert fiemap-tester to use O_DIRECT

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



We want to test fiemap, so we want to lay out a file exactly a certain way.  XFS
tries to be smart and will allocate data in a hole if the write pattern is

[data][hole][data]

where the hole is small enough.  This screws with fiemap-tester sometimes, so
make it easy and just do O_DIRECT so that we get the layout we want and can get
back to testing fiemap.  Thanks,

Signed-off-by: Josef Bacik <jbacik@xxxxxx>
---
 src/fiemap-tester.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/fiemap-tester.c b/src/fiemap-tester.c
index 8e633ab..5cb58fc 100644
--- a/src/fiemap-tester.c
+++ b/src/fiemap-tester.c
@@ -92,8 +92,7 @@ create_file_from_mapping(int fd, char *map, int blocks, int blocksize)
 	int i = 0;
 
 	bufsize = sizeof(char) * blocksize;
-	buf = malloc(bufsize);
-	if (!buf)
+	if (posix_memalign((void **)&buf, 4096, bufsize))
 		return -1;
 
 	memset(buf, 'a', bufsize);
@@ -562,7 +561,7 @@ main(int argc, char **argv)
 	if (!fname)
 		usage();
 
-	fd = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0644);
+	fd = open(fname, O_RDWR|O_CREAT|O_TRUNC|O_DIRECT, 0644);
 	if (fd < 0) {
 		perror("Can't open file");
 		exit(1);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux