diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-08-30 15:44:44 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-10-19 10:39:05 -0700 |
commit | 957e3bae4c2e8671c35d995d59d39a1f4090427e (patch) | |
tree | 8a66d08ef1343777f29d4d31ed9092b1e4a28b59 /fs/xfs/scrub/bitmap.h | |
parent | c2cbe2dd27df30f1f60e28a509afb4ba214906d2 (diff) |
xfs: remove the for_each_xbitmap_ helpers
Remove the for_each_xbitmap_ macros in favor of proper iterator
functions. We'll soon be switching this data structure over to an
interval tree implementation, which means that we can't allow callers to
modify the bitmap during iteration without telling us.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/scrub/bitmap.h')
-rw-r--r-- | fs/xfs/scrub/bitmap.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/fs/xfs/scrub/bitmap.h b/fs/xfs/scrub/bitmap.h index 900646b72de1..27fde5b4a753 100644 --- a/fs/xfs/scrub/bitmap.h +++ b/fs/xfs/scrub/bitmap.h @@ -19,13 +19,6 @@ struct xbitmap { void xbitmap_init(struct xbitmap *bitmap); void xbitmap_destroy(struct xbitmap *bitmap); -#define for_each_xbitmap_extent(bex, n, bitmap) \ - list_for_each_entry_safe((bex), (n), &(bitmap)->list, list) - -#define for_each_xbitmap_block(b, bex, n, bitmap) \ - list_for_each_entry_safe((bex), (n), &(bitmap)->list, list) \ - for ((b) = (bex)->start; (b) < (bex)->start + (bex)->len; (b)++) - int xbitmap_set(struct xbitmap *bitmap, uint64_t start, uint64_t len); int xbitmap_disunion(struct xbitmap *bitmap, struct xbitmap *sub); int xbitmap_set_btcur_path(struct xbitmap *bitmap, @@ -34,4 +27,19 @@ int xbitmap_set_btblocks(struct xbitmap *bitmap, struct xfs_btree_cur *cur); uint64_t xbitmap_hweight(struct xbitmap *bitmap); +/* + * Return codes for the bitmap iterator functions are 0 to continue iterating, + * and non-zero to stop iterating. Any non-zero value will be passed up to the + * iteration caller. The special value -ECANCELED can be used to stop + * iteration, because neither bitmap iterator ever generates that error code on + * its own. + */ +typedef int (*xbitmap_walk_run_fn)(uint64_t start, uint64_t len, void *priv); +int xbitmap_iter_set(struct xbitmap *bitmap, xbitmap_walk_run_fn fn, + void *priv); + +typedef int (*xbitmap_walk_bit_fn)(uint64_t bit, void *priv); +int xbitmap_iter_set_bits(struct xbitmap *bitmap, xbitmap_walk_bit_fn fn, + void *priv); + #endif /* __XFS_SCRUB_BITMAP_H__ */ |