xfs_ag_resv.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2016 Oracle. All Rights Reserved.
  4. * Author: Darrick J. Wong <[email protected]>
  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. static inline struct xfs_ag_resv *
  18. xfs_perag_resv(
  19. struct xfs_perag *pag,
  20. enum xfs_ag_resv_type type)
  21. {
  22. switch (type) {
  23. case XFS_AG_RESV_METADATA:
  24. return &pag->pag_meta_resv;
  25. case XFS_AG_RESV_RMAPBT:
  26. return &pag->pag_rmapbt_resv;
  27. default:
  28. return NULL;
  29. }
  30. }
  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 = { NULL };
  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. #endif /* __XFS_AG_RESV_H__ */