Re: Files full of zeros with coreutils-8.11 and xfs (FIEMAP related?)

Christoph Hellwig
2011-04-20T15:26:32Z

On Wed, Apr 20, 2011 at 07:08:25AM +1000, Dave Chinner wrote:
> So, it logically follws that you need to use the SYNC flag for both
> unwritten extents and delalloc extents to find out where there data
> realy lies by converting them to real, written extents. i.e. the
> only extents you can trust contain data from FIEMAP are the real
> extents on disk....

Even more funny is that the bug report that started this thread involved
software that didn't actually care about the location on disk, at all.

cp from coreutils really just wanted an efficient way to skip holes
in sparse files, and we got into a chain reaction of various flaws
and oversights :

(1) Linux lacks the SEEK_HOLE/SEEK_DATA interface that would make
skipping holes trivial and thus coreutils has to use FIEMAP.
(2) ext4 and btrfs in some cases mishandled reporting delalloc
extents, which means coreutils had to add the sync flag,
despite not caring where data is on disk
(3) coreutils tried to treat unwrittent extents as holes. Which
makes some sense given their high-level description, although
probably not too much in practice given that we explicitly
allocated blocks to these "holes" to optimize performance.
But the main issue here is that there is no documentation
that clearly states that unwrittent extents reported by
FIEMAP may actually contain useful data. In fact there's
no useful documentation for FIEMAP outside the kernel tree.
And interface that complex really needs a manpage.