BTRFS "discard storm" on 6.2.x kernel

Some btrfs disks seem to have problems with the new discard=async option:

PSA: new 6.2 kernel introduced “silently” a BTRFS feature that is on by default, that is “discard=async” option. Unless you have “nodiscard” specified in your fstab then this will be on.

Kernel commit:

63a7cb13071842 “btrfs: auto enable discard=async when possible”

On some, systems this can cause “discard storm”. The link to kernel list reporting this issue:

https://www.spinics.net/lists/linux-btrfs/msg133128.html

Original reddit post: BTRFS “discard storm” on 6.2.x kernel

3 Likes

I added the nodiscard option, but I can’t tell if it’s working or not. Even after a reboot, my BTRFS mounts look like this:

/dev/sdb3 on / type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=256,subvol=/@)
/dev/sdb3 on /srv/nfs/nix-store type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=256,subvol=/@)
/dev/sdb3 on /var/cache type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=257,subvol=/@cache)
/dev/sdb3 on /var/log type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=258,subvol=/@log)
/dev/sdb4 on /home type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=5,subvol=/)
/dev/sdb4 on /srv/nfs/downloads type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=286,subvol=/ajgringo619)
/dev/sdb4 on /srv/nfs/gentoo-binpkgs type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=286,subvol=/ajgringo619)
/dev/sdb4 on /srv/nfs/shared-files type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=286,subvol=/ajgringo619)
/dev/sdc1 on /media/backups type btrfs (rw,noatime,compress=zstd:3,space_cache=v2,subvolid=256,subvol=/@backups)

And my fstab:

UUID=6364-4843                               /boot/efi                 vfat    defaults,noatime 0 2
UUID=9753cd75-a2b0-40d5-bb71-913b20c2c9c7    /                         btrfs   subvol=/@,noatime,nodiscard,compress=zstd 0 0
UUID=9753cd75-a2b0-40d5-bb71-913b20c2c9c7    /var/cache                btrfs   subvol=/@cache,noatime,nodiscard,compress=zstd 0 0
UUID=9753cd75-a2b0-40d5-bb71-913b20c2c9c7    /var/log                  btrfs   subvol=/@log,noatime,nodiscard,compress=zstd 0 0
UUID=9d91dd59-5afd-4e69-b4b4-39c4b61acaf0    /home                     btrfs   noatime,nodiscard,compress=zstd 0 0
tmpfs                                        /tmp                      tmpfs   defaults,noatime,mode=1777 0 0

# data partitions
UUID=bc680f4c-30e2-47fb-ab1b-984d4fa50f0f    /media/backups            btrfs   subvol=/@backups,noatime,nodiscard,compress=zstd 0 0

# bind mounts for network services
/home/ajgringo619/Downloads                  /srv/nfs/downloads        none    bind 0 0
/home/ajgringo619/vm-shared/configs          /srv/nfs/shared-files     none    bind 0 0
/home/ajgringo619/vm-shared/gentoo-binpkgs   /srv/nfs/gentoo-binpkgs   none    bind 0 0
/nix                                         /srv/nfs/nix-store        none    bind 0 0

You can check with:

sudo dmesg | grep -i btrfs

[    4.398395] BTRFS info (device sdb2: state M): turning off async discard
1 Like

IMO, unless you are seeing an actual issue, it is probably too early to panic here.

We have a single person who has seen this issue on a single device. Unless it becomes more widespread or you see the issue yourself it is something to keep an eye on but I personally would not be re-configuring my system over this.

I’ve been seeing this effect for about a week now, but had no idea what the cause was. I did not notice any performance hits, but the SSD light was going crazy at times.