Tao Ma 9af2546508 xfs: Make fiemap work with sparse files
In xfs_vn_fiemap, we set bvm_count to fi_extent_max + 1 and want
to return fi_extent_max extents, but actually it won't work for
a sparse file. The reason is that in xfs_getbmap we will
calculate holes and set it in 'out', while out is malloced by
bmv_count(fi_extent_max+1) which didn't consider holes. So in the
worst case, if 'out' vector looks like
[hole, extent, hole, extent, hole, ... hole, extent, hole],
we will only return half of fi_extent_max extents.

This patch add a new parameter BMV_IF_NO_HOLES for bvm_iflags.
So with this flags, we don't use our 'out' in xfs_getbmap for
a hole. The solution is a bit ugly by just don't increasing
index of 'out' vector. I felt that it is not easy to skip it
at the very beginning since we have the complicated check and
some function like xfs_getbmapx_fix_eof_hole to adjust 'out'.

Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
2010-09-03 09:02:11 -05:00
..
2010-07-26 13:16:33 -05:00
2009-06-10 17:07:47 +02:00
2010-05-21 18:31:19 -04:00
2009-06-10 17:07:47 +02:00
2009-12-14 23:08:16 -06:00
2009-03-29 09:51:14 +02:00
2009-03-29 09:55:42 +02:00
2008-12-01 11:37:35 +11:00
2010-07-26 13:16:44 -05:00
2010-07-26 16:07:38 -05:00
2009-08-31 14:46:22 -05:00
2010-07-26 13:16:44 -05:00
2010-07-26 13:16:44 -05:00
2010-07-26 13:16:33 -05:00
2010-07-26 13:16:52 -05:00
2010-07-26 13:16:52 -05:00
2010-08-09 16:47:42 -04:00
2010-03-01 16:35:44 -06:00
2009-12-14 23:08:16 -06:00