bitmap.h 1.1 KB

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