^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2018 Oracle. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author: Darrick J. Wong <darrick.wong@oracle.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __XFS_SCRUB_BITMAP_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __XFS_SCRUB_BITMAP_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) struct xbitmap_range {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) uint64_t start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) uint64_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct xbitmap {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) void xbitmap_init(struct xbitmap *bitmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) void xbitmap_destroy(struct xbitmap *bitmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define for_each_xbitmap_extent(bex, n, bitmap) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) list_for_each_entry_safe((bex), (n), &(bitmap)->list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define for_each_xbitmap_block(b, bex, n, bitmap) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) list_for_each_entry_safe((bex), (n), &(bitmap)->list, list) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) for ((b) = (bex)->start; (b) < (bex)->start + (bex)->len; (b)++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int xbitmap_set(struct xbitmap *bitmap, uint64_t start, uint64_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int xbitmap_disunion(struct xbitmap *bitmap, struct xbitmap *sub);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int xbitmap_set_btcur_path(struct xbitmap *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct xfs_btree_cur *cur);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int xbitmap_set_btblocks(struct xbitmap *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct xfs_btree_cur *cur);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) uint64_t xbitmap_hweight(struct xbitmap *bitmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #endif /* __XFS_SCRUB_BITMAP_H__ */