This patch adds support for FIEMAP and leaves the current FIBMAP
approach in place as a fallback. Instead of trying to guess extents from
FIBMAP block maps, it directly uses extents as fragments.
The logic is similar as it merges adjecent extents as one fragment. It
also detects hole extents and inlined extents and doesn't account those
as fragments similar to the FIBMAP approach.
It optimizes handling filesystems with tail support (e.g., reiserfs) by
not accounting tailed extents as fragments, as the rewrite process
probably would tail the last extent again.
Similarily it tries to optimize for file systems that support shared
extents (xfs, btrfs) by not accounting such extents as fragments. This
helps preventing unsharing accused files and thus increasing space
usage. I pretend that keeping shared extents is more important than
continuous extents, as the operation of deduplicating those extents in
the first place is known to fragment those files.
However, if the heuristics decide to shake the file, extents still
become unshared. I have no idea currently how to optimize for that, thus
it is not part of this patch.
This patch adds support for FIEMAP and leaves the current FIBMAP approach in place as a fallback. Instead of trying to guess extents from FIBMAP block maps, it directly uses extents as fragments.
The logic is similar as it merges adjecent extents as one fragment. It also detects hole extents and inlined extents and doesn't account those as fragments similar to the FIBMAP approach.
It optimizes handling filesystems with tail support (e.g., reiserfs) by not accounting tailed extents as fragments, as the rewrite process probably would tail the last extent again.
Similarily it tries to optimize for file systems that support shared extents (xfs, btrfs) by not accounting such extents as fragments. This helps preventing unsharing accused files and thus increasing space usage. I pretend that keeping shared extents is more important than continuous extents, as the operation of deduplicating those extents in the first place is known to fragment those files.
However, if the heuristics decide to shake the file, extents still become unshared. I have no idea currently how to optimize for that, thus it is not part of this patch.
This is also part of my integration branch.
This change is