From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> While we're scrubbing various btrees, cross-reference the records with the other metadata. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --- fs/xfs/libxfs/xfs_rtbitmap.c | 30 ++++++++++++++++++++++++++++++ fs/xfs/scrub/bmap.c | 12 ++++++++++++ fs/xfs/xfs_rtalloc.h | 4 ++++ 3 files changed, 46 insertions(+) diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c index 5d4e43e..a38d51b 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.c +++ b/fs/xfs/libxfs/xfs_rtbitmap.c @@ -1086,3 +1086,33 @@ xfs_rtalloc_query_all( return xfs_rtalloc_query_range(tp, &keys[0], &keys[1], fn, priv); } + +/* Is the given extent all free? */ +int +xfs_rtalloc_extent_is_free( + struct xfs_mount *mp, + struct xfs_trans *tp, + xfs_rtblock_t start, + xfs_rtblock_t len, + bool *is_free) +{ + xfs_rtblock_t end; + xfs_extlen_t clen; + int matches; + int error; + + *is_free = false; + while (len) { + clen = len > ~0U ? ~0U : len; + error = xfs_rtcheck_range(mp, tp, start, clen, 1, &end, + &matches); + if (error || !matches || end < start + clen) + return error; + + len -= end - start; + start = end + 1; + } + + *is_free = true; + return error; +} diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c index 21d88aa..8377521 100644 --- a/fs/xfs/scrub/bmap.c +++ b/fs/xfs/scrub/bmap.c @@ -38,6 +38,7 @@ #include "xfs_alloc.h" #include "xfs_ialloc.h" #include "xfs_refcount.h" +#include "xfs_rtalloc.h" #include "scrub/xfs_scrub.h" #include "scrub/scrub.h" #include "scrub/common.h" @@ -286,6 +287,7 @@ xfs_scrub_bmap_extent( xfs_agnumber_t agno; bool is_freesp; bool has_inodes; + bool is_free = false; int error = 0; if (cur) @@ -343,6 +345,16 @@ xfs_scrub_bmap_extent( xfs_scrub_fblock_xref_check_ok(info->sc, info->whichfork, irec->br_startoff, !is_freesp); + } else { + xfs_ilock(mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP); + error = xfs_rtalloc_extent_is_free(mp, info->sc->tp, + irec->br_startblock, irec->br_blockcount, + &is_free); + if (xfs_scrub_should_xref(info->sc, &error, NULL)) + xfs_scrub_fblock_xref_check_ok(info->sc, + info->whichfork, irec->br_startoff, + !is_free); + xfs_iunlock(mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP); } /* Cross-reference with inobt. */ diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h index 79defa7..4aa7044 100644 --- a/fs/xfs/xfs_rtalloc.h +++ b/fs/xfs/xfs_rtalloc.h @@ -138,6 +138,9 @@ int xfs_rtalloc_query_range(struct xfs_trans *tp, int xfs_rtalloc_query_all(struct xfs_trans *tp, xfs_rtalloc_query_range_fn fn, void *priv); +int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp, + xfs_rtblock_t start, xfs_rtblock_t len, + bool *is_free); #else # define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (ENOSYS) # define xfs_rtfree_extent(t,b,l) (ENOSYS) @@ -146,6 +149,7 @@ int xfs_rtalloc_query_all(struct xfs_trans *tp, # define xfs_rtalloc_query_range(t,l,h,f,p) (ENOSYS) # define xfs_rtalloc_query_all(t,f,p) (ENOSYS) # define xfs_rtbuf_get(m,t,b,i,p) (ENOSYS) +# define xfs_rtalloc_extent_is_free(m,t,s,l,i) (ENOSYS) static inline int /* error */ xfs_rtmount_init( xfs_mount_t *mp) /* file system mount structure */ -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html