Skip to content

Commit

Permalink
xfs: add scrub cross-referencing helpers for the refcount btrees
Browse files Browse the repository at this point in the history
Add a couple of functions to the refcount btrees that will be used
to cross-reference metadata against the refcountbt.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
  • Loading branch information
Darrick J. Wong committed Jan 18, 2018
1 parent ed7c52d commit 49db55e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions fs/xfs/libxfs/xfs_refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -1696,3 +1696,22 @@ xfs_refcount_recover_cow_leftovers(
xfs_trans_brelse(tp, agbp);
goto out_trans;
}

/* Is there a record covering a given extent? */
int
xfs_refcount_has_record(
struct xfs_btree_cur *cur,
xfs_agblock_t bno,
xfs_extlen_t len,
bool *exists)
{
union xfs_btree_irec low;
union xfs_btree_irec high;

memset(&low, 0, sizeof(low));
low.rc.rc_startblock = bno;
memset(&high, 0xFF, sizeof(high));
high.rc.rc_startblock = bno + len - 1;

return xfs_btree_has_record(cur, &low, &high, exists);
}
3 changes: 3 additions & 0 deletions fs/xfs/libxfs/xfs_refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@ static inline xfs_fileoff_t xfs_refcount_max_unmap(int log_res)
return (log_res * 3 / 4) / XFS_REFCOUNT_ITEM_OVERHEAD;
}

extern int xfs_refcount_has_record(struct xfs_btree_cur *cur,
xfs_agblock_t bno, xfs_extlen_t len, bool *exists);

#endif /* __XFS_REFCOUNT_H__ */

0 comments on commit 49db55e

Please sign in to comment.