Skip to content

xfs: bunmapi needs updating for deferred freeing

Dave Chinner linux-xfs oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 15 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6xfs: btree format inode forks can have zero extentsfs/xfs/libxfs/xfs_bmap.c+0 -11 reply
2/6xfs: bunmapi has unnecessary AG lock ordering issuesfs/xfs/libxfs/xfs_bmap.c+0 -111 reply
3/6xfs: xfs_itruncate_extents has no extent count limitationfs/xfs/xfs_inode.c+12 -34 replies
4/6xfs: add a free space extent change reservationfs/xfs/libxfs/xfs_trans_resv.c+17 -01 reply
5/6xfs: factor free space tree transaciton reservationsfs/xfs/libxfs/xfs_trans_resv.c+45 -771 reply
6/6xfs: reduce transaction reservation for freeing extentsfs/xfs/libxfs/xfs_trans_resv.c+31 -325 replies

Reviews trailers per patch

2 of 6 patches have a Reviewed-by or Acked-by.

PatchDarrick J. Wong
1/6R-b
2/6R-b
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/6] xfs: bunmapi needs updating for deferred freeing

Hi folks,

I pulled on a loose thread when I started looking into the 64kB directory block size assert failure I was seeing while trying to test the bulk page allocation changes.

I posted the first patch in the series separately - it fixed the immediate assert failure (5.13-rc1 regression) I was seeing, but in fixing that it only then dropped back to the previous assert failure that g/538 was triggering with 64kb directory block sizes. This can only be reproduced on 5.12, because that's when the error injection that g/538 uses was added. So I went looking deeper.

It turns out that xfs_bunmapi() has some code in it to avoid locking AGFs in the wrong order and this is what was triggering. Many of the xfs_bunmapi() callers can not/do not handle partial unmaps that return success, and that's what the directory code is tripping over trying to free badly fragmented directory blocks.

This AGF locking order constraint was added to xfs_bunmapu in 2017 to avoid a deadlock in g/299. Sad thing is that shortly after this, we converted xfs-bunmapi to use deferred freeing, so it never actually locks AGFs anymore. But the deadlock avoiding landmine remained. And xfs_bmap_finish() went away, too, and we now only ever put one extent in any EFI we log for deferred freeing.

That means we now only free one extent per transaction via deferred freeing, and there are no limitations on what order xfs_bunmapi() can unmap extents. 64kB directories on a 1kB block size filesystem already unmap 64 extents in a single loop, so there's no real limitation here.

This means that the limitations of how many extents we can unmap per loop in xfs_itruncate_extents_flags() goes away for data device extents (and will eventually go away for RT devices, too, when Darrick's RT EFI stuff gets merged).

This "one data deveice extent free per transaction" change now means that all of the transaction reservations that include "xfs_bmap_finish" based freeing reservations are wrong. These extent frees are now done by deferred freeing, and so they only need a single extent free reservation instead of up to 4 (as truncate was reserving).

This series fixes the btree fork regression, the bunmapi partial unmap regression from 2017, extends xfs_itruncate_extents to unmap 64 extents at a time for data device (AG) resident extents, and reworks the transaction reservations to use a consistent and correct reservation for allocation and freeing extents. The size of some transaction reservations drops dramatically as a result.

The first two patches are -rcX candidates, the rest are for the next merge cycle....

Cheers,

Dave.