]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfstests: Add query fiemap count test.
authorTao Ma <tao.ma@oracle.com>
Tue, 4 May 2010 06:01:00 +0000 (16:01 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 4 May 2010 06:01:00 +0000 (16:01 +1000)
According to Documentation/filesystems/fiemap.txt, If fm_extent_count
is zero, then the fm_extents[] array is ignored (no extents will be
returned), and the fm_mapped_extents count will hold the number of
extents needed.

This is broken by commit 97db39a1f6f69e906e98118392400de5217aa33a.
So add this test case in fiemap tester to avoid future regression.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Reviewed-by: Dave Chinner <david@fromorbit.com>
src/fiemap-tester.c

index acec1b5563d8297925edd79a4a95be0d19fc0237..138acbf02a17843562b60d56d4c5f392648ef25e 100644 (file)
@@ -402,6 +402,20 @@ check_hole(struct fiemap *fiemap, int fd, __u64 logical_offset, int blocksize)
        return 0;
 }
 
+static int query_fiemap_count(int fd, int blocks, int blocksize)
+{
+       struct fiemap fiemap = { 0, };
+
+       fiemap.fm_length = blocks * blocksize;
+
+       if (ioctl(fd, FS_IOC_FIEMAP, (unsigned long)&fiemap) < 0) {
+               perror("FIEMAP query ioctl failed");
+               return -1;
+       }
+
+       return 0;
+}
+
 static int
 compare_fiemap_and_map(int fd, char *map, int blocks, int blocksize)
 {
@@ -411,6 +425,9 @@ compare_fiemap_and_map(int fd, char *map, int blocks, int blocksize)
        __u64 map_start, map_length;
        int i, c;
 
+       if (query_fiemap_count(fd, blocks, blocksize) < 0)
+               return -1;
+
        blocks_to_map = (random() % blocks) + 1;
        fiebuf = malloc(sizeof(struct fiemap) +
                        (blocks_to_map * sizeof(struct fiemap_extent)));