Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | // 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 Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 9 | struct xbitmap_range { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 10 | struct list_head list; |
| 11 | uint64_t start; |
| 12 | uint64_t len; |
| 13 | }; |
| 14 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 15 | struct xbitmap { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 16 | struct list_head list; |
| 17 | }; |
| 18 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 19 | void xbitmap_init(struct xbitmap *bitmap); |
| 20 | void xbitmap_destroy(struct xbitmap *bitmap); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 21 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 22 | #define for_each_xbitmap_extent(bex, n, bitmap) \ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 23 | list_for_each_entry_safe((bex), (n), &(bitmap)->list, list) |
| 24 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 25 | #define for_each_xbitmap_block(b, bex, n, bitmap) \ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 26 | list_for_each_entry_safe((bex), (n), &(bitmap)->list, list) \ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 27 | for ((b) = (bex)->start; (b) < (bex)->start + (bex)->len; (b)++) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 28 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 29 | int xbitmap_set(struct xbitmap *bitmap, uint64_t start, uint64_t len); |
| 30 | int xbitmap_disunion(struct xbitmap *bitmap, struct xbitmap *sub); |
| 31 | int xbitmap_set_btcur_path(struct xbitmap *bitmap, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 32 | struct xfs_btree_cur *cur); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 33 | int xbitmap_set_btblocks(struct xbitmap *bitmap, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 34 | struct xfs_btree_cur *cur); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 35 | uint64_t xbitmap_hweight(struct xbitmap *bitmap); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 36 | |
| 37 | #endif /* __XFS_SCRUB_BITMAP_H__ */ |