[PATCH] xfs_io: fix extent array reallocation
Felix Blyakher
felixb at sgi.com
Fri Mar 20 09:33:29 CDT 2009
On Mar 20, 2009, at 2:26 AM, Christoph Hellwig wrote:
> From: Tomasz Majkowski <moosh009 at gmail.com>
>
> 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.
Reviewed-by: Felix Blyakher <felixb at sgi.com>
>
>
>
> Index: xfsprogs-dev/io/bmap.c
> ===================================================================
> --- xfsprogs-dev.orig/io/bmap.c 2009-03-20 06:28:33.000000000 +0000
> +++ xfsprogs-dev/io/bmap.c 2009-03-20 06:29:52.000000000 +0000
> @@ -217,8 +217,8 @@
> 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,
>
> _______________________________________________
> xfs mailing list
> xfs at oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
More information about the xfs
mailing list