From f6d1a56367179f41a3eac1a1481863586015ff0d Mon Sep 17 00:00:00 2001 From: Tomasz Majkowski Date: Fri, 20 Mar 2009 17:01:58 +0100 Subject: [PATCH] xfs_io: fix extent array reallocation 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 Reviewed-by: Felix Blyakher --- io/bmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/io/bmap.c b/io/bmap.c index db1496ccc..f79cf8cc4 100644 --- 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, -- 2.47.2