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 | 3 fs/xfs/libxfs/xfs_bmap.c | 22 + fs/xfs/libxfs/xfs_btree.c | 121 ++++ fs/xfs/libxfs/xfs_btree.h | 7 fs/xfs/libxfs/xfs_defer.c | 1 fs/xfs/libxfs/xfs_defer.h | 1 fs/xfs/libxfs/xfs_format.h | 24 + fs/xfs/libxfs/xfs_fs.h | 4 fs/xfs/libxfs/xfs_health.h | 4 fs/xfs/libxfs/xfs_imeta.c | 6 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 | 227 +++++++- fs/xfs/libxfs/xfs_rmap.h | 22 + fs/xfs/libxfs/xfs_rtgroup.c | 12 fs/xfs/libxfs/xfs_rtgroup.h | 20 + fs/xfs/libxfs/xfs_rtrmap_btree.c | 1036 ++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_rtrmap_btree.h | 218 ++++++++ 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 | 128 ++++- fs/xfs/scrub/bmap_repair.c | 131 +++++ fs/xfs/scrub/common.c | 153 +++++- fs/xfs/scrub/common.h | 14 - fs/xfs/scrub/cow_repair.c | 2 fs/xfs/scrub/health.c | 1 fs/xfs/scrub/inode.c | 10 fs/xfs/scrub/inode_repair.c | 75 +++ fs/xfs/scrub/reap.c | 5 fs/xfs/scrub/reap.h | 2 fs/xfs/scrub/repair.c | 229 ++++++++ fs/xfs/scrub/repair.h | 34 + fs/xfs/scrub/rmap_repair.c | 36 + fs/xfs/scrub/rtbitmap.c | 104 ++++ fs/xfs/scrub/rtbitmap_repair.c | 692 +++++++++++++++++++++++++ fs/xfs/scrub/rtrmap.c | 282 ++++++++++ fs/xfs/scrub/rtrmap_repair.c | 908 +++++++++++++++++++++++++++++++++ fs/xfs/scrub/rtsummary_repair.c | 3 fs/xfs/scrub/scrub.c | 11 fs/xfs/scrub/scrub.h | 14 + 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 | 5 fs/xfs/xfs_buf_item_recover.c | 4 fs/xfs/xfs_drain.c | 41 ++ fs/xfs/xfs_drain.h | 19 + fs/xfs/xfs_extfree_item.c | 2 fs/xfs/xfs_fsmap.c | 579 ++++++++++++++------- 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_mount.c | 9 fs/xfs/xfs_mount.h | 10 fs/xfs/xfs_ondisk.h | 2 fs/xfs/xfs_qm.c | 20 + fs/xfs/xfs_qm_bhv.c | 2 fs/xfs/xfs_quota.h | 4 fs/xfs/xfs_rmap_item.c | 27 + fs/xfs/xfs_rtalloc.c | 283 ++++++++++ fs/xfs/xfs_rtalloc.h | 9 fs/xfs/xfs_super.c | 6 fs/xfs/xfs_trace.c | 18 + fs/xfs/xfs_trace.h | 136 ++++- 75 files changed, 5771 insertions(+), 388 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