defragall is a simple utility which allows you to defragment all Btrfs subvolumes mounted on your system, in a single command.
Type git submodule update --init to download the AUR repository.
Just type make.
Type sudo make install. But if you want to choose another root, so type sudo make INSTALL_ROOT='my_root' install. If you are on a system based on Archlinux, the package is available on AUR.
Type defragall -h to get help. The commands are based on btrfs filesystem defragment. The program creates a log file whose absolute path is /var/log/defragall.log.