[PATCH] xfs_io: fix extent array reallocation

Christoph Hellwig hch at infradead.org
Fri Mar 20 02:26:18 CDT 2009


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.


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,




More information about the xfs mailing list