I still find the defrag tool a little bit confusing from a user perspective: - Does the recursive defrag (-r) also defrag the specified directory's extent tree or should one run two separate commands for completeness (one with -r and one without -r)? - What's the target scope of the extent tree defragmentation? Is it recursive on the tree (regardless of the -r option) and thus defragments all the extent trees in case one targets the root subvolume?
In other words: What is the exact sequence of commands if one wishes to defragment the whole filesystem as extensively as possible (all files and extent trees included)? There used to be a scrip floating around on various wikis (for example, the Arch Linux wiki) which used the "find" tool to feed each and every directory to the defrag command. I always thought that must be overkill and now it's gone, but I don't see further explanations and/or new scripts in place (other than a single command with the -r option). It's also a little mystery for me if balancing the metadata chunks is supposed to be effectively defragmenting the metadata or not and what the best practice regarding that issue is. In my personal experience Btrfs filesystems tend to get slower over time, up to the point where it takes several minutes to mount them or to delete some big files (observed on HDDs, not on SSDs where the sheer speed might masks the problem and filesystem tends to be smaller anyway). When it gets really bad, Gentoo's localmount script starts to time out on boot and Samba based network file deletions tend to freeze the client Windows machine's file explorer. It only takes 3-6 months and/or roughly 10-20 times of the total disk(s) capacity's worth of write load to get there. Defrag doesn't seem to help with that but running a balance on each and every metadata blocks (data and system blocks can be skipped) seems to "renew" it (no more timeouts or noticeable delays on mount, metadata operation are as fast as expected, it works like a young filesystem...). One might expect that targeting the root subvolume with a recursive defrag will take care of metadata fragmentation as well but it doesn't seem to be the case and I don't see anybody recommending regular matadata balancing. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html