225: add additional fiemap-tester run without sync

Chris Mason pointed out that some filesystems were not doing
the right thing on fiemap, in the face of delalloc extents.

Because test 225 ran with FIEMAP_FLAG_SYNC only, this didn't
get caught.  Add a runtime option, and run it both ways.

Note that this changes defaults for fiemap-tester, so that
it no longer calls with FIEMAP_FLAG_SYNC by default, and
a new option -S is added to do so.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Alex Elder <aelder@sgi.com>
This commit is contained in:
Eric Sandeen
2011-03-08 09:16:23 -06:00
parent e423b5c584
commit b431918b6d
3 changed files with 17 additions and 8 deletions
+4 -1
View File
@@ -60,7 +60,10 @@ _cleanup()
}
trap "_cleanup; exit \$status" 0 1 2 3 15
echo "fiemap run without preallocation"
echo "fiemap run without preallocation, with sync"
$here/src/fiemap-tester -q -S -p 0 -r 200 $fiemapfile 2>&1 | tee $fiemaplog
echo "fiemap run without preallocation or sync"
$here/src/fiemap-tester -q -p 0 -r 200 $fiemapfile 2>&1 | tee $fiemaplog
if grep -q "Operation not supported" $fiemaplog; then
+2 -1
View File
@@ -1,2 +1,3 @@
QA output created by 225
fiemap run without preallocation
fiemap run without preallocation, with sync
fiemap run without preallocation or sync
+11 -6
View File
@@ -37,7 +37,7 @@ int quiet;
static void
usage(void)
{
printf("Usage: fiemap-tester [-m map] [-r number of runs] [-s seed] [-q]");
printf("Usage: fiemap-tester [-m map] [-r number of runs] [-s seed] [-qS]");
printf("[-p preallocate (1/0)] ");
printf("filename\n");
printf(" -m map : generate a file with the map given and test\n");
@@ -45,6 +45,7 @@ usage(void)
printf(" -r count : number of runs to execute (default infinity)\n");
printf(" -s seed : seed for random map generator (default 1)\n");
printf(" -q : be quiet about non-errors\n");
printf(" -S : sync file before mapping (via ioctl flags)\n");
printf("-m and -r cannot be used together\n");
exit(EXIT_FAILURE);
}
@@ -418,7 +419,7 @@ static int query_fiemap_count(int fd, int blocks, int blocksize)
}
static int
compare_fiemap_and_map(int fd, char *map, int blocks, int blocksize)
compare_fiemap_and_map(int fd, char *map, int blocks, int blocksize, int syncfile)
{
struct fiemap *fiemap;
char *fiebuf;
@@ -446,7 +447,7 @@ compare_fiemap_and_map(int fd, char *map, int blocks, int blocksize)
last_data = i;
}
fiemap->fm_flags = FIEMAP_FLAG_SYNC;
fiemap->fm_flags = syncfile ? FIEMAP_FLAG_SYNC : 0;
fiemap->fm_extent_count = blocks_to_map;
fiemap->fm_mapped_extents = 0;
@@ -519,9 +520,10 @@ main(int argc, char **argv)
int blocks = 0; /* the number of blocks to generate */
int maxblocks = 0; /* max # of blocks to create */
int prealloc = 1; /* whether or not to do preallocation */
int syncfile = 0; /* whether fiemap should sync file first */
int seed = 1;
while ((opt = getopt(argc, argv, "m:r:s:p:q")) != -1) {
while ((opt = getopt(argc, argv, "m:r:s:p:qS")) != -1) {
switch(opt) {
case 'm':
map = strdup(optarg);
@@ -538,13 +540,16 @@ main(int argc, char **argv)
case 'q':
quiet = 1;
break;
/* sync file before mapping */
case 'r':
runs = atoi(optarg);
break;
case 's':
seed = atoi(optarg);
break;
/* sync file before mapping */
case 'S':
syncfile = 1;
break;
default:
usage();
}
@@ -623,7 +628,7 @@ main(int argc, char **argv)
exit(1);
}
rc = compare_fiemap_and_map(fd, map, blocks, blocksize);
rc = compare_fiemap_and_map(fd, map, blocks, blocksize, syncfile);
if (rc) {
printf("Problem comparing fiemap and map\n");
free(map);