aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_alloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_alloc.h')
-rw-r--r--fs/xfs/xfs_alloc.h55
1 files changed, 50 insertions, 5 deletions
diff --git a/fs/xfs/xfs_alloc.h b/fs/xfs/xfs_alloc.h
index 895009a97271..2f52b924be79 100644
--- a/fs/xfs/xfs_alloc.h
+++ b/fs/xfs/xfs_alloc.h
@@ -19,6 +19,7 @@
19#define __XFS_ALLOC_H__ 19#define __XFS_ALLOC_H__
20 20
21struct xfs_buf; 21struct xfs_buf;
22struct xfs_btree_cur;
22struct xfs_mount; 23struct xfs_mount;
23struct xfs_perag; 24struct xfs_perag;
24struct xfs_trans; 25struct xfs_trans;
@@ -74,6 +75,22 @@ typedef unsigned int xfs_alloctype_t;
74#define XFS_ALLOC_SET_ASIDE(mp) (4 + ((mp)->m_sb.sb_agcount * 4)) 75#define XFS_ALLOC_SET_ASIDE(mp) (4 + ((mp)->m_sb.sb_agcount * 4))
75 76
76/* 77/*
78 * When deciding how much space to allocate out of an AG, we limit the
79 * allocation maximum size to the size the AG. However, we cannot use all the
80 * blocks in the AG - some are permanently used by metadata. These
81 * blocks are generally:
82 * - the AG superblock, AGF, AGI and AGFL
83 * - the AGF (bno and cnt) and AGI btree root blocks
84 * - 4 blocks on the AGFL according to XFS_ALLOC_SET_ASIDE() limits
85 *
86 * The AG headers are sector sized, so the amount of space they take up is
87 * dependent on filesystem geometry. The others are all single blocks.
88 */
89#define XFS_ALLOC_AG_MAX_USABLE(mp) \
90 ((mp)->m_sb.sb_agblocks - XFS_BB_TO_FSB(mp, XFS_FSS_TO_BB(mp, 4)) - 7)
91
92
93/*
77 * Argument structure for xfs_alloc routines. 94 * Argument structure for xfs_alloc routines.
78 * This is turned into a structure to avoid having 20 arguments passed 95 * This is turned into a structure to avoid having 20 arguments passed
79 * down several levels of the stack. 96 * down several levels of the stack.
@@ -118,15 +135,29 @@ xfs_alloc_longest_free_extent(struct xfs_mount *mp,
118 struct xfs_perag *pag); 135 struct xfs_perag *pag);
119 136
120#ifdef __KERNEL__ 137#ifdef __KERNEL__
138void
139xfs_alloc_busy_insert(struct xfs_trans *tp, xfs_agnumber_t agno,
140 xfs_agblock_t bno, xfs_extlen_t len, unsigned int flags);
121 141
122void 142void
123xfs_alloc_busy_insert(xfs_trans_t *tp, 143xfs_alloc_busy_clear(struct xfs_mount *mp, struct list_head *list,
124 xfs_agnumber_t agno, 144 bool do_discard);
125 xfs_agblock_t bno, 145
126 xfs_extlen_t len); 146int
147xfs_alloc_busy_search(struct xfs_mount *mp, xfs_agnumber_t agno,
148 xfs_agblock_t bno, xfs_extlen_t len);
127 149
128void 150void
129xfs_alloc_busy_clear(struct xfs_mount *mp, struct xfs_busy_extent *busyp); 151xfs_alloc_busy_reuse(struct xfs_mount *mp, xfs_agnumber_t agno,
152 xfs_agblock_t fbno, xfs_extlen_t flen, bool userdata);
153
154int
155xfs_busy_extent_ag_cmp(void *priv, struct list_head *a, struct list_head *b);
156
157static inline void xfs_alloc_busy_sort(struct list_head *list)
158{
159 list_sort(NULL, list, xfs_busy_extent_ag_cmp);
160}
130 161
131#endif /* __KERNEL__ */ 162#endif /* __KERNEL__ */
132 163
@@ -205,4 +236,18 @@ xfs_free_extent(
205 xfs_fsblock_t bno, /* starting block number of extent */ 236 xfs_fsblock_t bno, /* starting block number of extent */
206 xfs_extlen_t len); /* length of extent */ 237 xfs_extlen_t len); /* length of extent */
207 238
239int /* error */
240xfs_alloc_lookup_le(
241 struct xfs_btree_cur *cur, /* btree cursor */
242 xfs_agblock_t bno, /* starting block of extent */
243 xfs_extlen_t len, /* length of extent */
244 int *stat); /* success/failure */
245
246int /* error */
247xfs_alloc_get_rec(
248 struct xfs_btree_cur *cur, /* btree cursor */
249 xfs_agblock_t *bno, /* output: starting block of extent */
250 xfs_extlen_t *len, /* output: length of extent */
251 int *stat); /* output: success/failure */
252
208#endif /* __XFS_ALLOC_H__ */ 253#endif /* __XFS_ALLOC_H__ */