Hi all, Back when I originally designed xfs_scrub, all filesystem metadata checks were complete by the end of phase 3, and phase 4 was where all the metadata repairs occurred. On the grounds that the filesystem should be fully consistent by then, I made a call to FITRIM at the end of phase 4 to discard empty space in the filesystem. Unfortunately, that's no longer the case -- summary counters, link counts, and quota counters are not checked until phase 7. It's not safe to instruct the storage to unmap "empty" areas if we don't know where those empty areas are, so we need to create a phase 8 to trim the fs. While we're at it, make it more obvious that fstrim only gets to run if there are no unfixed corruptiosn and no other runtime errors have occurred. Finally, parallelize the fstrim calls by making them per-AG instead of per-filesystem. This cuts down the trimming time considerably on more modern hardware that can handle (or at least combine) concurrent discard requests. 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 xfsprogs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=scrub-fstrim-phase --- scrub/Makefile | 1 scrub/phase4.c | 30 +---------- scrub/phase8.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++ scrub/vfs.c | 22 +++++--- scrub/vfs.h | 2 - scrub/xfs_scrub.c | 11 ++++ scrub/xfs_scrub.h | 3 + 7 files changed, 182 insertions(+), 37 deletions(-) create mode 100644 scrub/phase8.c