Fix fiemap-tester for fewer extents returned
authorEric Sandeen <sandeen@sandeen.net>
Tue, 8 Mar 2011 15:09:38 +0000 (09:09 -0600)
committerEric Sandeen <sandeen@sandeen.net>
Tue, 8 Mar 2011 15:09:38 +0000 (09:09 -0600)
If the fiemap call returns fewer extents than asked for,
the fiemap tester gets confused.  If this happens, advance,
and call fiemap again for the next offset.

XFS exposed this because if a file is all-delalloc, it was
only returning 1 mapped extent (this is probably also a buglet).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Alex Elder <aelder@sgi.com>
src/fiemap-tester.c

index f6875af30b81eed534bde81021446c57cb369f88..53d7a640bbd78687a2600cd5d4374f72159d9767 100644 (file)
@@ -467,8 +467,10 @@ compare_fiemap_and_map(int fd, char *map, int blocks, int blocksize)
                for (i = cur_extent, c = 1; i < blocks; i++, c++) {
                        __u64 logical_offset = i * blocksize;
 
                for (i = cur_extent, c = 1; i < blocks; i++, c++) {
                        __u64 logical_offset = i * blocksize;
 
-                       if (c > blocks_to_map)
+                       if (c > fiemap->fm_mapped_extents) {
+                               i++;
                                break;
                                break;
+                       }
 
                        switch (map[i]) {
                        case 'D':
 
                        switch (map[i]) {
                        case 'D':