xfs_ag_resv.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Oracle. All Rights Reserved.
  4. * Author: Darrick J. Wong <darrick.wong@oracle.com>
  5. */
  6. #ifndef __XFS_AG_RESV_H__
  7. #define __XFS_AG_RESV_H__
  8. int xfs_ag_resv_free(struct xfs_perag *pag);
  9. int xfs_ag_resv_init(struct xfs_perag *pag, struct xfs_trans *tp);
  10. bool xfs_ag_resv_critical(struct xfs_perag *pag, enum xfs_ag_resv_type type);
  11. xfs_extlen_t xfs_ag_resv_needed(struct xfs_perag *pag,
  12. enum xfs_ag_resv_type type);
  13. void xfs_ag_resv_alloc_extent(struct xfs_perag *pag, enum xfs_ag_resv_type type,
  14. struct xfs_alloc_arg *args);
  15. void xfs_ag_resv_free_extent(struct xfs_perag *pag, enum xfs_ag_resv_type type,
  16. struct xfs_trans *tp, xfs_extlen_t len);
  17. /*
  18. * RMAPBT reservation accounting wrappers. Since rmapbt blocks are sourced from
  19. * the AGFL, they are allocated one at a time and the reservation updates don't
  20. * require a transaction.
  21. */
  22. static inline void
  23. xfs_ag_resv_rmapbt_alloc(
  24. struct xfs_mount *mp,
  25. xfs_agnumber_t agno)
  26. {
  27. struct xfs_alloc_arg args = { NULL };
  28. struct xfs_perag *pag;
  29. args.len = 1;
  30. pag = xfs_perag_get(mp, agno);
  31. xfs_ag_resv_alloc_extent(pag, XFS_AG_RESV_RMAPBT, &args);
  32. xfs_perag_put(pag);
  33. }
  34. static inline void
  35. xfs_ag_resv_rmapbt_free(
  36. struct xfs_mount *mp,
  37. xfs_agnumber_t agno)
  38. {
  39. struct xfs_perag *pag;
  40. pag = xfs_perag_get(mp, agno);
  41. xfs_ag_resv_free_extent(pag, XFS_AG_RESV_RMAPBT, NULL, 1);
  42. xfs_perag_put(pag);
  43. }
  44. #endif /* __XFS_AG_RESV_H__ */