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