On Mon, Jun 14, 2010 at 10:27:06AM +1000, Dave Chinner wrote:yeah, that should work and I will try to generate a patch for it.
On Sat, Jun 12, 2010 at 10:08:15AM +0800, Tao Ma wrote:
The reason is that in xfs_getbmap we willRight, it's not broken, we simply return less than fi_extent_mex
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.
extents when there are holes. I don't see that as a problem as
applications have to handle that case anyway, and....
So in xfs_vn_fiemap, we should consider this worst case. If theThat's rather dangerous, I think. It relies on other code to catch
user wants fi_extent_max extents, we need a 'out' with size of
2 *fi_extent_max + 2(one more the header).
the buffer overrun that this sets up for fragmented, non-sparse
files. Personally I'd much prefer to return fewer extents for sparse
files than to add a landmine like this into the kernel code....
I just had a thought - if you want to avoid holes being reported to
fiemap, then add a BMV_IF_NO_HOLES flag to xfs_getbmap() and skip
holes in the mappin gloop when this flag is set. That will make
fiemap fill in the full number of extents without hacking the
extent count...