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 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=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 | 4 fs/xfs/libxfs/xfs_ag_resv.c | 5 fs/xfs/libxfs/xfs_bmap.c | 29 + fs/xfs/libxfs/xfs_btree.c | 108 +++++ fs/xfs/libxfs/xfs_btree.h | 9 fs/xfs/libxfs/xfs_format.h | 76 ++++ fs/xfs/libxfs/xfs_fs.h | 4 fs/xfs/libxfs/xfs_health.h | 4 fs/xfs/libxfs/xfs_imeta.c | 2 fs/xfs/libxfs/xfs_imeta.h | 1 fs/xfs/libxfs/xfs_inode_buf.c | 6 fs/xfs/libxfs/xfs_inode_fork.c | 13 + fs/xfs/libxfs/xfs_log_format.h | 4 fs/xfs/libxfs/xfs_refcount.c | 6 fs/xfs/libxfs/xfs_rmap.c | 377 +++++++++++------- fs/xfs/libxfs/xfs_rmap.h | 39 +- fs/xfs/libxfs/xfs_rtrmap_btree.c | 778 ++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_rtrmap_btree.h | 195 ++++++++++ fs/xfs/libxfs/xfs_sb.c | 6 fs/xfs/libxfs/xfs_shared.h | 1 fs/xfs/libxfs/xfs_swapext.c | 3 fs/xfs/libxfs/xfs_trans_resv.c | 17 + fs/xfs/libxfs/xfs_trans_space.h | 13 + fs/xfs/libxfs/xfs_types.h | 6 fs/xfs/scrub/alloc_repair.c | 6 fs/xfs/scrub/bmap.c | 76 +++- fs/xfs/scrub/bmap_repair.c | 87 ++++ fs/xfs/scrub/common.c | 37 ++ fs/xfs/scrub/common.h | 8 fs/xfs/scrub/health.c | 1 fs/xfs/scrub/repair.c | 95 +++++ fs/xfs/scrub/repair.h | 13 + fs/xfs/scrub/rmap_repair.c | 21 + fs/xfs/scrub/rtbitmap.c | 59 +++ fs/xfs/scrub/rtbitmap_repair.c | 252 ++++++++++++ fs/xfs/scrub/rtrmap.c | 147 +++++++ fs/xfs/scrub/rtrmap_repair.c | 689 ++++++++++++++++++++++++++++++++++ fs/xfs/scrub/scrub.c | 11 - fs/xfs/scrub/scrub.h | 11 + fs/xfs/scrub/trace.c | 2 fs/xfs/scrub/trace.h | 87 ++++ fs/xfs/xfs_buf_item_recover.c | 4 fs/xfs/xfs_fsmap.c | 66 +++ fs/xfs/xfs_health.c | 4 fs/xfs/xfs_inode.c | 9 fs/xfs/xfs_inode_item.c | 2 fs/xfs/xfs_inode_item_recover.c | 33 +- fs/xfs/xfs_mount.c | 2 fs/xfs/xfs_mount.h | 4 fs/xfs/xfs_ondisk.h | 3 fs/xfs/xfs_rmap_item.c | 31 +- fs/xfs/xfs_rtalloc.c | 55 ++- fs/xfs/xfs_rtalloc.h | 4 fs/xfs/xfs_super.c | 6 fs/xfs/xfs_trace.h | 39 +- 55 files changed, 3286 insertions(+), 284 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/rtbitmap_repair.c create mode 100644 fs/xfs/scrub/rtrmap.c create mode 100644 fs/xfs/scrub/rtrmap_repair.c