Linux-libre 5.7.3-gnu
[librecmc/linux-libre.git] / fs / xfs / scrub / bitmap.h
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
9 struct xbitmap_range {
10         struct list_head        list;
11         uint64_t                start;
12         uint64_t                len;
13 };
14
15 struct xbitmap {
16         struct list_head        list;
17 };
18
19 void xbitmap_init(struct xbitmap *bitmap);
20 void 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
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,
32                 struct xfs_btree_cur *cur);
33 int xbitmap_set_btblocks(struct xbitmap *bitmap,
34                 struct xfs_btree_cur *cur);
35 uint64_t xbitmap_hweight(struct xbitmap *bitmap);
36
37 #endif  /* __XFS_SCRUB_BITMAP_H__ */