Hi all, Now that we've spent a lot of time reworking common code in online fsck, we're ready to start rebuilding the AG space btrees. This series implements repair functions for the free space, inode, and refcount btrees. Rebuilding the reverse mapping btree is much more intense and is left for a subsequent patchset. The fstests counterpart of this patchset implements stress testing of repair. If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below. This has been running on the djcloud for months with no problems. 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 fstests git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=repair-ag-btrees --- fs/xfs/Makefile | 3 fs/xfs/libxfs/xfs_ag.h | 10 fs/xfs/libxfs/xfs_ag_resv.c | 2 fs/xfs/libxfs/xfs_alloc.c | 18 - fs/xfs/libxfs/xfs_alloc.h | 2 fs/xfs/libxfs/xfs_alloc_btree.c | 13 - fs/xfs/libxfs/xfs_btree.c | 26 + fs/xfs/libxfs/xfs_btree.h | 2 fs/xfs/libxfs/xfs_ialloc.c | 41 +- fs/xfs/libxfs/xfs_ialloc.h | 3 fs/xfs/libxfs/xfs_refcount.c | 18 - fs/xfs/libxfs/xfs_refcount.h | 2 fs/xfs/libxfs/xfs_refcount_btree.c | 13 - fs/xfs/libxfs/xfs_types.h | 7 fs/xfs/scrub/agheader_repair.c | 18 - fs/xfs/scrub/alloc.c | 16 + fs/xfs/scrub/alloc_repair.c | 914 ++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/bitmap.c | 404 +++++++++++++--- fs/xfs/scrub/bitmap.h | 70 ++- fs/xfs/scrub/common.c | 1 fs/xfs/scrub/common.h | 19 + fs/xfs/scrub/ialloc_repair.c | 874 ++++++++++++++++++++++++++++++++++ fs/xfs/scrub/newbt.c | 48 ++ fs/xfs/scrub/newbt.h | 6 fs/xfs/scrub/reap.c | 5 fs/xfs/scrub/refcount_repair.c | 793 +++++++++++++++++++++++++++++++ fs/xfs/scrub/repair.c | 128 +++++ fs/xfs/scrub/repair.h | 43 ++ fs/xfs/scrub/scrub.c | 22 + fs/xfs/scrub/scrub.h | 9 fs/xfs/scrub/trace.h | 112 +++- fs/xfs/scrub/xfarray.h | 22 + fs/xfs/xfs_extent_busy.c | 13 + fs/xfs/xfs_extent_busy.h | 2 34 files changed, 3493 insertions(+), 186 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