bitmap.h (ecc73f8a58c7844b04186726f8699ba97cec2ef9) bitmap.h (178b48d588ea5424a54423dc9c406416de0547c8)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (C) 2018-2023 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <djwong@kernel.org>
5 */
6#ifndef __XFS_SCRUB_BITMAP_H__
7#define __XFS_SCRUB_BITMAP_H__
8

--- 5 unchanged lines hidden (view full) ---

14
15struct xbitmap {
16 struct list_head list;
17};
18
19void xbitmap_init(struct xbitmap *bitmap);
20void xbitmap_destroy(struct xbitmap *bitmap);
21
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (C) 2018-2023 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <djwong@kernel.org>
5 */
6#ifndef __XFS_SCRUB_BITMAP_H__
7#define __XFS_SCRUB_BITMAP_H__
8

--- 5 unchanged lines hidden (view full) ---

14
15struct xbitmap {
16 struct list_head list;
17};
18
19void xbitmap_init(struct xbitmap *bitmap);
20void xbitmap_destroy(struct xbitmap *bitmap);
21
22#define for_each_xbitmap_extent(bex, n, bitmap) \
23 list_for_each_entry_safe((bex), (n), &(bitmap)->list, list)
24
25#define for_each_xbitmap_block(b, bex, n, bitmap) \
26 list_for_each_entry_safe((bex), (n), &(bitmap)->list, list) \
27 for ((b) = (bex)->start; (b) < (bex)->start + (bex)->len; (b)++)
28
29int xbitmap_set(struct xbitmap *bitmap, uint64_t start, uint64_t len);
30int xbitmap_disunion(struct xbitmap *bitmap, struct xbitmap *sub);
31int xbitmap_set_btcur_path(struct xbitmap *bitmap,
32 struct xfs_btree_cur *cur);
33int xbitmap_set_btblocks(struct xbitmap *bitmap,
34 struct xfs_btree_cur *cur);
35uint64_t xbitmap_hweight(struct xbitmap *bitmap);
36
22int xbitmap_set(struct xbitmap *bitmap, uint64_t start, uint64_t len);
23int xbitmap_disunion(struct xbitmap *bitmap, struct xbitmap *sub);
24int xbitmap_set_btcur_path(struct xbitmap *bitmap,
25 struct xfs_btree_cur *cur);
26int xbitmap_set_btblocks(struct xbitmap *bitmap,
27 struct xfs_btree_cur *cur);
28uint64_t xbitmap_hweight(struct xbitmap *bitmap);
29
30/*
31 * Return codes for the bitmap iterator functions are 0 to continue iterating,
32 * and non-zero to stop iterating. Any non-zero value will be passed up to the
33 * iteration caller. The special value -ECANCELED can be used to stop
34 * iteration, because neither bitmap iterator ever generates that error code on
35 * its own. Callers must not modify the bitmap while walking it.
36 */
37typedef int (*xbitmap_walk_fn)(uint64_t start, uint64_t len, void *priv);
38int xbitmap_walk(struct xbitmap *bitmap, xbitmap_walk_fn fn,
39 void *priv);
40
41typedef int (*xbitmap_walk_bits_fn)(uint64_t bit, void *priv);
42int xbitmap_walk_bits(struct xbitmap *bitmap, xbitmap_walk_bits_fn fn,
43 void *priv);
44
37#endif /* __XFS_SCRUB_BITMAP_H__ */
45#endif /* __XFS_SCRUB_BITMAP_H__ */