maharmstone / btrfs

WinBtrfs - an open-source btrfs driver for Windows
GNU Lesser General Public License v3.0
5.75k stars 222 forks source link

Feature request: Defragmentation #137

Open Atemu opened 5 years ago

Atemu commented 5 years ago

Since all compression algorithms of mainline Linux are supported now, being able to switch between them would be awesome.

Zero3K commented 5 years ago

How does that have to do with defragging the drive?

Atemu commented 5 years ago

Like many other "basic" filesystem features, defragmenting works a bit differently on BTRFS.
AFAIK all the btrfs filesystem defragment command does is rewrite an entire file in-place which causes the file's blocks to be put through the BTRFS write pipeline again.
The blocks are read from the file sequentially which means that they'll also be written sequentially and since a file is fragmented when the files's blocks aren't sequential, it's no longer fragmented when it's rewritten sequentially.

When a file's blocks are rewritten, they're also recompressed and the btrfs filesystem defragment command allows you to choose which algorithm should be used for that on Linux (e.g. -czstd).
This is currently the only way to change the compression algorithm on an already written file on Linux BTRFS and it'd be helpful if that were possible on WinBTRFS aswell.

Zero3K commented 5 years ago

That makes sense after you explained it.