If I do
btrfs fi defrag -rv /home
then I get a long list of files which needs to be defragmented.
It seams as if it doesn't actually do anything.
Is it possible to see how far in the defrag progess it is?
If I do
btrfs fi defrag -rv /home
then I get a long list of files which needs to be defragmented.
It seams as if it doesn't actually do anything.
Is it possible to see how far in the defrag progess it is?
You can use -f to flush, otherwise it works in batches and may stall. If it's printed the file then it's done, subject to caching / locking (hopefully not any filesystem errors).
-f flush data for each file before going to the next file.
-r defragment files recursively in given directories.
Note: Directory arguments without -r do not defragment files recursively but will defragment certain internal trees (extent tree and the subvolume tree). This has been confusing and could be removed in the future.
-v be verbose.
$ btrfs filesystem defrag -v -r dir/
Recursively defragment files under dir/, print files as they are processed. The file names will be printed in batches, similarly the amount of data triggered by defragmentation will be proportional to last N printed files. The system dirty memory throttling will slow down the defragmentation but there can still be a lot of IO load and the system may stall for a moment.
$ btrfs filesystem defrag -v -r -f dir/
Recursively defragment files under dir/, be verbose and wait until all blocks are flushed before processing next file. You can note slower progress of the output and lower IO load (proportional to currently defragmented file).