xfs: less heavy locks during fstrim [v30.3 14/16]

Congratulations!  You have made it to the final patchset of the main
 online fsck feature!  This patchset fixes some stalling behavior that I
 observed when running FITRIM against large flash-based filesystems with
 very heavily fragmented free space data.  In summary -- the current
 fstrim implementation optimizes for trimming the largest free extents
 first, and holds the AGF lock for the duration of the operation.  This
 is great if fstrim is being run as a foreground process by a sysadmin.
 
 For xfs_scrub, however, this isn't so good -- we don't really want to
 block on one huge kernel call while reporting no progress information.
 We don't want to hold the AGF so long that background processes stall.
 These problems are easily fixable by issuing smaller FITRIM calls, but
 there's still the problem of walking the entire cntbt.  To solve that
 second problem, we introduce a new sub-AG FITRIM implementation.  To
 solve the first problem, make it relax the AGF periodically.
 
 This has been running on the djcloud for months with no problems.  Enjoy!
 
 Signed-off-by: Darrick J. Wong <djwong@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQQ2qTKExjcn+O1o2YRKO3ySh0YRpgUCZh23VAAKCRBKO3ySh0YR
 pnLkAP9dlH5LKtJLK7Wbl3GC0EjPBUaX6a/nmkJPBIMocdautAD/X6J8ItPkx885
 26qzJSXeapMIXVS1olUPuUL6B3jW/gE=
 =HS4c
 -----END PGP SIGNATURE-----

Merge tag 'discard-relax-locks-6.10_2024-04-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.10-mergeA

xfs: less heavy locks during fstrim

Congratulations!  You have made it to the final patchset of the main
online fsck feature!  This patchset fixes some stalling behavior that I
observed when running FITRIM against large flash-based filesystems with
very heavily fragmented free space data.  In summary -- the current
fstrim implementation optimizes for trimming the largest free extents
first, and holds the AGF lock for the duration of the operation.  This
is great if fstrim is being run as a foreground process by a sysadmin.

For xfs_scrub, however, this isn't so good -- we don't really want to
block on one huge kernel call while reporting no progress information.
We don't want to hold the AGF so long that background processes stall.
These problems are easily fixable by issuing smaller FITRIM calls, but
there's still the problem of walking the entire cntbt.  To solve that
second problem, we introduce a new sub-AG FITRIM implementation.  To
solve the first problem, make it relax the AGF periodically.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>

* tag 'discard-relax-locks-6.10_2024-04-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
  xfs: fix performance problems when fstrimming a subset of a fragmented AG
This commit is contained in:
Chandan Babu R 2024-04-16 12:46:28 +05:30
commit 6ad1b91470