[systemd-devel] journal fragmentation on Btrfs

Chris Murphy lists at colorremedies.com
Mon Apr 17 17:50:04 UTC 2017


Here's an example rotated log (Btrfs, NVMe, no compression, default
ssd mount option). As you can see it takes up more space on disk than
it contains data, so there's a lot of slack space for some reason,
despite /etc/systemd/journald.conf being unmodified and thus
Compress=Yes.

file: system at 2547b430ecdc441c9cf82569eeb22065-0000000000000001-00054c3c31bec567.journal
extents 41 disk size 143511552 logical size 100663296 ratio 0.70

$ sudo btrfs fi defrag -c
system at 2547b430ecdc441c9cf82569eeb22065-0000000000000001-00054c3c31bec567.journal

And now:

file: system at 2547b430ecdc441c9cf82569eeb22065-0000000000000001-00054c3c31bec567.journal
extents 768 disk size 21504000 logical size 100663296 ratio 4.68

That's nearly 1/7th smaller. The existing defrag without compression
is probably just increasing write amplification on SSDs. If it's badly
fragmented just leave it alone.

This also works on nocow journals with +C set, although I'm not sure
whether this is intended behavior (I thought nocow implies no
compression); so I've asked about that on the Btrfs list.

Chris Murphy


More information about the systemd-devel mailing list