xfs: add scrub cross-referencing helpers for the free space btrees

Add a couple of functions to the free space btrees that will be used
to cross-reference metadata against the bnobt/cntbt, and a generic
btree function that provides the real implementation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
Darrick J. Wong
2018-01-16 18:52:12 -08:00
parent c468562879
commit ce1d802e6a
4 changed files with 62 additions and 1 deletions

View File

@@ -4998,3 +4998,33 @@ xfs_btree_diff_two_ptrs(
return (int64_t)be64_to_cpu(a->l) - be64_to_cpu(b->l);
return (int64_t)be32_to_cpu(a->s) - be32_to_cpu(b->s);
}
/* If there's an extent, we're done. */
STATIC int
xfs_btree_has_record_helper(
struct xfs_btree_cur *cur,
union xfs_btree_rec *rec,
void *priv)
{
return XFS_BTREE_QUERY_RANGE_ABORT;
}
/* Is there a record covering a given range of keys? */
int
xfs_btree_has_record(
struct xfs_btree_cur *cur,
union xfs_btree_irec *low,
union xfs_btree_irec *high,
bool *exists)
{
int error;
error = xfs_btree_query_range(cur, low, high,
&xfs_btree_has_record_helper, NULL);
if (error == XFS_BTREE_QUERY_RANGE_ABORT) {
*exists = true;
return 0;
}
*exists = false;
return error;
}