From e9caede6e2f5691b18798d88e236314af8c72f20 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Wed, 24 Jul 2019 15:54:07 -0400 Subject: [PATCH] xfs: add online scrub for superblock counters Source kernel commit: 75efa57d0bf5fcf650a183f0ce0dc011ba8c4bc8 Teach online scrub how to check the filesystem summary counters. We use the incore delalloc block counter along with the incore AG headers to compute expected values for fdblocks, icount, and ifree, and then check that the percpu counter is within a certain threshold of the expected value. This is done to avoid having to freeze or otherwise lock the filesystem, which means that we're only checking that the counters are fairly close, not that they're exactly correct. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Brian Foster Signed-off-by: Eric Sandeen --- libxfs/xfs_fs.h | 3 ++- libxfs/xfs_types.c | 2 +- libxfs/xfs_types.h | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index 8d50ccf8a..f1158a796 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -599,9 +599,10 @@ struct xfs_scrub_metadata { #define XFS_SCRUB_TYPE_UQUOTA 21 /* user quotas */ #define XFS_SCRUB_TYPE_GQUOTA 22 /* group quotas */ #define XFS_SCRUB_TYPE_PQUOTA 23 /* project quotas */ +#define XFS_SCRUB_TYPE_FSCOUNTERS 24 /* fs summary counters */ /* Number of scrub subcommands. */ -#define XFS_SCRUB_TYPE_NR 24 +#define XFS_SCRUB_TYPE_NR 25 /* i: Repair this metadata. */ #define XFS_SCRUB_IFLAG_REPAIR (1 << 0) diff --git a/libxfs/xfs_types.c b/libxfs/xfs_types.c index 715d2056c..3243c45b0 100644 --- a/libxfs/xfs_types.c +++ b/libxfs/xfs_types.c @@ -185,7 +185,7 @@ xfs_verify_rtbno( } /* Calculate the range of valid icount values. */ -static void +void xfs_icount_range( struct xfs_mount *mp, unsigned long long *min, diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index c5a25403b..802b34cd1 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -191,5 +191,7 @@ bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino); bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); bool xfs_verify_icount(struct xfs_mount *mp, unsigned long long icount); bool xfs_verify_dablk(struct xfs_mount *mp, xfs_fileoff_t off); +void xfs_icount_range(struct xfs_mount *mp, unsigned long long *min, + unsigned long long *max); #endif /* __XFS_TYPES_H__ */ -- 2.47.2