Pádraig Brady wrote: ... > OK thanks for the info. So: > > XFS may miss some extents for sparse files before 2.6.36 > BTRFS and EXT4 need a sync before fiemap() before 2.6.38 > BTRFS can return overlapping extents before 2.6.38 > > It seems like we should at least detect overlapping extents in our: > http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/extent-scan.c;hb=HEAD > and return false (don't use fiemap) in this case. > We've already stopped doing the lseeks() but that assumes non overlapping > extents. > > So if we do the above we avoid corruption on BTRFS. > We could also change to only enabling FIEMAP_FLAG_SYNC before 2.6.38? > That still doesn't account for the XFS issue which was only fixed > in a released kernel 5 months ago, and that leans towards > us changing cp to just not use fiemap before 2.6.38 as you suggest. > That allows us to remove the FIEMAP_FLAG_SYNC too.
Good summary. That latter is simpler and gets my vote: don't use FIEMAP with a pre-2.6.38 kernel