74 lines · c
1// SPDX-License-Identifier: GPL-2.0-or-later2/*3 * Copyright (C) 2018-2023 Oracle. All Rights Reserved.4 * Author: Darrick J. Wong <djwong@kernel.org>5 */6#ifndef __XFS_SCRUB_AGB_BITMAP_H__7#define __XFS_SCRUB_AGB_BITMAP_H__8 9/* Bitmaps, but for type-checked for xfs_agblock_t */10 11struct xagb_bitmap {12 struct xbitmap32 agbitmap;13};14 15static inline void xagb_bitmap_init(struct xagb_bitmap *bitmap)16{17 xbitmap32_init(&bitmap->agbitmap);18}19 20static inline void xagb_bitmap_destroy(struct xagb_bitmap *bitmap)21{22 xbitmap32_destroy(&bitmap->agbitmap);23}24 25static inline int xagb_bitmap_clear(struct xagb_bitmap *bitmap,26 xfs_agblock_t start, xfs_extlen_t len)27{28 return xbitmap32_clear(&bitmap->agbitmap, start, len);29}30static inline int xagb_bitmap_set(struct xagb_bitmap *bitmap,31 xfs_agblock_t start, xfs_extlen_t len)32{33 return xbitmap32_set(&bitmap->agbitmap, start, len);34}35 36static inline bool xagb_bitmap_test(struct xagb_bitmap *bitmap,37 xfs_agblock_t start, xfs_extlen_t *len)38{39 return xbitmap32_test(&bitmap->agbitmap, start, len);40}41 42static inline int xagb_bitmap_disunion(struct xagb_bitmap *bitmap,43 struct xagb_bitmap *sub)44{45 return xbitmap32_disunion(&bitmap->agbitmap, &sub->agbitmap);46}47 48static inline uint32_t xagb_bitmap_hweight(struct xagb_bitmap *bitmap)49{50 return xbitmap32_hweight(&bitmap->agbitmap);51}52static inline bool xagb_bitmap_empty(struct xagb_bitmap *bitmap)53{54 return xbitmap32_empty(&bitmap->agbitmap);55}56 57static inline int xagb_bitmap_walk(struct xagb_bitmap *bitmap,58 xbitmap32_walk_fn fn, void *priv)59{60 return xbitmap32_walk(&bitmap->agbitmap, fn, priv);61}62 63int xagb_bitmap_set_btblocks(struct xagb_bitmap *bitmap,64 struct xfs_btree_cur *cur);65int xagb_bitmap_set_btcur_path(struct xagb_bitmap *bitmap,66 struct xfs_btree_cur *cur);67 68static inline uint32_t xagb_bitmap_count_set_regions(struct xagb_bitmap *b)69{70 return xbitmap32_count_set_regions(&b->agbitmap);71}72 73#endif /* __XFS_SCRUB_AGB_BITMAP_H__ */74