Hi all, This is the first part of the twenty-second revision of a patchset that adds to XFS kernel support for online metadata scrubbing and repair. There aren't any on-disk format changes. New for this version is a rebase against 5.5-rc4, bulk loading of btrees, integration with the health reporting subsystem, and the explicit revalidation of all metadata structures that were rebuilt. First, create a new data structure that provides an abstraction of a big memory array by using linked lists. This is where we store records for btree reconstruction. This first implementation is memory inefficient and consumes a /lot/ of kernel memory, but lays the groundwork for a later patch in the set to convert the implementation to use a (memfd) swap file, which enables us to use pageable memory without pounding the slab cache. The three patches after that implement reconstruction of the free space btrees, inode btrees, and reference count btree. The reverse mapping btree requires considerably more thought and will be covered later. 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-ag-btrees xfsprogs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=repair-ag-btrees --- fs/xfs/Makefile | 3 fs/xfs/libxfs/xfs_ag_resv.c | 2 fs/xfs/libxfs/xfs_ialloc.c | 20 + fs/xfs/libxfs/xfs_ialloc.h | 1 fs/xfs/libxfs/xfs_ialloc_btree.c | 2 fs/xfs/libxfs/xfs_ialloc_btree.h | 2 fs/xfs/libxfs/xfs_types.c | 20 + fs/xfs/libxfs/xfs_types.h | 9 fs/xfs/scrub/alloc_repair.c | 761 +++++++++++++++++++++++++++++++++++ fs/xfs/scrub/common.c | 9 fs/xfs/scrub/health.c | 10 fs/xfs/scrub/ialloc_repair.c | 837 ++++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/refcount_repair.c | 653 ++++++++++++++++++++++++++++++ fs/xfs/scrub/repair.c | 66 +++ fs/xfs/scrub/repair.h | 32 + fs/xfs/scrub/scrub.c | 19 + fs/xfs/scrub/scrub.h | 9 fs/xfs/scrub/trace.h | 103 +++-- fs/xfs/xfs_extent_busy.c | 13 + fs/xfs/xfs_extent_busy.h | 2 20 files changed, 2517 insertions(+), 56 deletions(-) create mode 100644 fs/xfs/scrub/alloc_repair.c create mode 100644 fs/xfs/scrub/ialloc_repair.c create mode 100644 fs/xfs/scrub/refcount_repair.c