xfs_ag_resv.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2016 Oracle. All Rights Reserved.
  3. *
  4. * Author: Darrick J. Wong <darrick.wong@oracle.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it would be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write the Free Software Foundation,
  18. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef __XFS_AG_RESV_H__
  21. #define __XFS_AG_RESV_H__
  22. int xfs_ag_resv_free(struct xfs_perag *pag);
  23. int xfs_ag_resv_init(struct xfs_perag *pag);
  24. bool xfs_ag_resv_critical(struct xfs_perag *pag, enum xfs_ag_resv_type type);
  25. xfs_extlen_t xfs_ag_resv_needed(struct xfs_perag *pag,
  26. enum xfs_ag_resv_type type);
  27. void xfs_ag_resv_alloc_extent(struct xfs_perag *pag, enum xfs_ag_resv_type type,
  28. struct xfs_alloc_arg *args);
  29. void xfs_ag_resv_free_extent(struct xfs_perag *pag, enum xfs_ag_resv_type type,
  30. struct xfs_trans *tp, xfs_extlen_t len);
  31. /*
  32. * RMAPBT reservation accounting wrappers. Since rmapbt blocks are sourced from
  33. * the AGFL, they are allocated one at a time and the reservation updates don't
  34. * require a transaction.
  35. */
  36. static inline void
  37. xfs_ag_resv_rmapbt_alloc(
  38. struct xfs_mount *mp,
  39. xfs_agnumber_t agno)
  40. {
  41. struct xfs_alloc_arg args = {0};
  42. struct xfs_perag *pag;
  43. args.len = 1;
  44. pag = xfs_perag_get(mp, agno);
  45. xfs_ag_resv_alloc_extent(pag, XFS_AG_RESV_RMAPBT, &args);
  46. xfs_perag_put(pag);
  47. }
  48. static inline void
  49. xfs_ag_resv_rmapbt_free(
  50. struct xfs_mount *mp,
  51. xfs_agnumber_t agno)
  52. {
  53. struct xfs_perag *pag;
  54. pag = xfs_perag_get(mp, agno);
  55. xfs_ag_resv_free_extent(pag, XFS_AG_RESV_RMAPBT, NULL, 1);
  56. xfs_perag_put(pag);
  57. }
  58. #endif /* __XFS_AG_RESV_H__ */