]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_io: fix extent array reallocation
authorTomasz Majkowski <moosh009@gmail.com>
Fri, 20 Mar 2009 16:01:58 +0000 (17:01 +0100)
committerChristoph Hellwig <hch@brick.lst.de>
Fri, 20 Mar 2009 16:01:58 +0000 (17:01 +0100)
The XFS_IOC_FSGETXATTRA ioctl only returns the number of allocated
extents, so when we reallocate the extent array in the bmap command
we have to account for the worst case where there is a whole between
each two allocated extents.  Also add some slack to that case to
allow for a file growing while we are racing with it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Felix Blyakher <felixb@sgi.com>
io/bmap.c

index db1496cccdcfe66fbd15aefb2d14cf099975e5df..f79cf8cc4c4540346b83e3c5d307d083c90ac32e 100644 (file)
--- a/io/bmap.c
+++ b/io/bmap.c
@@ -217,8 +217,8 @@ bmap_f(
                        exitcode = 1;
                        return 0;
                }
-               if (fsx.fsx_nextents >= map_size-1) {
-                       map_size = 2*(fsx.fsx_nextents+1);
+               if (2 * fsx.fsx_nextents > map_size) {
+                       map_size = 2 * fsx.fsx_nextents + 1;
                        map = realloc(map, map_size*sizeof(*map));
                        if (map == NULL) {
                                fprintf(stderr,