* [PATCH] xfs_io: fix extent array reallocation
@ 2009-03-20 7:26 Christoph Hellwig
2009-03-20 14:33 ` Felix Blyakher
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2009-03-20 7:26 UTC (permalink / raw)
To: xfs, moosh009
From: Tomasz Majkowski <moosh009@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,
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] xfs_io: fix extent array reallocation
2009-03-20 7:26 [PATCH] xfs_io: fix extent array reallocation Christoph Hellwig
@ 2009-03-20 14:33 ` Felix Blyakher
0 siblings, 0 replies; 2+ messages in thread
From: Felix Blyakher @ 2009-03-20 14:33 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: moosh009, xfs
On Mar 20, 2009, at 2:26 AM, Christoph Hellwig wrote:
> From: Tomasz Majkowski <moosh009@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@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@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-20 14:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-20 7:26 [PATCH] xfs_io: fix extent array reallocation Christoph Hellwig
2009-03-20 14:33 ` Felix Blyakher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox