free-space-cache.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2009 Oracle. 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 __BTRFS_FREE_SPACE_CACHE
  19. #define __BTRFS_FREE_SPACE_CACHE
  20. struct btrfs_free_space {
  21. struct rb_node offset_index;
  22. u64 offset;
  23. u64 bytes;
  24. unsigned long *bitmap;
  25. struct list_head list;
  26. };
  27. struct inode *lookup_free_space_inode(struct btrfs_root *root,
  28. struct btrfs_block_group_cache
  29. *block_group, struct btrfs_path *path);
  30. int create_free_space_inode(struct btrfs_root *root,
  31. struct btrfs_trans_handle *trans,
  32. struct btrfs_block_group_cache *block_group,
  33. struct btrfs_path *path);
  34. int btrfs_truncate_free_space_cache(struct btrfs_root *root,
  35. struct btrfs_trans_handle *trans,
  36. struct btrfs_path *path,
  37. struct inode *inode);
  38. int load_free_space_cache(struct btrfs_fs_info *fs_info,
  39. struct btrfs_block_group_cache *block_group);
  40. int btrfs_write_out_cache(struct btrfs_root *root,
  41. struct btrfs_trans_handle *trans,
  42. struct btrfs_block_group_cache *block_group,
  43. struct btrfs_path *path);
  44. int btrfs_add_free_space(struct btrfs_block_group_cache *block_group,
  45. u64 bytenr, u64 size);
  46. int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,
  47. u64 bytenr, u64 size);
  48. void btrfs_remove_free_space_cache(struct btrfs_block_group_cache
  49. *block_group);
  50. u64 btrfs_find_space_for_alloc(struct btrfs_block_group_cache *block_group,
  51. u64 offset, u64 bytes, u64 empty_size);
  52. void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group,
  53. u64 bytes);
  54. u64 btrfs_block_group_free_space(struct btrfs_block_group_cache *block_group);
  55. int btrfs_find_space_cluster(struct btrfs_trans_handle *trans,
  56. struct btrfs_root *root,
  57. struct btrfs_block_group_cache *block_group,
  58. struct btrfs_free_cluster *cluster,
  59. u64 offset, u64 bytes, u64 empty_size);
  60. void btrfs_init_free_cluster(struct btrfs_free_cluster *cluster);
  61. u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group,
  62. struct btrfs_free_cluster *cluster, u64 bytes,
  63. u64 min_start);
  64. int btrfs_return_cluster_to_free_space(
  65. struct btrfs_block_group_cache *block_group,
  66. struct btrfs_free_cluster *cluster);
  67. #endif