]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_io: fix fiemap loop continuation
authorDave Chinner <dchinner@redhat.com>
Thu, 2 Feb 2012 06:21:14 +0000 (17:21 +1100)
committerChristoph Hellwig <hch@lst.de>
Sun, 5 Feb 2012 14:00:35 +0000 (14:00 +0000)
When the fiemap command needs to retrieve more extents from the
kernel via a subsequent IO, it calculates the next logical block to
retrieve in file system block units. the fiemap needs the start
offset in bytes, not filesystem blocks.  Hence if the fiemap command
can loop forever retrieving the same blocks if the logical offset
offset of the next block in filesystem block units is smaller than
the number of bytes in a filessytem block. i.e. it will just loop
retreiving the first 32 extents from offset block zero.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
io/fiemap.c

index 066e693f14f92106c9bba5e3d6aece308107f6af..99296ddbafeecbe3f12ee0f9c1cdf40c9ef553bc 100644 (file)
@@ -108,7 +108,7 @@ print_verbose(
               boff_w, bbuf, tot_w, len, flg_w, flgbuf);
 
        (*cur_extent)++;
-       *last_logical = lstart + len;
+       *last_logical = extent->fe_logical + extent->fe_length;
 }
 
 static void
@@ -151,7 +151,7 @@ print_plain(
        else
                printf("\n");
        (*cur_extent)++;
-       *last_logical = lstart + len;
+       *last_logical = extent->fe_logical + extent->fe_length;
 }
 
 int
@@ -252,7 +252,7 @@ fiemap_f(
                memset(fiemap, 0, map_size);
                fiemap->fm_flags = fiemap_flags;
                fiemap->fm_start = last_logical;
-               fiemap->fm_length = -1;
+               fiemap->fm_length = -1LL;
                fiemap->fm_extent_count = num_extents;
 
                ret = ioctl(file->fd, FS_IOC_FIEMAP, (unsigned long)fiemap);