In v5.16 btrfs had a big rework (originally considered as a refactor only) on defrag, which brings quite some regressions. With those regressions, extra scrutiny is brought to defrag code, and some existing bugs are exposed. For v5.15, there are those patches need to be backported: (Tracked through github issue: https://github.com/btrfs/linux/issues/422) - Already upstreamed: "btrfs: don't hold CPU for too long when defragging a file" The first patch. - In maintainer's tree btrfs: defrag: don't try to merge regular extents with preallocated extents btrfs: defrag: don't defrag extents which are already at max capacity btrfs: defrag: remove an ambiguous condition for rejection Those will be backported when they get merged upstream. - One special fix for v5.15 The 2nd patch. The problem is, that patch has no upstream commit, since v5.16 reworked the defrag code and fix the problem unintentionally. It's not a good idea to bring the whole rework (along with its bugs) to stable kernel. So here I crafted a small fix for v5.15 only. Not sure if this is conflicted with any stable policy. Qu Wenruo (2): btrfs: don't hold CPU for too long when defragging a file btrfs: defrag: use the same cluster size for defrag ioctl and autodefrag fs/btrfs/ioctl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) -- 2.35.1