relocation.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef BTRFS_RELOCATION_H
  3. #define BTRFS_RELOCATION_H
  4. #include <linux/types.h>
  5. struct extent_buffer;
  6. struct btrfs_fs_info;
  7. struct btrfs_root;
  8. struct btrfs_trans_handle;
  9. struct btrfs_ordered_extent;
  10. struct btrfs_pending_snapshot;
  11. static inline bool should_relocate_using_remap_tree(const struct btrfs_block_group *bg)
  12. {
  13. if (!btrfs_fs_incompat(bg->fs_info, REMAP_TREE))
  14. return false;
  15. if (bg->flags & (BTRFS_BLOCK_GROUP_SYSTEM | BTRFS_BLOCK_GROUP_METADATA_REMAP))
  16. return false;
  17. return true;
  18. }
  19. int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start,
  20. bool verbose);
  21. int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, struct btrfs_root *root);
  22. int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
  23. struct btrfs_root *root);
  24. int btrfs_recover_relocation(struct btrfs_fs_info *fs_info);
  25. int btrfs_reloc_clone_csums(struct btrfs_ordered_extent *ordered);
  26. int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
  27. struct btrfs_root *root,
  28. const struct extent_buffer *buf,
  29. struct extent_buffer *cow);
  30. void btrfs_reloc_pre_snapshot(struct btrfs_pending_snapshot *pending,
  31. u64 *bytes_to_reserve);
  32. int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
  33. struct btrfs_pending_snapshot *pending);
  34. int btrfs_should_cancel_balance(const struct btrfs_fs_info *fs_info);
  35. struct btrfs_root *find_reloc_root(struct btrfs_fs_info *fs_info, u64 bytenr);
  36. bool btrfs_should_ignore_reloc_root(const struct btrfs_root *root);
  37. u64 btrfs_get_reloc_bg_bytenr(const struct btrfs_fs_info *fs_info);
  38. int btrfs_translate_remap(struct btrfs_fs_info *fs_info, u64 *logical, u64 *length);
  39. int btrfs_remove_extent_from_remap_tree(struct btrfs_trans_handle *trans,
  40. struct btrfs_path *path,
  41. u64 bytenr, u64 num_bytes);
  42. int btrfs_last_identity_remap_gone(struct btrfs_chunk_map *chunk_map,
  43. struct btrfs_block_group *bg);
  44. #endif