# "PSA: Linux 5.16 has major regression in btrfs causing extreme IO load"

**URL:** <https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446>\
**Category:** Lounge\
**Created:** [January 31, 2022, 12:03pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446 "2022-01-31T12:03:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![EOS](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/eos/32/121414_2.png) [@EOS](https://forum.endeavouros.com/u/EOS)\
**Post date:** [January 31, 2022, 12:03pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/1 "2022-01-31T12:03:30Z")

</div>

The BTRFS file system and Linux 5.16 may cause significant ssd disk wear if the autodefrag mount option is enabled.

> Linux 5.16 saw some changes in the btrfs defragmentation code which introduced a regression that causes extreme write IO (and associated single-core 100% CPU load by a kernel thread named `btrfs-cleaner`). Apparently it’s defragmenting in an infinite loop.
> 
> It’s affecting volumes mounted with `-o ssd,autodefrag`, which is the default in most distributions.
> 
> This has the potential to wear out an SSD in a matter of weeks: on my Samsung PM981 Polaris 512GB this lead to 188 TB of writes in 10 days or so. That’s several years of endurance gone. 370 full drive overwrites.
> 
> The workaround is to disable autodefrag until this is resolved: `mount -o remount,noautodefrag /` and change `autodefrag` to `noautodefrag` in your `/etc/fstab`.
> 
> Relevant linux mailing list thread: [https://lore.kernel.org/linux-btrfs/CAEwRaO4y3PPPUdwYjNDoB9m9CLzfd3DFFk2iK1X6OyyEWG5-mg@mail.gmail.com/](https://lore.kernel.org/linux-btrfs/CAEwRaO4y3PPPUdwYjNDoB9m9CLzfd3DFFk2iK1X6OyyEWG5-mg@mail.gmail.com/)

Original post: [www.reddit.com](https://www.reddit.com/r/linux/comments/sgybyr/psa_linux_516_has_major_regression_in_btrfs/)

---

<div class="post-metadata">

**Author:** ![keybreak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/keybreak/32/9257_2.png) [@keybreak](https://forum.endeavouros.com/u/keybreak)\
**Post date:** [January 31, 2022, 12:47pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/2 "2022-01-31T12:47:25Z")

</div>

🤡 fs

---

<div class="post-metadata">

**Author:** ![I0F](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/i0f/32/47182_2.png) [@I0F](https://forum.endeavouros.com/u/I0F)\
**Post date:** [January 31, 2022, 12:47pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/3 "2022-01-31T12:47:45Z")

</div>

Well, now I’m happy I was too lazy changing to btrfs on friday. Being lazy sometimes works out…

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [January 31, 2022, 12:51pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/4 "2022-01-31T12:51:40Z")

</div>

Pinned globally on January 31, 2022, 12:51pm UTC



---

<div class="post-metadata">

**Author:** ![pebcak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/pebcak/32/100472_2.png) [@pebcak](https://forum.endeavouros.com/u/pebcak)\
**Post date:** [January 31, 2022, 1:05pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/5 "2022-01-31T13:05:05Z")

</div>

Thanks for posting this!  
I have been watching the terminal output of `sudo iotop -a` on and off for a past couple of weeks.  
I did notice an unusually high write rate associated with another btrfs process as well, namely `btrfs-transaction` (?).  
I wanted to post about it on the forum and ask about it but I didn’t get around doing it.

Below is an screenshot of the terminal output of `sudo iotop -a` after 5 minutes uptime with nothing else but the system running:

![iotop-5min.](https://forum.endeavouros.com/uploads/default/original/3X/b/7/b7a970fa01246f3d3a54e9846f99f688c2b6508b.jpeg)

here is another one after 20 minutes uptime, with Firefox (one tab) running in the background:

![Screenshot from 2022-01-31 14-00-33](https://forum.endeavouros.com/uploads/default/original/3X/f/b/fbb7497328d93b3bf94a675b1afe8257dae4635d.jpeg)

Does anyone know it this is also related to the above mentioned regression?

I need to add that this is after I applied the workaround posted above.

---

<div class="post-metadata">

**Author:** ![keybreak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/keybreak/32/9257_2.png) [@keybreak](https://forum.endeavouros.com/u/keybreak)\
**Post date:** [January 31, 2022, 1:07pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/6 "2022-01-31T13:07:51Z")

</div>

> [@pebcak](#):
>
> iotop

Thx, i was looking for similar tool on Linux for long! 👍

---

<div class="post-metadata">

**Author:** ![pebcak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/pebcak/32/100472_2.png) [@pebcak](https://forum.endeavouros.com/u/pebcak)\
**Post date:** [January 31, 2022, 1:21pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/7 "2022-01-31T13:21:21Z")

</div>

I found this post from almost 5 years (!) ago:

> <https://superuser.com/questions/1211324/btrfs-transacti-writes-to-disk-every-30-seconds>

So, it seems the issue with autodefrag and `btrfs-transacti` is not a new one?

I would appreciate if forummates with more knowledge about the ins and outs of BTRFS could shed some light on this.

---

<div class="post-metadata">

**Author:** ![anon49550872](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@anon49550872](https://forum.endeavouros.com/u/anon49550872)\
**Post date:** [January 31, 2022, 1:26pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/8 "2022-01-31T13:26:47Z")

</div>

I checked the `sudo iotop -a`, and indeed btrfs transaction and btrfs cleaner were there…  
Then, removed `ssd,autodefrag` from btrfs fs in fstab, rebooted and now, no more btrfs transaction/cleaner are showing up…

---

<div class="post-metadata">

**Author:** ![Schlaefer](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/schlaefer/32/11917_2.png) [@Schlaefer](https://forum.endeavouros.com/u/Schlaefer)\
**Post date:** [January 31, 2022, 1:27pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/9 "2022-01-31T13:27:41Z")

</div>

> [@pebcak](#):
>
> So, it seems the issue with autodefrag and `btrfs-transacti` is not a new one?

Thirty seconds is the default [btrfs commit interval](https://wiki.archlinux.org/title/Btrfs#Commit_interval), I assume this is what this user was observing and curious about. These issues are definitely new in 5.16.

---

<div class="post-metadata">

**Author:** ![pebcak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/pebcak/32/100472_2.png) [@pebcak](https://forum.endeavouros.com/u/pebcak)\
**Post date:** [January 31, 2022, 1:30pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/10 "2022-01-31T13:30:41Z")

</div>

I did change autodefrag to noautodefrag as mentioned in OP. After reboot I still got `btrfs-transacti` running and writing 🤔

---

<div class="post-metadata">

**Author:** ![pebcak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/pebcak/32/100472_2.png) [@pebcak](https://forum.endeavouros.com/u/pebcak)\
**Post date:** [January 31, 2022, 1:33pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/11 "2022-01-31T13:33:59Z")

</div>

systemd-journald seems to do a whole lot of writing as was mentioned in the post I linked to above.

The proposed solution:

> 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.

Is this the thing that needs to be done then?

---

<div class="post-metadata">

**Author:** ![jonathon](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/jonathon/32/18722_2.png) [@jonathon](https://forum.endeavouros.com/u/jonathon)\
**Post date:** [January 31, 2022, 1:37pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/12 "2022-01-31T13:37:37Z")

</div>

There’s some good detail about the increased IO in the kernel mailing list thread.

There are two main issues:

1. Defragmenting 1 byte files will cause an infinite loop;
2. The algorithm looks for candidates more correctly than in 5.15, therefore identifying more opportunities for correct defragmentation.

Case 1 is obviously a bug. Case 2 is less of a bug, and an older BTRFS filesystem will see much more defragmentation activity because it hasn’t been defragmented fully since changes in 5.10 vastly reduced the scope of candidate data.

There are some patches in the mailing list thread that should be making their way into the kernel at some point; they aren’t present as of 5.15.4.

---

<div class="post-metadata">

**Author:** ![anon49550872](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@anon49550872](https://forum.endeavouros.com/u/anon49550872)\
**Post date:** [January 31, 2022, 1:41pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/13 "2022-01-31T13:41:27Z")

</div>

Does noautodefrag has the same effect as removing autodefrag from the fstab ?

---

<div class="post-metadata">

**Author:** ![jonathon](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/jonathon/32/18722_2.png) [@jonathon](https://forum.endeavouros.com/u/jonathon)\
**Post date:** [January 31, 2022, 1:42pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/14 "2022-01-31T13:42:43Z")

</div>

It will depend on the defaults. `noautodefrag` will make the option explicit.

---

<div class="post-metadata">

**Author:** ![anon49550872](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@anon49550872](https://forum.endeavouros.com/u/anon49550872)\
**Post date:** [January 31, 2022, 1:43pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/15 "2022-01-31T13:43:52Z")

</div>

It seems removing autodefrag is enough for me, thanks jonathon.

```auto
$ sudo mount | grep btrfs
/dev/sda2 on / type btrfs (rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/@)

```

---

<div class="post-metadata">

**Author:** ![pebcak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/pebcak/32/100472_2.png) [@pebcak](https://forum.endeavouros.com/u/pebcak)\
**Post date:** [January 31, 2022, 1:45pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/16 "2022-01-31T13:45:56Z")

</div>

Don’t know.  
I wonder how come in your case btrfs-transacti is also gone.  
So if I interpret @jonathon correctly, both removing and make the option explicit should have the same result. 🤔

---

<div class="post-metadata">

**Author:** ![bittin](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/bittin/32/30588_2.png) [@bittin](https://forum.endeavouros.com/u/bittin)\
**Post date:** [January 31, 2022, 1:46pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/17 "2022-01-31T13:46:59Z")

</div>

Thanks for the information, turned off autodefrag

---

<div class="post-metadata">

**Author:** ![Schlaefer](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/schlaefer/32/11917_2.png) [@Schlaefer](https://forum.endeavouros.com/u/Schlaefer)\
**Post date:** [January 31, 2022, 1:57pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/18 "2022-01-31T13:57:39Z")

</div>

> [@pebcak](#):
>
> systemd-journald seems to do a whole lot of writing as was mentioned in the post I linked to above.

If journald writes a lot of log data I would look into why it writes so much data. One can make a case to handle `/var/log` somewhat differently - and some installations do - but on a normal desktop system that’s more of an advanced optimization than a necessity. If you have never tinkered with btrfs subvolumes and no reason otherwise to do so I would recommend not to bother.

---

<div class="post-metadata">

**Author:** ![mbod](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/mbod/32/16833_2.png) [@mbod](https://forum.endeavouros.com/u/mbod)\
**Post date:** [January 31, 2022, 2:06pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/19 "2022-01-31T14:06:31Z")

</div>

The impact of this is more dramatic than the title suggests. From the reddit note:

> This has the potential to wear out an SSD in a matter of weeks: on my Samsung PM981 Polaris 512GB this lead to 188 TB of writes in 10 days or so. That’s several years of endurance gone. 370 full drive overwrites.

Potential hardware damage and complete data loss. This should not go unnoticed by any EndeavourOS user. But I am afraid that many of them do not follow this forum.

I am wondering if there is any good way to fix all(!) endeavouros installations with a mandatory package. Or at least a note in BIG LETTERS when a 5.16 is installed or updated.

---

<div class="post-metadata">

**Author:** ![keybreak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/keybreak/32/9257_2.png) [@keybreak](https://forum.endeavouros.com/u/keybreak)\
**Post date:** [January 31, 2022, 2:10pm UTC](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446/20 "2022-01-31T14:10:16Z")

</div>

The only way is not to use 🤡 fs i’m afraid (since it was known to having that kind of problems from time to time), and even if there were some centralized backdoor in EndeavourOS (@joekamprad 🤫), i doubt it would be good idea to knowingly have such ability, even if it were used for good intention…

[Next page](https://forum.endeavouros.com/t/psa-linux-5-16-has-major-regression-in-btrfs-causing-extreme-io-load/23446.md?page=2)
