ref-verify.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) 2014 Facebook. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public
  6. * License v2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public
  14. * License along with this program; if not, write to the
  15. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. * Boston, MA 021110-1307, USA.
  17. */
  18. #ifndef __REF_VERIFY__
  19. #define __REF_VERIFY__
  20. #ifdef CONFIG_BTRFS_FS_REF_VERIFY
  21. int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info);
  22. void btrfs_free_ref_cache(struct btrfs_fs_info *fs_info);
  23. int btrfs_ref_tree_mod(struct btrfs_root *root, u64 bytenr, u64 num_bytes,
  24. u64 parent, u64 ref_root, u64 owner, u64 offset,
  25. int action);
  26. void btrfs_free_ref_tree_range(struct btrfs_fs_info *fs_info, u64 start,
  27. u64 len);
  28. static inline void btrfs_init_ref_verify(struct btrfs_fs_info *fs_info)
  29. {
  30. spin_lock_init(&fs_info->ref_verify_lock);
  31. fs_info->block_tree = RB_ROOT;
  32. }
  33. #else
  34. static inline int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info)
  35. {
  36. return 0;
  37. }
  38. static inline void btrfs_free_ref_cache(struct btrfs_fs_info *fs_info)
  39. {
  40. }
  41. static inline int btrfs_ref_tree_mod(struct btrfs_root *root, u64 bytenr,
  42. u64 num_bytes, u64 parent, u64 ref_root,
  43. u64 owner, u64 offset, int action)
  44. {
  45. return 0;
  46. }
  47. static inline void btrfs_free_ref_tree_range(struct btrfs_fs_info *fs_info,
  48. u64 start, u64 len)
  49. {
  50. }
  51. static inline void btrfs_init_ref_verify(struct btrfs_fs_info *fs_info)
  52. {
  53. }
  54. #endif /* CONFIG_BTRFS_FS_REF_VERIFY */
  55. #endif /* _REF_VERIFY__ */