blob: 900646b72de147e5017301f23e6e0f1271b8d443 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
5 */
6#ifndef __XFS_SCRUB_BITMAP_H__
7#define __XFS_SCRUB_BITMAP_H__
8
Olivier Deprez157378f2022-04-04 15:47:50 +02009struct xbitmap_range {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000010 struct list_head list;
11 uint64_t start;
12 uint64_t len;
13};
14
Olivier Deprez157378f2022-04-04 15:47:50 +020015struct xbitmap {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000016 struct list_head list;
17};
18
Olivier Deprez157378f2022-04-04 15:47:50 +020019void xbitmap_init(struct xbitmap *bitmap);
20void xbitmap_destroy(struct xbitmap *bitmap);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000021
Olivier Deprez157378f2022-04-04 15:47:50 +020022#define for_each_xbitmap_extent(bex, n, bitmap) \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000023 list_for_each_entry_safe((bex), (n), &(bitmap)->list, list)
24
Olivier Deprez157378f2022-04-04 15:47:50 +020025#define for_each_xbitmap_block(b, bex, n, bitmap) \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000026 list_for_each_entry_safe((bex), (n), &(bitmap)->list, list) \
Olivier Deprez157378f2022-04-04 15:47:50 +020027 for ((b) = (bex)->start; (b) < (bex)->start + (bex)->len; (b)++)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000028
Olivier Deprez157378f2022-04-04 15:47:50 +020029int 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,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000032 struct xfs_btree_cur *cur);
Olivier Deprez157378f2022-04-04 15:47:50 +020033int xbitmap_set_btblocks(struct xbitmap *bitmap,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000034 struct xfs_btree_cur *cur);
Olivier Deprez157378f2022-04-04 15:47:50 +020035uint64_t xbitmap_hweight(struct xbitmap *bitmap);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000036
37#endif /* __XFS_SCRUB_BITMAP_H__ */