aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_alloc_btree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_alloc_btree.h')
-rw-r--r--fs/xfs/xfs_alloc_btree.h135
1 files changed, 23 insertions, 112 deletions
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h
index ed5161a572ef..f857b0f248d3 100644
--- a/fs/xfs/xfs_alloc_btree.h
+++ b/fs/xfs/xfs_alloc_btree.h
@@ -62,38 +62,14 @@ typedef xfs_agblock_t xfs_alloc_ptr_t; /* btree pointer type */
62 /* btree block header type */ 62 /* btree block header type */
63typedef struct xfs_btree_sblock xfs_alloc_block_t; 63typedef struct xfs_btree_sblock xfs_alloc_block_t;
64 64
65#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_ALLOC_BLOCK) 65#define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)XFS_BUF_PTR(bp))
66xfs_alloc_block_t *xfs_buf_to_alloc_block(struct xfs_buf *bp);
67#define XFS_BUF_TO_ALLOC_BLOCK(bp) xfs_buf_to_alloc_block(bp)
68#else
69#define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)(XFS_BUF_PTR(bp)))
70#endif
71 66
72/* 67/*
73 * Real block structures have a size equal to the disk block size. 68 * Real block structures have a size equal to the disk block size.
74 */ 69 */
75
76#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_SIZE)
77int xfs_alloc_block_size(int lev, struct xfs_btree_cur *cur);
78#define XFS_ALLOC_BLOCK_SIZE(lev,cur) xfs_alloc_block_size(lev,cur)
79#else
80#define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) 70#define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
81#endif 71#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_alloc_mxr[lev != 0])
82 72#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_alloc_mnr[lev != 0])
83#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MAXRECS)
84int xfs_alloc_block_maxrecs(int lev, struct xfs_btree_cur *cur);
85#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) xfs_alloc_block_maxrecs(lev,cur)
86#else
87#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) \
88 ((cur)->bc_mp->m_alloc_mxr[lev != 0])
89#endif
90#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MINRECS)
91int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur);
92#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) xfs_alloc_block_minrecs(lev,cur)
93#else
94#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) \
95 ((cur)->bc_mp->m_alloc_mnr[lev != 0])
96#endif
97 73
98/* 74/*
99 * Minimum and maximum blocksize and sectorsize. 75 * Minimum and maximum blocksize and sectorsize.
@@ -113,145 +89,80 @@ int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur);
113 * Block numbers in the AG: 89 * Block numbers in the AG:
114 * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3. 90 * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3.
115 */ 91 */
116#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BNO_BLOCK)
117xfs_agblock_t xfs_bno_block(struct xfs_mount *mp);
118#define XFS_BNO_BLOCK(mp) xfs_bno_block(mp)
119#else
120#define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1)) 92#define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1))
121#endif
122#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CNT_BLOCK)
123xfs_agblock_t xfs_cnt_block(struct xfs_mount *mp);
124#define XFS_CNT_BLOCK(mp) xfs_cnt_block(mp)
125#else
126#define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) 93#define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1))
127#endif
128 94
129/* 95/*
130 * Record, key, and pointer address macros for btree blocks. 96 * Record, key, and pointer address macros for btree blocks.
131 */ 97 */
132#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_REC_ADDR)
133xfs_alloc_rec_t *xfs_alloc_rec_addr(xfs_alloc_block_t *bb, int i,
134 struct xfs_btree_cur *cur);
135#define XFS_ALLOC_REC_ADDR(bb,i,cur) xfs_alloc_rec_addr(bb,i,cur)
136#else
137#define XFS_ALLOC_REC_ADDR(bb,i,cur) \ 98#define XFS_ALLOC_REC_ADDR(bb,i,cur) \
138 XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, bb, i, \ 99 XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, \
139 XFS_ALLOC_BLOCK_MAXRECS(0, cur)) 100 bb, i, XFS_ALLOC_BLOCK_MAXRECS(0, cur))
140#endif
141 101
142#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_KEY_ADDR)
143xfs_alloc_key_t *xfs_alloc_key_addr(xfs_alloc_block_t *bb, int i,
144 struct xfs_btree_cur *cur);
145#define XFS_ALLOC_KEY_ADDR(bb,i,cur) xfs_alloc_key_addr(bb,i,cur)
146#else
147#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \ 102#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \
148 XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ 103 XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \
149 XFS_ALLOC_BLOCK_MAXRECS(1, cur)) 104 bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
150#endif
151 105
152#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_PTR_ADDR)
153xfs_alloc_ptr_t *xfs_alloc_ptr_addr(xfs_alloc_block_t *bb, int i,
154 struct xfs_btree_cur *cur);
155#define XFS_ALLOC_PTR_ADDR(bb,i,cur) xfs_alloc_ptr_addr(bb,i,cur)
156#else
157#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ 106#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \
158 XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ 107 XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \
159 XFS_ALLOC_BLOCK_MAXRECS(1, cur)) 108 bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
160#endif
161
162/*
163 * Prototypes for externally visible routines.
164 */
165 109
166/* 110/*
167 * Decrement cursor by one record at the level. 111 * Decrement cursor by one record at the level.
168 * For nonzero levels the leaf-ward information is untouched. 112 * For nonzero levels the leaf-ward information is untouched.
169 */ 113 */
170int /* error */ 114extern int xfs_alloc_decrement(struct xfs_btree_cur *cur, int level, int *stat);
171xfs_alloc_decrement(
172 struct xfs_btree_cur *cur, /* btree cursor */
173 int level, /* level in btree, 0 is leaf */
174 int *stat); /* success/failure */
175 115
176/* 116/*
177 * Delete the record pointed to by cur. 117 * Delete the record pointed to by cur.
178 * The cursor refers to the place where the record was (could be inserted) 118 * The cursor refers to the place where the record was (could be inserted)
179 * when the operation returns. 119 * when the operation returns.
180 */ 120 */
181int /* error */ 121extern int xfs_alloc_delete(struct xfs_btree_cur *cur, int *stat);
182xfs_alloc_delete(
183 struct xfs_btree_cur *cur, /* btree cursor */
184 int *stat); /* success/failure */
185 122
186/* 123/*
187 * Get the data from the pointed-to record. 124 * Get the data from the pointed-to record.
188 */ 125 */
189int /* error */ 126extern int xfs_alloc_get_rec(struct xfs_btree_cur *cur, xfs_agblock_t *bno,
190xfs_alloc_get_rec( 127 xfs_extlen_t *len, int *stat);
191 struct xfs_btree_cur *cur, /* btree cursor */
192 xfs_agblock_t *bno, /* output: starting block of extent */
193 xfs_extlen_t *len, /* output: length of extent */
194 int *stat); /* output: success/failure */
195 128
196/* 129/*
197 * Increment cursor by one record at the level. 130 * Increment cursor by one record at the level.
198 * For nonzero levels the leaf-ward information is untouched. 131 * For nonzero levels the leaf-ward information is untouched.
199 */ 132 */
200int /* error */ 133extern int xfs_alloc_increment(struct xfs_btree_cur *cur, int level, int *stat);
201xfs_alloc_increment(
202 struct xfs_btree_cur *cur, /* btree cursor */
203 int level, /* level in btree, 0 is leaf */
204 int *stat); /* success/failure */
205 134
206/* 135/*
207 * Insert the current record at the point referenced by cur. 136 * Insert the current record at the point referenced by cur.
208 * The cursor may be inconsistent on return if splits have been done. 137 * The cursor may be inconsistent on return if splits have been done.
209 */ 138 */
210int /* error */ 139extern int xfs_alloc_insert(struct xfs_btree_cur *cur, int *stat);
211xfs_alloc_insert(
212 struct xfs_btree_cur *cur, /* btree cursor */
213 int *stat); /* success/failure */
214 140
215/* 141/*
216 * Lookup the record equal to [bno, len] in the btree given by cur. 142 * Lookup the record equal to [bno, len] in the btree given by cur.
217 */ 143 */
218int /* error */ 144extern int xfs_alloc_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno,
219xfs_alloc_lookup_eq( 145 xfs_extlen_t len, int *stat);
220 struct xfs_btree_cur *cur, /* btree cursor */
221 xfs_agblock_t bno, /* starting block of extent */
222 xfs_extlen_t len, /* length of extent */
223 int *stat); /* success/failure */
224 146
225/* 147/*
226 * Lookup the first record greater than or equal to [bno, len] 148 * Lookup the first record greater than or equal to [bno, len]
227 * in the btree given by cur. 149 * in the btree given by cur.
228 */ 150 */
229int /* error */ 151extern int xfs_alloc_lookup_ge(struct xfs_btree_cur *cur, xfs_agblock_t bno,
230xfs_alloc_lookup_ge( 152 xfs_extlen_t len, int *stat);
231 struct xfs_btree_cur *cur, /* btree cursor */
232 xfs_agblock_t bno, /* starting block of extent */
233 xfs_extlen_t len, /* length of extent */
234 int *stat); /* success/failure */
235 153
236/* 154/*
237 * Lookup the first record less than or equal to [bno, len] 155 * Lookup the first record less than or equal to [bno, len]
238 * in the btree given by cur. 156 * in the btree given by cur.
239 */ 157 */
240int /* error */ 158extern int xfs_alloc_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno,
241xfs_alloc_lookup_le( 159 xfs_extlen_t len, int *stat);
242 struct xfs_btree_cur *cur, /* btree cursor */
243 xfs_agblock_t bno, /* starting block of extent */
244 xfs_extlen_t len, /* length of extent */
245 int *stat); /* success/failure */
246 160
247/* 161/*
248 * Update the record referred to by cur, to the value given by [bno, len]. 162 * Update the record referred to by cur, to the value given by [bno, len].
249 * This either works (return 0) or gets an EFSCORRUPTED error. 163 * This either works (return 0) or gets an EFSCORRUPTED error.
250 */ 164 */
251int /* error */ 165extern int xfs_alloc_update(struct xfs_btree_cur *cur, xfs_agblock_t bno,
252xfs_alloc_update( 166 xfs_extlen_t len);
253 struct xfs_btree_cur *cur, /* btree cursor */
254 xfs_agblock_t bno, /* starting block of extent */
255 xfs_extlen_t len); /* length of extent */
256 167
257#endif /* __XFS_ALLOC_BTREE_H__ */ 168#endif /* __XFS_ALLOC_BTREE_H__ */