btrfs-transacti writes to disk every 30 seconds

3

3

I'm running Ubuntu 16.04.2 LTS with btrfs on 4 8 TB Seagate drives in RAID 1. Every 30 seconds btrfs-transacti shows up in iotop with ca. 80 M/s for 15 seconds, even when the system is not used. The system is only used for storing backups once a day, but has disc activity all day.

How can I find out what causes these write peaks and how can I stop it?

Christian

Posted 2017-05-21T09:34:09.847

Reputation: 33

I'm seeing something similar, btrfs-transacti writes around 1 MB of data roughly every 30 seconds, slowly eating though my SSD. I already moved a bunch of active cache data to tmpfs ramdisks and made sure /var/log has +C and the fs was mounted without autodefrag, but no improvement. – Cobra_Fast – 2018-09-13T17:12:42.347

Answers

2

I believe it is btrfs autodefrag. I get those as well. This is an option that has to be set explicitly in the fstab, but many people do and recommend it, especially on spinning rust hard drives. SSDs don't really care about fragments produced by copy-on-write.

Then, if your /var/log directory is on btrfs, I believe you end up defragging the systemd journal files quite often.

One thing that Fedora does but I'm not sure about Ubuntu, is it marks the /var/log/journal directory and all subdirectories and files with chattr +C. The 'C' attribute marks it as not copy-on-write, which means btrfs reads and writes it much as ext4 or xfs would.

Using the "C" attribute prevents large amounts of fragmentation or autodefrag writes but also means the file isn't protected by checksums.

Even though I'm not sure of your exact situation it's my best guess that you have /var/log/journal on btrfs, with autodefrag set, and without the C attribute. Which would explain the constant writes throughout the day, and the large amount of use in the btrfs-transaction threads.

Zan Lynx

Posted 2017-05-21T09:34:09.847

Reputation: 1 518

I cannot check your assumptions any more, because I replaced Ubuntu with openmediavault. There I don't see this behaviour. So probably you are right - maybe a wrong setting of attributes might have been the cause. – Christian – 2018-03-05T10:42:08.537