BTRFS Maintenance and the SSD parameter

I stumbled across this discussion about the ssd parameter that I’d been using in my installation guide and realized that I was very likely afflicted by what was being disucssed in the mailing list. Firing up IRC and jumping into the #btrfs discussion on freenode to ask for some clarification about how I’d examine my current state.

Luckily I was able to talk with several knowledgeable people, and even knorrie who was the original author of the mailing list discussion above. I was advised to look at the relative delta between the total and used counts while doing a btrfs fi df /:

$ btrfs filesystem df /
Data, single: total=441.01GiB, used=352.51GiB
System, single: total=4.00MiB, used=80.00KiB
Metadata, single: total=3.01GiB, used=1.09GiB
GlobalReserve, single: total=494.16MiB, used=0.00B

As it was pretty large knorrie suggested that I rebalance, but use his heatmap utility to visualize the progress.

<Knorrie> ok, so bright white is good
<Knorrie> and we need to get rid of the dark stuff

I ran a balance action via his python-btrfs example and was able to call his heatmap utility via watch and stitch it together for a movie:

Low and behold the results!

$ btrfs filesystem df /
Data, single: total=353.01GiB, used=352.52GiB
System, single: total=4.00MiB, used=64.00KiB
Metadata, single: total=3.01GiB, used=1.09GiB
GlobalReserve, single: total=489.78MiB, used=0.00B

If you’d like to do the following, with pictures and videos, check out heatmap. If you’d just like to know how to do the maintenance then I’d suggest the simplest form of balance as:

btrfs balance start -dusage=99 /

or alternatively:

btrfs balance start /

you can check on the progress with btrfs balance status /

This is an entirely ignorant approach and you should consider (like I plan to do in the near future) reading up on how other people are doing maintenance.