Hi all, This is the latest revision of a patchset that adds to XFS kernel support for reverse mapping for the realtime device. This time around I've fixed some of the bitrot that I've noticed over the past few months, and most notably have converted rtrmapbt to use the metadata inode directory feature instead of burning more space in the superblock. At the beginning of the set are patches to implement storing B+tree leaves in an inode root, since the realtime rmapbt is rooted in an inode, unlike the regular rmapbt which is rooted in an AG block. Prior to this, the only btree that could be rooted in the inode fork was the block mapping btree; if all the extent records fit in the inode, format would be switched from 'btree' to 'extents'. The next few patches enhance the reverse mapping routines to handle the parts that are specific to rtgroups -- adding the new btree type, adding a new log intent item type, and wiring up the metadata directory tree entries. Finally, implement GETFSMAP with the rtrmapbt and scrub functionality for the rtrmapbt and rtbitmap and online fsck functionality. 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 --- Commits in this patchset: * libxfs: compute the rt rmap btree maxlevels during initialization * libxfs: add a realtime flag to the rmap update log redo items * libfrog: enable scrubbing of the realtime rmap * man: document userspace API changes due to rt rmap * xfs_db: compute average btree height * xfs_db: don't abort when bmapping on a non-extents/bmbt fork * xfs_db: display the realtime rmap btree contents * xfs_db: support the realtime rmapbt * xfs_db: copy the realtime rmap btree * xfs_db: make fsmap query the realtime reverse mapping tree * xfs_db: add an rgresv command * xfs_spaceman: report health status of the realtime rmap btree * xfs_repair: tidy up rmap_diffkeys * xfs_repair: flag suspect long-format btree blocks * xfs_repair: use realtime rmap btree data to check block types * xfs_repair: create a new set of incore rmap information for rt groups * xfs_repair: refactor realtime inode check * xfs_repair: find and mark the rtrmapbt inodes * xfs_repair: check existing realtime rmapbt entries against observed rmaps * xfs_repair: always check realtime file mappings against incore info * xfs_repair: rebuild the realtime rmap btree * xfs_repair: check for global free space concerns with default btree slack levels * xfs_repair: rebuild the bmap btree for realtime files * xfs_repair: reserve per-AG space while rebuilding rt metadata * xfs_logprint: report realtime RUIs * mkfs: add some rtgroup inode helpers * mkfs: create the realtime rmap inode --- db/bmap.c | 17 + db/bmroot.c | 149 +++++++++++ db/bmroot.h | 2 db/btblock.c | 103 ++++++++ db/btblock.h | 5 db/btdump.c | 63 +++++ db/btheight.c | 36 +++ db/field.c | 11 + db/field.h | 5 db/fsmap.c | 149 +++++++++++ db/info.c | 119 +++++++++ db/inode.c | 24 ++ db/metadump.c | 120 +++++++++ db/type.c | 5 db/type.h | 1 include/libxfs.h | 1 libfrog/scrub.c | 10 + libxfs/defer_item.c | 35 ++- libxfs/init.c | 19 + libxfs/libxfs_api_defs.h | 24 ++ 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 | 12 + man/man8/xfs_db.8 | 74 +++++- mkfs/proto.c | 31 ++ mkfs/xfs_mkfs.c | 87 ++++++- repair/Makefile | 1 repair/agbtree.c | 5 repair/bmap_repair.c | 109 ++++++++ repair/bulkload.c | 41 +++ repair/bulkload.h | 2 repair/dino_chunks.c | 13 + repair/dinode.c | 441 ++++++++++++++++++++++++++++----- repair/dir2.c | 7 + repair/globals.c | 6 repair/globals.h | 2 repair/incore.h | 1 repair/phase4.c | 14 + repair/phase5.c | 114 ++++++++- repair/phase6.c | 72 +++++ repair/rmap.c | 403 ++++++++++++++++++++++++------ repair/rmap.h | 15 + repair/rt.h | 4 repair/rtrmap_repair.c | 265 ++++++++++++++++++++ repair/scan.c | 411 ++++++++++++++++++++++++++++++- repair/scan.h | 37 +++ repair/xfs_repair.c | 8 - scrub/repair.c | 1 spaceman/health.c | 10 + 51 files changed, 2905 insertions(+), 216 deletions(-) create mode 100644 repair/rtrmap_repair.c