Hi all, While I was cleaning things up for 6.1, I noticed that the btree _query_range and _query_all functions don't perform the same checking that the _get_rec functions perform. In fact, they don't perform /any/ sanity checking, which means that callers aren't warned about impossible records. Therefore, hoist the record validation and complaint logging code into separate functions, and call them from any place where we convert an ondisk record into an incore record. For online scrub, we can replace checking code with a call to the record checking functions in libxfs, thereby reducing the size of the codebase. 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=btree-complain-bad-records xfsprogs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=btree-complain-bad-records --- fs/xfs/libxfs/xfs_alloc.c | 82 ++++++++++++++++++++++++--------- fs/xfs/libxfs/xfs_alloc.h | 6 ++ fs/xfs/libxfs/xfs_bmap.c | 31 ++++++++++++ fs/xfs/libxfs/xfs_bmap.h | 2 + fs/xfs/libxfs/xfs_ialloc.c | 77 +++++++++++++++++++++---------- fs/xfs/libxfs/xfs_ialloc.h | 2 + fs/xfs/libxfs/xfs_ialloc_btree.c | 2 - fs/xfs/libxfs/xfs_ialloc_btree.h | 2 - fs/xfs/libxfs/xfs_inode_fork.c | 3 + fs/xfs/libxfs/xfs_refcount.c | 73 +++++++++++++++++++---------- fs/xfs/libxfs/xfs_refcount.h | 2 + fs/xfs/libxfs/xfs_rmap.c | 95 ++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_rmap.h | 12 +++-- fs/xfs/scrub/alloc.c | 24 +++++----- fs/xfs/scrub/bmap.c | 6 ++ fs/xfs/scrub/ialloc.c | 24 ++-------- fs/xfs/scrub/refcount.c | 14 +----- fs/xfs/scrub/rmap.c | 44 ++---------------- 18 files changed, 303 insertions(+), 198 deletions(-)