Hi all, Add libxfs code from the kernel, then teach the various utilities about how to access realtime rmapbt information and rebuild it. 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=realtime-rmap xfsprogs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-rmap fstests git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-rmap xfsdocs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-documentation.git/log/?h=realtime-rmap --- db/bmroot.c | 149 +++++ db/bmroot.h | 2 db/btblock.c | 103 +++ db/btblock.h | 5 db/btdump.c | 64 ++ db/btheight.c | 5 db/check.c | 203 ++++++- db/field.c | 11 db/field.h | 5 db/fsmap.c | 164 +++++ db/inode.c | 128 ++++ db/inode.h | 4 db/metadump.c | 129 ++++ db/type.c | 5 db/type.h | 1 include/libxfs.h | 2 include/xfs_mount.h | 21 + io/scrub.c | 41 + libfrog/scrub.c | 10 libxfs/Makefile | 2 libxfs/defer_item.c | 115 +++- libxfs/init.c | 20 - libxfs/libxfs_api_defs.h | 19 + libxfs/rdwr.c | 2 libxfs/trans.c | 1 libxfs/xfbtree.c | 2 libxfs/xfs_bmap.c | 23 + libxfs/xfs_btree.c | 77 ++ libxfs/xfs_btree.h | 7 libxfs/xfs_defer.h | 1 libxfs/xfs_format.h | 24 + libxfs/xfs_fs.h | 6 libxfs/xfs_fs_staging.h | 1 libxfs/xfs_health.h | 4 libxfs/xfs_inode_buf.c | 26 + libxfs/xfs_inode_fork.c | 13 libxfs/xfs_log_format.h | 6 libxfs/xfs_ondisk.h | 2 libxfs/xfs_refcount.c | 6 libxfs/xfs_rmap.c | 198 ++++++ libxfs/xfs_rmap.h | 25 + libxfs/xfs_rtgroup.c | 12 libxfs/xfs_rtgroup.h | 20 + libxfs/xfs_rtrmap_btree.c | 1028 +++++++++++++++++++++++++++++++++ libxfs/xfs_rtrmap_btree.h | 217 +++++++ libxfs/xfs_sb.c | 6 libxfs/xfs_shared.h | 2 libxfs/xfs_swapext.c | 4 libxfs/xfs_trans_resv.c | 12 libxfs/xfs_trans_space.h | 13 libxfs/xfs_types.h | 5 logprint/log_misc.c | 2 logprint/log_print_all.c | 8 logprint/log_redo.c | 24 + man/man2/ioctl_xfs_rtgroup_geometry.2 | 3 man/man2/ioctl_xfs_scrub_metadata.2 | 8 man/man8/xfs_db.8 | 63 ++ man/man8/xfs_io.8 | 3 mkfs/proto.c | 56 ++ mkfs/xfs_mkfs.c | 90 +++ repair/Makefile | 1 repair/agbtree.c | 5 repair/bmap_repair.c | 131 ++++ repair/bulkload.c | 41 + repair/bulkload.h | 2 repair/dino_chunks.c | 13 repair/dinode.c | 381 ++++++++++-- repair/dir2.c | 4 repair/globals.c | 6 repair/globals.h | 2 repair/incore.h | 1 repair/phase2.c | 100 +++ repair/phase4.c | 12 repair/phase5.c | 116 ++++ repair/phase6.c | 208 +++++++ repair/rmap.c | 560 +++++++++++++++--- repair/rmap.h | 17 - repair/rtrmap_repair.c | 261 ++++++++ repair/scan.c | 411 +++++++++++++ repair/scan.h | 37 + repair/xfs_repair.c | 8 scrub/phase4.c | 54 ++ scrub/phase5.c | 24 + scrub/repair.c | 159 +++++ scrub/repair.h | 5 scrub/scrub.c | 3 scrub/scrub.h | 4 spaceman/health.c | 10 88 files changed, 5500 insertions(+), 284 deletions(-) create mode 100644 libxfs/xfs_rtrmap_btree.c create mode 100644 libxfs/xfs_rtrmap_btree.h create mode 100644 repair/rtrmap_repair.c