Commit 5bb46e3e authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: create iterator error codes

Currently, xfs doesn't have generic error codes defined for "stop
iterating"; we just reuse the XFS_BTREE_QUERY_* return values.  This
looks a little weird if we're not actually iterating a btree index.
Before we start adding more iterators, we should create general
XFS_ITER_{CONTINUE,ABORT} return values and define the XFS_BTREE_QUERY_*
ones from that.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 73d30d48
...@@ -3137,7 +3137,7 @@ xfs_alloc_has_record( ...@@ -3137,7 +3137,7 @@ xfs_alloc_has_record(
/* /*
* Walk all the blocks in the AGFL. The @walk_fn can return any negative * Walk all the blocks in the AGFL. The @walk_fn can return any negative
* error code or XFS_BTREE_QUERY_RANGE_ABORT. * error code or XFS_ITER_*.
*/ */
int int
xfs_agfl_walk( xfs_agfl_walk(
......
...@@ -465,8 +465,8 @@ uint xfs_btree_compute_maxlevels(uint *limits, unsigned long len); ...@@ -465,8 +465,8 @@ uint xfs_btree_compute_maxlevels(uint *limits, unsigned long len);
unsigned long long xfs_btree_calc_size(uint *limits, unsigned long long len); unsigned long long xfs_btree_calc_size(uint *limits, unsigned long long len);
/* return codes */ /* return codes */
#define XFS_BTREE_QUERY_RANGE_CONTINUE 0 /* keep iterating */ #define XFS_BTREE_QUERY_RANGE_CONTINUE (XFS_ITER_CONTINUE) /* keep iterating */
#define XFS_BTREE_QUERY_RANGE_ABORT 1 /* stop iterating */ #define XFS_BTREE_QUERY_RANGE_ABORT (XFS_ITER_ABORT) /* stop iterating */
typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur, typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur,
union xfs_btree_rec *rec, void *priv); union xfs_btree_rec *rec, void *priv);
......
...@@ -177,4 +177,10 @@ struct xfs_ino_geometry { ...@@ -177,4 +177,10 @@ struct xfs_ino_geometry {
unsigned int agino_log; /* #bits for agino in inum */ unsigned int agino_log; /* #bits for agino in inum */
}; };
/* Keep iterating the data structure. */
#define XFS_ITER_CONTINUE (0)
/* Stop iterating the data structure. */
#define XFS_ITER_ABORT (1)
#endif /* __XFS_SHARED_H__ */ #endif /* __XFS_SHARED_H__ */
...@@ -639,7 +639,7 @@ xchk_agfl_block( ...@@ -639,7 +639,7 @@ xchk_agfl_block(
xchk_agfl_block_xref(sc, agbno); xchk_agfl_block_xref(sc, agbno);
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
return XFS_BTREE_QUERY_RANGE_ABORT; return XFS_ITER_ABORT;
return 0; return 0;
} }
...@@ -730,7 +730,7 @@ xchk_agfl( ...@@ -730,7 +730,7 @@ xchk_agfl(
/* Check the blocks in the AGFL. */ /* Check the blocks in the AGFL. */
error = xfs_agfl_walk(sc->mp, XFS_BUF_TO_AGF(sc->sa.agf_bp), error = xfs_agfl_walk(sc->mp, XFS_BUF_TO_AGF(sc->sa.agf_bp),
sc->sa.agfl_bp, xchk_agfl_block, &sai); sc->sa.agfl_bp, xchk_agfl_block, &sai);
if (error == XFS_BTREE_QUERY_RANGE_ABORT) { if (error == XFS_ITER_ABORT) {
error = 0; error = 0;
goto out_free; goto out_free;
} }
......
...@@ -664,7 +664,7 @@ xrep_findroot_agfl_walk( ...@@ -664,7 +664,7 @@ xrep_findroot_agfl_walk(
{ {
xfs_agblock_t *agbno = priv; xfs_agblock_t *agbno = priv;
return (*agbno == bno) ? XFS_BTREE_QUERY_RANGE_ABORT : 0; return (*agbno == bno) ? XFS_ITER_ABORT : 0;
} }
/* Does this block match the btree information passed in? */ /* Does this block match the btree information passed in? */
...@@ -694,7 +694,7 @@ xrep_findroot_block( ...@@ -694,7 +694,7 @@ xrep_findroot_block(
if (owner == XFS_RMAP_OWN_AG) { if (owner == XFS_RMAP_OWN_AG) {
error = xfs_agfl_walk(mp, ri->agf, ri->agfl_bp, error = xfs_agfl_walk(mp, ri->agf, ri->agfl_bp,
xrep_findroot_agfl_walk, &agbno); xrep_findroot_agfl_walk, &agbno);
if (error == XFS_BTREE_QUERY_RANGE_ABORT) if (error == XFS_ITER_ABORT)
return 0; return 0;
if (error) if (error)
return error; return error;
......
...@@ -1239,7 +1239,7 @@ xfs_qm_exit(void) ...@@ -1239,7 +1239,7 @@ xfs_qm_exit(void)
/* /*
* Iterate every dquot of a particular type. The caller must ensure that the * Iterate every dquot of a particular type. The caller must ensure that the
* particular quota type is active. iter_fn can return negative error codes, * particular quota type is active. iter_fn can return negative error codes,
* or XFS_BTREE_QUERY_RANGE_ABORT to indicate that it wants to stop iterating. * or XFS_ITER_ABORT to indicate that it wants to stop iterating.
*/ */
int int
xfs_qm_dqiterate( xfs_qm_dqiterate(
......
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