[PATCHSET v26.0 0/9] xfs: fix online repair block reaping

Darrick J. Wong
2023-07-27T22:18:37Z

Hi all,

These patches fix a few problems that I noticed in the code that deals
with old btree blocks after a successful repair.

First, I observed that it is possible for repair to incorrectly
invalidate and delete old btree blocks if they were crosslinked. The
solution here is to consult the reverse mappings for each block in the
extent -- singly owned blocks are invalidated and freed, whereas for
crosslinked blocks, we merely drop the incorrect reverse mapping.

A largeish change in this patchset is moving the reaping code to a
separate file, because the code are mostly interrelated static
functions. For now this also drops the ability to reap file blocks,
which will return when we add the bmbt repair functions.

Second, we convert the reap function to use EFIs so that we can commit
to freeing as many blocks in as few transactions as we dare. We would
like to free as many old blocks as we can in the same transaction that
commits the new structure to the ondisk filesystem to minimize the
number of blocks that leak if the system crashes before the repair fully
completes.

The third change made in this series is to avoid tripping buffer cache
assertions if we're merely scanning the buffer cache for buffers to
invalidate, and find a non-stale buffer of the wrong length. This is
primarily cosmetic, but makes my life easier.

The fourth change restructures the reaping code to try to process as many
blocks in one go as possible, to reduce logging traffic.

The last change switches the reaping mechanism to use per-AG bitmaps
defined in a previous patchset. This should reduce type confusion when
reading the source code.

If you're going to start using this mess, you probably ought to just
pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything. Enjoy!
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=repair-reap-fixes

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=repair-reap-fixes
---
fs/xfs/Makefile | 1
fs/xfs/scrub/agheader_repair.c | 75 +++---
fs/xfs/scrub/bitmap.c | 78 ------
fs/xfs/scrub/bitmap.h | 10 -
fs/xfs/scrub/reap.c | 499 ++++++++++++++++++++++++++++++++++++++++
fs/xfs/scrub/reap.h | 12 +
fs/xfs/scrub/repair.c | 366 ++++-------------------------
fs/xfs/scrub/repair.h | 10 -
fs/xfs/scrub/trace.h | 72 +++---
fs/xfs/xfs_buf.c | 9 +
fs/xfs/xfs_buf.h | 13 +
11 files changed, 666 insertions(+), 479 deletions(-)
create mode 100644 fs/xfs/scrub/reap.c
create mode 100644 fs/xfs/scrub/reap.h