unbrice / shake

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

Add support for FIEMAP v2 #16

Closed kakra closed 2 years ago

kakra commented 7 years ago

This v2 branch fixes some issue that sneaked in while I rebased my previous work to split out separate patches.

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 change is Reviewable

unbrice commented 2 years ago

Hey :) I'm doing a spring cleanup of old pull requests, please do reopen if you're later interested in resolving the open threads.

kakra commented 2 years ago

I'm fine with cleaning up... After such a long time, I'd need to rethink from scratch again anyways. I still have the local branches which I could rebase if needed.