unbrice / shake

Shake is a defragmenter that runs in userspace
Other
44 stars 5 forks source link

Add support for FIEMAP #7

Closed kakra closed 7 years ago

kakra commented 7 years ago

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 Reviewable

kakra commented 7 years ago

This should fix issue #1.

kakra commented 7 years ago

Brice, I think I need to redo this. Something seems to have gone wrong during rebasing the patch:

  1. fragsize in the FIEMAP branch seems to be always zero while looking at the code
  2. the "goto out" block is there twice now
kakra commented 7 years ago

Superseded by #16, closing.