BTRFS spin locks way too much when accessing many files concurrently
Description:
Accessing many files concurrently at once causes BTRFS to spin lock too much and basically lock up all other processes for seconds at a time.
Mostly happens when accessing their content, not the other metadata.
Additional info:
- package version(s): linux 6.10.1-arch1-1
- config and/or log files: I collected a perf report showing the problem, using
sudo perf record -F 99 --call-graph dwarf,16384 -g -m 32M -- rg uncommon-phrase ~/Documents
: perf.data, flamegraph.svg - link to upstream bug report, if any: https://lore.kernel.org/linux-btrfs/CAHPNGSSt-a4ZZWrtJdVyYnJFscFjP9S7rMcvEMaNSpR556DdLA@mail.gmail.com/T/#u
Steps to reproduce:
- Collect a lot of files / file content in BTRFS (In my test I had 1,425,292 files comprising 424GB)
- Run
rg anything-here ./folder
, or any other highly-parallel file content consuming command, e.g. I also encountered this withrestic
during backups. - The system slows to an absolute crawl.