ref-verify.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2014 Facebook. All rights reserved.
  4. */
  5. #ifndef BTRFS_REF_VERIFY_H
  6. #define BTRFS_REF_VERIFY_H
  7. #include <linux/types.h>
  8. #include <linux/rbtree_types.h>
  9. struct btrfs_fs_info;
  10. struct btrfs_ref;
  11. #ifdef CONFIG_BTRFS_DEBUG
  12. #include <linux/spinlock.h>
  13. int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info);
  14. void btrfs_free_ref_cache(struct btrfs_fs_info *fs_info);
  15. int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
  16. const struct btrfs_ref *generic_ref);
  17. void btrfs_free_ref_tree_range(struct btrfs_fs_info *fs_info, u64 start,
  18. u64 len);
  19. static inline void btrfs_init_ref_verify(struct btrfs_fs_info *fs_info)
  20. {
  21. spin_lock_init(&fs_info->ref_verify_lock);
  22. fs_info->block_tree = RB_ROOT;
  23. }
  24. #else
  25. static inline int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info)
  26. {
  27. return 0;
  28. }
  29. static inline void btrfs_free_ref_cache(struct btrfs_fs_info *fs_info)
  30. {
  31. }
  32. static inline int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
  33. const struct btrfs_ref *generic_ref)
  34. {
  35. return 0;
  36. }
  37. static inline void btrfs_free_ref_tree_range(struct btrfs_fs_info *fs_info,
  38. u64 start, u64 len)
  39. {
  40. }
  41. static inline void btrfs_init_ref_verify(struct btrfs_fs_info *fs_info)
  42. {
  43. }
  44. #endif /* CONFIG_BTRFS_DEBUG */
  45. #endif