qgroup.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 __BTRFS_QGROUP__
  19. #define __BTRFS_QGROUP__
  20. #include "ulist.h"
  21. #include "delayed-ref.h"
  22. /*
  23. * Record a dirty extent, and info qgroup to update quota on it
  24. * TODO: Use kmem cache to alloc it.
  25. */
  26. struct btrfs_qgroup_extent_record {
  27. struct rb_node node;
  28. u64 bytenr;
  29. u64 num_bytes;
  30. struct ulist *old_roots;
  31. };
  32. int btrfs_quota_enable(struct btrfs_trans_handle *trans,
  33. struct btrfs_fs_info *fs_info);
  34. int btrfs_quota_disable(struct btrfs_trans_handle *trans,
  35. struct btrfs_fs_info *fs_info);
  36. int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info);
  37. void btrfs_qgroup_rescan_resume(struct btrfs_fs_info *fs_info);
  38. int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info);
  39. int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans,
  40. struct btrfs_fs_info *fs_info, u64 src, u64 dst);
  41. int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans,
  42. struct btrfs_fs_info *fs_info, u64 src, u64 dst);
  43. int btrfs_create_qgroup(struct btrfs_trans_handle *trans,
  44. struct btrfs_fs_info *fs_info, u64 qgroupid);
  45. int btrfs_remove_qgroup(struct btrfs_trans_handle *trans,
  46. struct btrfs_fs_info *fs_info, u64 qgroupid);
  47. int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
  48. struct btrfs_fs_info *fs_info, u64 qgroupid,
  49. struct btrfs_qgroup_limit *limit);
  50. int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info);
  51. void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info);
  52. struct btrfs_delayed_extent_op;
  53. int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans,
  54. struct btrfs_fs_info *fs_info);
  55. struct btrfs_qgroup_extent_record
  56. *btrfs_qgroup_insert_dirty_extent(struct btrfs_delayed_ref_root *delayed_refs,
  57. struct btrfs_qgroup_extent_record *record);
  58. int
  59. btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans,
  60. struct btrfs_fs_info *fs_info,
  61. u64 bytenr, u64 num_bytes,
  62. struct ulist *old_roots, struct ulist *new_roots);
  63. int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
  64. struct btrfs_fs_info *fs_info);
  65. int btrfs_run_qgroups(struct btrfs_trans_handle *trans,
  66. struct btrfs_fs_info *fs_info);
  67. int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
  68. struct btrfs_fs_info *fs_info, u64 srcid, u64 objectid,
  69. struct btrfs_qgroup_inherit *inherit);
  70. int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes);
  71. void btrfs_qgroup_free(struct btrfs_root *root, u64 num_bytes);
  72. void assert_qgroups_uptodate(struct btrfs_trans_handle *trans);
  73. #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
  74. int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
  75. u64 rfer, u64 excl);
  76. #endif
  77. #endif /* __BTRFS_QGROUP__ */