Commit e9a2599a authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: create a function to query all records in a btree

Create a helper function that will query all records in a btree.
This will be used by the online repair functions to examine every
record in a btree to rebuild a second btree.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 2d520bfa
...@@ -2910,3 +2910,18 @@ xfs_alloc_query_range( ...@@ -2910,3 +2910,18 @@ xfs_alloc_query_range(
return xfs_btree_query_range(cur, &low_brec, &high_brec, return xfs_btree_query_range(cur, &low_brec, &high_brec,
xfs_alloc_query_range_helper, &query); xfs_alloc_query_range_helper, &query);
} }
/* Find all free space records. */
int
xfs_alloc_query_all(
struct xfs_btree_cur *cur,
xfs_alloc_query_range_fn fn,
void *priv)
{
struct xfs_alloc_query_range_info query;
ASSERT(cur->bc_btnum == XFS_BTNUM_BNO);
query.priv = priv;
query.fn = fn;
return xfs_btree_query_all(cur, xfs_alloc_query_range_helper, &query);
}
...@@ -228,5 +228,7 @@ int xfs_alloc_query_range(struct xfs_btree_cur *cur, ...@@ -228,5 +228,7 @@ int xfs_alloc_query_range(struct xfs_btree_cur *cur,
struct xfs_alloc_rec_incore *low_rec, struct xfs_alloc_rec_incore *low_rec,
struct xfs_alloc_rec_incore *high_rec, struct xfs_alloc_rec_incore *high_rec,
xfs_alloc_query_range_fn fn, void *priv); xfs_alloc_query_range_fn fn, void *priv);
int xfs_alloc_query_all(struct xfs_btree_cur *cur, xfs_alloc_query_range_fn fn,
void *priv);
#endif /* __XFS_ALLOC_H__ */ #endif /* __XFS_ALLOC_H__ */
...@@ -4842,6 +4842,21 @@ xfs_btree_query_range( ...@@ -4842,6 +4842,21 @@ xfs_btree_query_range(
fn, priv); fn, priv);
} }
/* Query a btree for all records. */
int
xfs_btree_query_all(
struct xfs_btree_cur *cur,
xfs_btree_query_range_fn fn,
void *priv)
{
union xfs_btree_irec low_rec;
union xfs_btree_irec high_rec;
memset(&low_rec, 0, sizeof(low_rec));
memset(&high_rec, 0xFF, sizeof(high_rec));
return xfs_btree_query_range(cur, &low_rec, &high_rec, fn, priv);
}
/* /*
* Calculate the number of blocks needed to store a given number of records * Calculate the number of blocks needed to store a given number of records
* in a short-format (per-AG metadata) btree. * in a short-format (per-AG metadata) btree.
......
...@@ -496,6 +496,8 @@ typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur, ...@@ -496,6 +496,8 @@ typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur,
int xfs_btree_query_range(struct xfs_btree_cur *cur, int xfs_btree_query_range(struct xfs_btree_cur *cur,
union xfs_btree_irec *low_rec, union xfs_btree_irec *high_rec, union xfs_btree_irec *low_rec, union xfs_btree_irec *high_rec,
xfs_btree_query_range_fn fn, void *priv); xfs_btree_query_range_fn fn, void *priv);
int xfs_btree_query_all(struct xfs_btree_cur *cur, xfs_btree_query_range_fn fn,
void *priv);
typedef int (*xfs_btree_visit_blocks_fn)(struct xfs_btree_cur *cur, int level, typedef int (*xfs_btree_visit_blocks_fn)(struct xfs_btree_cur *cur, int level,
void *data); void *data);
......
...@@ -2001,14 +2001,14 @@ xfs_rmap_query_range_helper( ...@@ -2001,14 +2001,14 @@ xfs_rmap_query_range_helper(
/* Find all rmaps between two keys. */ /* Find all rmaps between two keys. */
int int
xfs_rmap_query_range( xfs_rmap_query_range(
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
struct xfs_rmap_irec *low_rec, struct xfs_rmap_irec *low_rec,
struct xfs_rmap_irec *high_rec, struct xfs_rmap_irec *high_rec,
xfs_rmap_query_range_fn fn, xfs_rmap_query_range_fn fn,
void *priv) void *priv)
{ {
union xfs_btree_irec low_brec; union xfs_btree_irec low_brec;
union xfs_btree_irec high_brec; union xfs_btree_irec high_brec;
struct xfs_rmap_query_range_info query; struct xfs_rmap_query_range_info query;
low_brec.r = *low_rec; low_brec.r = *low_rec;
...@@ -2019,6 +2019,20 @@ xfs_rmap_query_range( ...@@ -2019,6 +2019,20 @@ xfs_rmap_query_range(
xfs_rmap_query_range_helper, &query); xfs_rmap_query_range_helper, &query);
} }
/* Find all rmaps. */
int
xfs_rmap_query_all(
struct xfs_btree_cur *cur,
xfs_rmap_query_range_fn fn,
void *priv)
{
struct xfs_rmap_query_range_info query;
query.priv = priv;
query.fn = fn;
return xfs_btree_query_all(cur, xfs_rmap_query_range_helper, &query);
}
/* Clean up after calling xfs_rmap_finish_one. */ /* Clean up after calling xfs_rmap_finish_one. */
void void
xfs_rmap_finish_one_cleanup( xfs_rmap_finish_one_cleanup(
......
...@@ -162,6 +162,8 @@ typedef int (*xfs_rmap_query_range_fn)( ...@@ -162,6 +162,8 @@ typedef int (*xfs_rmap_query_range_fn)(
int xfs_rmap_query_range(struct xfs_btree_cur *cur, int xfs_rmap_query_range(struct xfs_btree_cur *cur,
struct xfs_rmap_irec *low_rec, struct xfs_rmap_irec *high_rec, struct xfs_rmap_irec *low_rec, struct xfs_rmap_irec *high_rec,
xfs_rmap_query_range_fn fn, void *priv); xfs_rmap_query_range_fn fn, void *priv);
int xfs_rmap_query_all(struct xfs_btree_cur *cur, xfs_rmap_query_range_fn fn,
void *priv);
enum xfs_rmap_intent_type { enum xfs_rmap_intent_type {
XFS_RMAP_MAP, XFS_RMAP_MAP,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment