• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
9 int xfs_ag_resv_free(struct xfs_perag *pag);
10 int xfs_ag_resv_init(struct xfs_perag *pag, struct xfs_trans *tp);
11 
12 bool xfs_ag_resv_critical(struct xfs_perag *pag, enum xfs_ag_resv_type type);
13 xfs_extlen_t xfs_ag_resv_needed(struct xfs_perag *pag,
14 		enum xfs_ag_resv_type type);
15 
16 void xfs_ag_resv_alloc_extent(struct xfs_perag *pag, enum xfs_ag_resv_type type,
17 		struct xfs_alloc_arg *args);
18 void xfs_ag_resv_free_extent(struct xfs_perag *pag, enum xfs_ag_resv_type type,
19 		struct xfs_trans *tp, xfs_extlen_t len);
20 
21 /*
22  * RMAPBT reservation accounting wrappers. Since rmapbt blocks are sourced from
23  * the AGFL, they are allocated one at a time and the reservation updates don't
24  * require a transaction.
25  */
26 static inline void
xfs_ag_resv_rmapbt_alloc(struct xfs_mount * mp,xfs_agnumber_t agno)27 xfs_ag_resv_rmapbt_alloc(
28 	struct xfs_mount	*mp,
29 	xfs_agnumber_t		agno)
30 {
31 	struct xfs_alloc_arg	args = { NULL };
32 	struct xfs_perag	*pag;
33 
34 	args.len = 1;
35 	pag = xfs_perag_get(mp, agno);
36 	xfs_ag_resv_alloc_extent(pag, XFS_AG_RESV_RMAPBT, &args);
37 	xfs_perag_put(pag);
38 }
39 
40 static inline void
xfs_ag_resv_rmapbt_free(struct xfs_mount * mp,xfs_agnumber_t agno)41 xfs_ag_resv_rmapbt_free(
42 	struct xfs_mount	*mp,
43 	xfs_agnumber_t		agno)
44 {
45 	struct xfs_perag	*pag;
46 
47 	pag = xfs_perag_get(mp, agno);
48 	xfs_ag_resv_free_extent(pag, XFS_AG_RESV_RMAPBT, NULL, 1);
49 	xfs_perag_put(pag);
50 }
51 
52 #endif	/* __XFS_AG_RESV_H__ */
53