Hi all, The design doc for XFS online fsck contains a long discussion of the eventual consistency models in use for XFS metadata. In that chapter, we note that it is possible for scrub to collide with a chain of deferred space metadata updates, and proposes a lightweight solution: The use of a pending-intents counter so that scrub can wait for the system to drain all chains. This patchset implements that scrub drain. The first patch implements the basic mechanism, and the subsequent patches reduce the runtime overhead by converting the implementation to use sloppy counters and introducing jump labels to avoid walking into scrub hooks when it isn't running. This last paradigm repeats elsewhere in this megaseries. 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=scrub-drain-intents xfsprogs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=scrub-drain-intents --- fs/xfs/Kconfig | 5 ++ fs/xfs/libxfs/xfs_ag.c | 6 ++ fs/xfs/libxfs/xfs_ag.h | 8 +++ fs/xfs/libxfs/xfs_defer.c | 10 ++- fs/xfs/libxfs/xfs_defer.h | 3 + fs/xfs/scrub/agheader.c | 9 +++ fs/xfs/scrub/alloc.c | 3 + fs/xfs/scrub/bmap.c | 3 + fs/xfs/scrub/btree.c | 1 fs/xfs/scrub/common.c | 129 ++++++++++++++++++++++++++++++++++++++++---- fs/xfs/scrub/common.h | 15 +++++ fs/xfs/scrub/dabtree.c | 1 fs/xfs/scrub/fscounters.c | 7 ++ fs/xfs/scrub/health.c | 2 + fs/xfs/scrub/ialloc.c | 2 + fs/xfs/scrub/inode.c | 3 + fs/xfs/scrub/quota.c | 3 + fs/xfs/scrub/refcount.c | 4 + fs/xfs/scrub/repair.c | 3 + fs/xfs/scrub/rmap.c | 3 + fs/xfs/scrub/scrub.c | 63 ++++++++++++++++----- fs/xfs/scrub/scrub.h | 6 ++ fs/xfs/scrub/trace.h | 34 ++++++++++++ fs/xfs/xfs_attr_item.c | 1 fs/xfs/xfs_bmap_item.c | 48 ++++++++++++++++ fs/xfs/xfs_extfree_item.c | 30 ++++++++++ fs/xfs/xfs_mount.c | 105 ++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_mount.h | 64 ++++++++++++++++++++++ fs/xfs/xfs_refcount_item.c | 25 +++++++++ fs/xfs/xfs_rmap_item.c | 18 ++++++ fs/xfs/xfs_trace.h | 71 ++++++++++++++++++++++++ 31 files changed, 652 insertions(+), 33 deletions(-)