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 widen the reverse mapping routines to fit the 64-bit numbers required to store information about the realtime device and establish a new b+tree type (rtrmapbt) for the realtime variant of the rmapbt. After that are a few patches to handle rooting the rtrmapbt in a specific inode that's referenced by the superblock. Finally, there are patches to implement GETFSMAP with the rtrmapbt and scrub functionality for the rtrmapbt and rtbitmap; and then wire up the online scrub functionality. We also enhance EFIs to support tracking freeing of realtime extents so that when rmap is turned on we can maintain the same order of operations as the regular rmap code. 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 --- fs/xfs/Makefile | 3 fs/xfs/libxfs/xfs_bmap.c | 23 + fs/xfs/libxfs/xfs_btree.c | 78 +++ fs/xfs/libxfs/xfs_btree.h | 7 fs/xfs/libxfs/xfs_defer.h | 1 fs/xfs/libxfs/xfs_format.h | 24 + fs/xfs/libxfs/xfs_fs.h | 6 fs/xfs/libxfs/xfs_fs_staging.h | 1 fs/xfs/libxfs/xfs_health.h | 4 fs/xfs/libxfs/xfs_inode_buf.c | 26 + fs/xfs/libxfs/xfs_inode_fork.c | 13 fs/xfs/libxfs/xfs_log_format.h | 6 fs/xfs/libxfs/xfs_log_recover.h | 2 fs/xfs/libxfs/xfs_ondisk.h | 2 fs/xfs/libxfs/xfs_refcount.c | 6 fs/xfs/libxfs/xfs_rmap.c | 198 +++++++ fs/xfs/libxfs/xfs_rmap.h | 25 + fs/xfs/libxfs/xfs_rtgroup.c | 12 fs/xfs/libxfs/xfs_rtgroup.h | 20 + fs/xfs/libxfs/xfs_rtrmap_btree.c | 1030 ++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_rtrmap_btree.h | 217 ++++++++ fs/xfs/libxfs/xfs_sb.c | 6 fs/xfs/libxfs/xfs_shared.h | 2 fs/xfs/libxfs/xfs_swapext.c | 4 fs/xfs/libxfs/xfs_trans_resv.c | 12 fs/xfs/libxfs/xfs_trans_space.h | 13 fs/xfs/libxfs/xfs_types.h | 5 fs/xfs/scrub/alloc_repair.c | 10 fs/xfs/scrub/bmap.c | 133 ++++- fs/xfs/scrub/bmap_repair.c | 128 +++++ fs/xfs/scrub/common.c | 165 ++++++ fs/xfs/scrub/common.h | 18 + fs/xfs/scrub/health.c | 1 fs/xfs/scrub/inode.c | 10 fs/xfs/scrub/inode_repair.c | 116 ++++ fs/xfs/scrub/metapath.c | 27 + fs/xfs/scrub/newbt.c | 43 ++ fs/xfs/scrub/newbt.h | 1 fs/xfs/scrub/reap.c | 41 ++ fs/xfs/scrub/reap.h | 2 fs/xfs/scrub/repair.c | 229 ++++++++ fs/xfs/scrub/repair.h | 28 + fs/xfs/scrub/rmap_repair.c | 36 + fs/xfs/scrub/rtbitmap.c | 80 +++ fs/xfs/scrub/rtbitmap.h | 59 ++ fs/xfs/scrub/rtbitmap_repair.c | 676 +++++++++++++++++++++++++ fs/xfs/scrub/rtrmap.c | 283 ++++++++++ fs/xfs/scrub/rtrmap_repair.c | 946 +++++++++++++++++++++++++++++++++++ fs/xfs/scrub/rtsummary_repair.c | 3 fs/xfs/scrub/scrub.c | 13 fs/xfs/scrub/scrub.h | 14 + fs/xfs/scrub/stats.c | 1 fs/xfs/scrub/tempfile.c | 15 - fs/xfs/scrub/tempswap.h | 2 fs/xfs/scrub/trace.c | 1 fs/xfs/scrub/trace.h | 249 +++++++++ fs/xfs/scrub/xfbtree.c | 3 fs/xfs/xfs_bmap_item.c | 11 fs/xfs/xfs_buf_item_recover.c | 4 fs/xfs/xfs_drain.c | 93 +++ fs/xfs/xfs_drain.h | 28 + fs/xfs/xfs_extfree_item.c | 14 - fs/xfs/xfs_fsmap.c | 464 ++++++++++++----- fs/xfs/xfs_fsops.c | 12 fs/xfs/xfs_health.c | 4 fs/xfs/xfs_inode.c | 19 + fs/xfs/xfs_inode_item.c | 2 fs/xfs/xfs_inode_item_recover.c | 33 + fs/xfs/xfs_log_recover.c | 2 fs/xfs/xfs_mount.c | 5 fs/xfs/xfs_mount.h | 10 fs/xfs/xfs_rmap_item.c | 254 +++++++++ fs/xfs/xfs_rtalloc.c | 246 +++++++++ fs/xfs/xfs_rtalloc.h | 5 fs/xfs/xfs_super.c | 6 fs/xfs/xfs_trace.c | 18 + fs/xfs/xfs_trace.h | 136 ++++- 77 files changed, 6111 insertions(+), 334 deletions(-) create mode 100644 fs/xfs/libxfs/xfs_rtrmap_btree.c create mode 100644 fs/xfs/libxfs/xfs_rtrmap_btree.h create mode 100644 fs/xfs/scrub/rtrmap.c create mode 100644 fs/xfs/scrub/rtrmap_repair.c