aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap_btree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_bmap_btree.h')
-rw-r--r--fs/xfs/xfs_bmap_btree.h596
1 files changed, 152 insertions, 444 deletions
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 2cf4fe45cbcb..ff0102d14918 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -114,31 +114,31 @@ typedef xfs_bmbt_rec_64_t xfs_bmbt_rec_t, xfs_bmdr_rec_t;
114 (((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) 114 (((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS)
115#define DSTARTBLOCKMASK \ 115#define DSTARTBLOCKMASK \
116 (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) 116 (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS)
117#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_ISNULLSTARTBLOCK) 117
118int isnullstartblock(xfs_fsblock_t x);
119#define ISNULLSTARTBLOCK(x) isnullstartblock(x) 118#define ISNULLSTARTBLOCK(x) isnullstartblock(x)
120#else 119static inline int isnullstartblock(xfs_fsblock_t x)
121#define ISNULLSTARTBLOCK(x) (((x) & STARTBLOCKMASK) == STARTBLOCKMASK) 120{
122#endif 121 return ((x) & STARTBLOCKMASK) == STARTBLOCKMASK;
123#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_ISNULLDSTARTBLOCK) 122}
124int isnulldstartblock(xfs_dfsbno_t x); 123
125#define ISNULLDSTARTBLOCK(x) isnulldstartblock(x) 124#define ISNULLDSTARTBLOCK(x) isnulldstartblock(x)
126#else 125static inline int isnulldstartblock(xfs_dfsbno_t x)
127#define ISNULLDSTARTBLOCK(x) (((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK) 126{
128#endif 127 return ((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK;
129#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_NULLSTARTBLOCK) 128}
130xfs_fsblock_t nullstartblock(int k); 129
131#define NULLSTARTBLOCK(k) nullstartblock(k) 130#define NULLSTARTBLOCK(k) nullstartblock(k)
132#else 131static inline xfs_fsblock_t nullstartblock(int k)
133#define NULLSTARTBLOCK(k) \ 132{
134 ((ASSERT(k < (1 << STARTBLOCKVALBITS))), (STARTBLOCKMASK | (k))) 133 ASSERT(k < (1 << STARTBLOCKVALBITS));
135#endif 134 return STARTBLOCKMASK | (k);
136#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_STARTBLOCKVAL) 135}
137xfs_filblks_t startblockval(xfs_fsblock_t x); 136
138#define STARTBLOCKVAL(x) startblockval(x) 137#define STARTBLOCKVAL(x) startblockval(x)
139#else 138static inline xfs_filblks_t startblockval(xfs_fsblock_t x)
140#define STARTBLOCKVAL(x) ((xfs_filblks_t)((x) & ~STARTBLOCKMASK)) 139{
141#endif 140 return (xfs_filblks_t)((x) & ~STARTBLOCKMASK);
141}
142 142
143/* 143/*
144 * Possible extent formats. 144 * Possible extent formats.
@@ -159,14 +159,9 @@ typedef enum {
159/* 159/*
160 * Extent state and extent format macros. 160 * Extent state and extent format macros.
161 */ 161 */
162#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTFMT_INODE ) 162#define XFS_EXTFMT_INODE(x) \
163xfs_exntfmt_t xfs_extfmt_inode(struct xfs_inode *ip); 163 (XFS_SB_VERSION_HASEXTFLGBIT(&((x)->i_mount->m_sb)) ? \
164#define XFS_EXTFMT_INODE(x) xfs_extfmt_inode(x) 164 XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE)
165#else
166#define XFS_EXTFMT_INODE(x) \
167 (XFS_SB_VERSION_HASEXTFLGBIT(&((x)->i_mount->m_sb)) ? \
168 XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE)
169#endif
170#define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN) 165#define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN)
171 166
172/* 167/*
@@ -192,248 +187,111 @@ typedef xfs_dfsbno_t xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; /* btree pointer type */
192 /* btree block header type */ 187 /* btree block header type */
193typedef struct xfs_btree_lblock xfs_bmbt_block_t; 188typedef struct xfs_btree_lblock xfs_bmbt_block_t;
194 189
195#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_BMBT_BLOCK) 190#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp))
196xfs_bmbt_block_t *xfs_buf_to_bmbt_block(struct xfs_buf *bp);
197#define XFS_BUF_TO_BMBT_BLOCK(bp) xfs_buf_to_bmbt_block(bp)
198#else
199#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)(XFS_BUF_PTR(bp)))
200#endif
201 191
202#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_RBLOCK_DSIZE) 192#define XFS_BMAP_IBLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
203int xfs_bmap_rblock_dsize(int lev, struct xfs_btree_cur *cur); 193#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize)
204#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) xfs_bmap_rblock_dsize(lev,cur) 194#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \
205#else
206#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize)
207#endif
208#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_RBLOCK_ISIZE)
209int xfs_bmap_rblock_isize(int lev, struct xfs_btree_cur *cur);
210#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) xfs_bmap_rblock_isize(lev,cur)
211#else
212#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \
213 ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \ 195 ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \
214 (cur)->bc_private.b.whichfork)->if_broot_bytes) 196 (cur)->bc_private.b.whichfork)->if_broot_bytes)
215#endif
216#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_IBLOCK_SIZE)
217int xfs_bmap_iblock_size(int lev, struct xfs_btree_cur *cur);
218#define XFS_BMAP_IBLOCK_SIZE(lev,cur) xfs_bmap_iblock_size(lev,cur)
219#else
220#define XFS_BMAP_IBLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
221#endif
222 197
223#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DSIZE) 198#define XFS_BMAP_BLOCK_DSIZE(lev,cur) \
224int xfs_bmap_block_dsize(int lev, struct xfs_btree_cur *cur); 199 (((lev) == (cur)->bc_nlevels - 1 ? \
225#define XFS_BMAP_BLOCK_DSIZE(lev,cur) xfs_bmap_block_dsize(lev,cur) 200 XFS_BMAP_RBLOCK_DSIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur)))
226#else 201#define XFS_BMAP_BLOCK_ISIZE(lev,cur) \
227#define XFS_BMAP_BLOCK_DSIZE(lev,cur) \ 202 (((lev) == (cur)->bc_nlevels - 1 ? \
228 ((lev) == (cur)->bc_nlevels - 1 ? \ 203 XFS_BMAP_RBLOCK_ISIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur)))
229 XFS_BMAP_RBLOCK_DSIZE(lev,cur) : \
230 XFS_BMAP_IBLOCK_SIZE(lev,cur))
231#endif
232#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_ISIZE)
233int xfs_bmap_block_isize(int lev, struct xfs_btree_cur *cur);
234#define XFS_BMAP_BLOCK_ISIZE(lev,cur) xfs_bmap_block_isize(lev,cur)
235#else
236#define XFS_BMAP_BLOCK_ISIZE(lev,cur) \
237 ((lev) == (cur)->bc_nlevels - 1 ? \
238 XFS_BMAP_RBLOCK_ISIZE(lev,cur) : \
239 XFS_BMAP_IBLOCK_SIZE(lev,cur))
240#endif
241 204
242#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DMAXRECS)
243int xfs_bmap_block_dmaxrecs(int lev, struct xfs_btree_cur *cur);
244#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) xfs_bmap_block_dmaxrecs(lev,cur)
245#else
246#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \ 205#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \
247 ((lev) == (cur)->bc_nlevels - 1 ? \ 206 (((lev) == (cur)->bc_nlevels - 1 ? \
248 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ 207 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \
249 xfs_bmdr, (lev) == 0) : \ 208 xfs_bmdr, (lev) == 0) : \
250 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])) 209 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
251#endif
252#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_IMAXRECS)
253int xfs_bmap_block_imaxrecs(int lev, struct xfs_btree_cur *cur);
254#define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) xfs_bmap_block_imaxrecs(lev,cur)
255#else
256#define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) \ 210#define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) \
257 ((lev) == (cur)->bc_nlevels - 1 ? \ 211 (((lev) == (cur)->bc_nlevels - 1 ? \
258 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur), \ 212 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\
259 xfs_bmbt, (lev) == 0) : \ 213 xfs_bmbt, (lev) == 0) : \
260 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])) 214 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
261#endif
262 215
263#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DMINRECS)
264int xfs_bmap_block_dminrecs(int lev, struct xfs_btree_cur *cur);
265#define XFS_BMAP_BLOCK_DMINRECS(lev,cur) xfs_bmap_block_dminrecs(lev,cur)
266#else
267#define XFS_BMAP_BLOCK_DMINRECS(lev,cur) \ 216#define XFS_BMAP_BLOCK_DMINRECS(lev,cur) \
268 ((lev) == (cur)->bc_nlevels - 1 ? \ 217 (((lev) == (cur)->bc_nlevels - 1 ? \
269 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ 218 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur),\
270 xfs_bmdr, (lev) == 0) : \ 219 xfs_bmdr, (lev) == 0) : \
271 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])) 220 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
272#endif
273#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_IMINRECS)
274int xfs_bmap_block_iminrecs(int lev, struct xfs_btree_cur *cur);
275#define XFS_BMAP_BLOCK_IMINRECS(lev,cur) xfs_bmap_block_iminrecs(lev,cur)
276#else
277#define XFS_BMAP_BLOCK_IMINRECS(lev,cur) \ 221#define XFS_BMAP_BLOCK_IMINRECS(lev,cur) \
278 ((lev) == (cur)->bc_nlevels - 1 ? \ 222 (((lev) == (cur)->bc_nlevels - 1 ? \
279 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur), \ 223 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\
280 xfs_bmbt, (lev) == 0) : \ 224 xfs_bmbt, (lev) == 0) : \
281 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])) 225 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
282#endif 226
283 227#define XFS_BMAP_REC_DADDR(bb,i,cur) \
284#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_REC_DADDR) 228 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \
285xfs_bmbt_rec_t * 229 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
286xfs_bmap_rec_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); 230 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
287#define XFS_BMAP_REC_DADDR(bb,i,cur) xfs_bmap_rec_daddr(bb,i,cur) 231 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)))
288#else 232#define XFS_BMAP_REC_IADDR(bb,i,cur) \
289#define XFS_BMAP_REC_DADDR(bb,i,cur) \ 233 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \
290 XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 234 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
291 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 235 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
292 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ 236 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)))
293 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) 237
294#endif 238#define XFS_BMAP_KEY_DADDR(bb,i,cur) \
295#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_REC_IADDR) 239 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \
296xfs_bmbt_rec_t * 240 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
297xfs_bmap_rec_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); 241 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
298#define XFS_BMAP_REC_IADDR(bb,i,cur) xfs_bmap_rec_iaddr(bb,i,cur) 242 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)))
299#else 243#define XFS_BMAP_KEY_IADDR(bb,i,cur) \
300#define XFS_BMAP_REC_IADDR(bb,i,cur) \ 244 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \
301 XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \ 245 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
302 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 246 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
303 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ 247 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)))
304 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) 248
305#endif 249#define XFS_BMAP_PTR_DADDR(bb,i,cur) \
306 250 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \
307#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_KEY_DADDR) 251 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
308xfs_bmbt_key_t * 252 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
309xfs_bmap_key_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); 253 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)))
310#define XFS_BMAP_KEY_DADDR(bb,i,cur) xfs_bmap_key_daddr(bb,i,cur) 254#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
311#else 255 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \
312#define XFS_BMAP_KEY_DADDR(bb,i,cur) \ 256 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
313 XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 257 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
314 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 258 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)))
315 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
316 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
317#endif
318#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_KEY_IADDR)
319xfs_bmbt_key_t *
320xfs_bmap_key_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur);
321#define XFS_BMAP_KEY_IADDR(bb,i,cur) xfs_bmap_key_iaddr(bb,i,cur)
322#else
323#define XFS_BMAP_KEY_IADDR(bb,i,cur) \
324 XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \
325 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
326 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
327 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
328#endif
329
330#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_PTR_DADDR)
331xfs_bmbt_ptr_t *
332xfs_bmap_ptr_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur);
333#define XFS_BMAP_PTR_DADDR(bb,i,cur) xfs_bmap_ptr_daddr(bb,i,cur)
334#else
335#define XFS_BMAP_PTR_DADDR(bb,i,cur) \
336 XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \
337 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
338 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
339 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
340#endif
341#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_PTR_IADDR)
342xfs_bmbt_ptr_t *
343xfs_bmap_ptr_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur);
344#define XFS_BMAP_PTR_IADDR(bb,i,cur) xfs_bmap_ptr_iaddr(bb,i,cur)
345#else
346#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
347 XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \
348 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
349 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
350 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
351#endif
352 259
353/* 260/*
354 * These are to be used when we know the size of the block and 261 * These are to be used when we know the size of the block and
355 * we don't have a cursor. 262 * we don't have a cursor.
356 */ 263 */
357#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_REC_ADDR)
358xfs_bmbt_rec_t *xfs_bmap_broot_rec_addr(xfs_bmbt_block_t *bb, int i, int sz);
359#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) xfs_bmap_broot_rec_addr(bb,i,sz)
360#else
361#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \ 264#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \
362 XFS_BTREE_REC_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) 265 (XFS_BTREE_REC_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
363#endif
364#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_KEY_ADDR)
365xfs_bmbt_key_t *xfs_bmap_broot_key_addr(xfs_bmbt_block_t *bb, int i, int sz);
366#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) xfs_bmap_broot_key_addr(bb,i,sz)
367#else
368#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \ 266#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \
369 XFS_BTREE_KEY_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) 267 (XFS_BTREE_KEY_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
370#endif
371#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_PTR_ADDR)
372xfs_bmbt_ptr_t *xfs_bmap_broot_ptr_addr(xfs_bmbt_block_t *bb, int i, int sz);
373#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) xfs_bmap_broot_ptr_addr(bb,i,sz)
374#else
375#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \ 268#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \
376 XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) 269 (XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
377#endif 270
271#define XFS_BMAP_BROOT_NUMRECS(bb) INT_GET((bb)->bb_numrecs, ARCH_CONVERT)
272#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0)
378 273
379#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_NUMRECS)
380int xfs_bmap_broot_numrecs(xfs_bmdr_block_t *bb);
381#define XFS_BMAP_BROOT_NUMRECS(bb) xfs_bmap_broot_numrecs(bb)
382#else
383#define XFS_BMAP_BROOT_NUMRECS(bb) (INT_GET((bb)->bb_numrecs, ARCH_CONVERT))
384#endif
385#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_MAXRECS)
386int xfs_bmap_broot_maxrecs(int sz);
387#define XFS_BMAP_BROOT_MAXRECS(sz) xfs_bmap_broot_maxrecs(sz)
388#else
389#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0)
390#endif
391#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_SPACE_CALC)
392int xfs_bmap_broot_space_calc(int nrecs);
393#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) xfs_bmap_broot_space_calc(nrecs)
394#else
395#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ 274#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \
396 ((int)(sizeof(xfs_bmbt_block_t) + \ 275 (int)(sizeof(xfs_bmbt_block_t) + \
397 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))) 276 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
398#endif 277
399#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_SPACE)
400int xfs_bmap_broot_space(xfs_bmdr_block_t *bb);
401#define XFS_BMAP_BROOT_SPACE(bb) xfs_bmap_broot_space(bb)
402#else
403#define XFS_BMAP_BROOT_SPACE(bb) \ 278#define XFS_BMAP_BROOT_SPACE(bb) \
404 XFS_BMAP_BROOT_SPACE_CALC(INT_GET((bb)->bb_numrecs, ARCH_CONVERT)) 279 (XFS_BMAP_BROOT_SPACE_CALC(INT_GET((bb)->bb_numrecs, ARCH_CONVERT)))
405#endif 280#define XFS_BMDR_SPACE_CALC(nrecs) \
406#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMDR_SPACE_CALC) 281 (int)(sizeof(xfs_bmdr_block_t) + \
407int xfs_bmdr_space_calc(int nrecs); 282 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
408#define XFS_BMDR_SPACE_CALC(nrecs) xfs_bmdr_space_calc(nrecs)
409#else
410#define XFS_BMDR_SPACE_CALC(nrecs) \
411 ((int)(sizeof(xfs_bmdr_block_t) + \
412 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))))
413#endif
414 283
415/* 284/*
416 * Maximum number of bmap btree levels. 285 * Maximum number of bmap btree levels.
417 */ 286 */
418#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BM_MAXLEVELS) 287#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[(w)])
419int xfs_bm_maxlevels(struct xfs_mount *mp, int w);
420#define XFS_BM_MAXLEVELS(mp,w) xfs_bm_maxlevels(mp,w)
421#else
422#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[w])
423#endif
424 288
425#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_SANITY_CHECK) 289#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \
426int xfs_bmap_sanity_check(struct xfs_mount *mp, xfs_bmbt_block_t *bb,
427 int level);
428#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \
429 xfs_bmap_sanity_check(mp,bb,level)
430#else
431#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \
432 (INT_GET((bb)->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC && \ 290 (INT_GET((bb)->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC && \
433 INT_GET((bb)->bb_level, ARCH_CONVERT) == level && \ 291 INT_GET((bb)->bb_level, ARCH_CONVERT) == level && \
434 INT_GET((bb)->bb_numrecs, ARCH_CONVERT) > 0 && \ 292 INT_GET((bb)->bb_numrecs, ARCH_CONVERT) > 0 && \
435 INT_GET((bb)->bb_numrecs, ARCH_CONVERT) <= (mp)->m_bmap_dmxr[(level) != 0]) 293 INT_GET((bb)->bb_numrecs, ARCH_CONVERT) <= \
436#endif 294 (mp)->m_bmap_dmxr[(level) != 0])
437 295
438 296
439#ifdef __KERNEL__ 297#ifdef __KERNEL__
@@ -459,234 +317,84 @@ extern ktrace_t *xfs_bmbt_trace_buf;
459/* 317/*
460 * Prototypes for xfs_bmap.c to call. 318 * Prototypes for xfs_bmap.c to call.
461 */ 319 */
462 320extern void xfs_bmdr_to_bmbt(xfs_bmdr_block_t *, int, xfs_bmbt_block_t *, int);
463void 321extern int xfs_bmbt_decrement(struct xfs_btree_cur *, int, int *);
464xfs_bmdr_to_bmbt( 322extern int xfs_bmbt_delete(struct xfs_btree_cur *, int *);
465 xfs_bmdr_block_t *, 323extern void xfs_bmbt_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
466 int, 324extern xfs_bmbt_block_t *xfs_bmbt_get_block(struct xfs_btree_cur *cur,
467 xfs_bmbt_block_t *, 325 int, struct xfs_buf **bpp);
468 int); 326extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_t *r);
469 327extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_t *r);
470int 328extern xfs_fileoff_t xfs_bmbt_get_startoff(xfs_bmbt_rec_t *r);
471xfs_bmbt_decrement( 329extern xfs_exntst_t xfs_bmbt_get_state(xfs_bmbt_rec_t *r);
472 struct xfs_btree_cur *,
473 int,
474 int *);
475
476int
477xfs_bmbt_delete(
478 struct xfs_btree_cur *,
479 int *);
480
481void
482xfs_bmbt_get_all(
483 xfs_bmbt_rec_t *r,
484 xfs_bmbt_irec_t *s);
485
486xfs_bmbt_block_t *
487xfs_bmbt_get_block(
488 struct xfs_btree_cur *cur,
489 int level,
490 struct xfs_buf **bpp);
491
492xfs_filblks_t
493xfs_bmbt_get_blockcount(
494 xfs_bmbt_rec_t *r);
495
496xfs_fsblock_t
497xfs_bmbt_get_startblock(
498 xfs_bmbt_rec_t *r);
499
500xfs_fileoff_t
501xfs_bmbt_get_startoff(
502 xfs_bmbt_rec_t *r);
503
504xfs_exntst_t
505xfs_bmbt_get_state(
506 xfs_bmbt_rec_t *r);
507 330
508#ifndef XFS_NATIVE_HOST 331#ifndef XFS_NATIVE_HOST
509void 332extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
510xfs_bmbt_disk_get_all( 333extern xfs_exntst_t xfs_bmbt_disk_get_state(xfs_bmbt_rec_t *r);
511 xfs_bmbt_rec_t *r, 334extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r);
512 xfs_bmbt_irec_t *s); 335extern xfs_fsblock_t xfs_bmbt_disk_get_startblock(xfs_bmbt_rec_t *r);
513 336extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(xfs_bmbt_rec_t *r);
514xfs_exntst_t 337#else
515xfs_bmbt_disk_get_state( 338#define xfs_bmbt_disk_get_all(r, s) xfs_bmbt_get_all(r, s)
516 xfs_bmbt_rec_t *r); 339#define xfs_bmbt_disk_get_state(r) xfs_bmbt_get_state(r)
517 340#define xfs_bmbt_disk_get_blockcount(r) xfs_bmbt_get_blockcount(r)
518xfs_filblks_t 341#define xfs_bmbt_disk_get_startblock(r) xfs_bmbt_get_blockcount(r)
519xfs_bmbt_disk_get_blockcount( 342#define xfs_bmbt_disk_get_startoff(r) xfs_bmbt_get_startoff(r)
520 xfs_bmbt_rec_t *r);
521
522xfs_fsblock_t
523xfs_bmbt_disk_get_startblock(
524 xfs_bmbt_rec_t *r);
525
526xfs_fileoff_t
527xfs_bmbt_disk_get_startoff(
528 xfs_bmbt_rec_t *r);
529
530#else
531#define xfs_bmbt_disk_get_all(r, s) \
532 xfs_bmbt_get_all(r, s)
533#define xfs_bmbt_disk_get_state(r) \
534 xfs_bmbt_get_state(r)
535#define xfs_bmbt_disk_get_blockcount(r) \
536 xfs_bmbt_get_blockcount(r)
537#define xfs_bmbt_disk_get_startblock(r) \
538 xfs_bmbt_get_blockcount(r)
539#define xfs_bmbt_disk_get_startoff(r) \
540 xfs_bmbt_get_startoff(r)
541#endif /* XFS_NATIVE_HOST */ 343#endif /* XFS_NATIVE_HOST */
542 344
543int 345extern int xfs_bmbt_increment(struct xfs_btree_cur *, int, int *);
544xfs_bmbt_increment( 346extern int xfs_bmbt_insert(struct xfs_btree_cur *, int *);
545 struct xfs_btree_cur *, 347extern void xfs_bmbt_log_block(struct xfs_btree_cur *, struct xfs_buf *, int);
546 int, 348extern void xfs_bmbt_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int,
547 int *); 349 int);
548 350extern int xfs_bmbt_lookup_eq(struct xfs_btree_cur *, xfs_fileoff_t,
549int 351 xfs_fsblock_t, xfs_filblks_t, int *);
550xfs_bmbt_insert( 352extern int xfs_bmbt_lookup_ge(struct xfs_btree_cur *, xfs_fileoff_t,
551 struct xfs_btree_cur *, 353 xfs_fsblock_t, xfs_filblks_t, int *);
552 int *);
553
554void
555xfs_bmbt_log_block(
556 struct xfs_btree_cur *,
557 struct xfs_buf *,
558 int);
559
560void
561xfs_bmbt_log_recs(
562 struct xfs_btree_cur *,
563 struct xfs_buf *,
564 int,
565 int);
566
567int
568xfs_bmbt_lookup_eq(
569 struct xfs_btree_cur *,
570 xfs_fileoff_t,
571 xfs_fsblock_t,
572 xfs_filblks_t,
573 int *);
574
575int
576xfs_bmbt_lookup_ge(
577 struct xfs_btree_cur *,
578 xfs_fileoff_t,
579 xfs_fsblock_t,
580 xfs_filblks_t,
581 int *);
582 354
583/* 355/*
584 * Give the bmap btree a new root block. Copy the old broot contents 356 * Give the bmap btree a new root block. Copy the old broot contents
585 * down into a real block and make the broot point to it. 357 * down into a real block and make the broot point to it.
586 */ 358 */
587int /* error */ 359extern int xfs_bmbt_newroot(struct xfs_btree_cur *cur, int *lflags, int *stat);
588xfs_bmbt_newroot( 360
589 struct xfs_btree_cur *cur, /* btree cursor */ 361extern void xfs_bmbt_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
590 int *logflags, /* logging flags for inode */ 362extern void xfs_bmbt_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o,
591 int *stat); /* return status - 0 fail */ 363 xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
592 364extern void xfs_bmbt_set_blockcount(xfs_bmbt_rec_t *r, xfs_filblks_t v);
593void 365extern void xfs_bmbt_set_startblock(xfs_bmbt_rec_t *r, xfs_fsblock_t v);
594xfs_bmbt_set_all( 366extern void xfs_bmbt_set_startoff(xfs_bmbt_rec_t *r, xfs_fileoff_t v);
595 xfs_bmbt_rec_t *r, 367extern void xfs_bmbt_set_state(xfs_bmbt_rec_t *r, xfs_exntst_t v);
596 xfs_bmbt_irec_t *s);
597
598void
599xfs_bmbt_set_allf(
600 xfs_bmbt_rec_t *r,
601 xfs_fileoff_t o,
602 xfs_fsblock_t b,
603 xfs_filblks_t c,
604 xfs_exntst_t v);
605
606void
607xfs_bmbt_set_blockcount(
608 xfs_bmbt_rec_t *r,
609 xfs_filblks_t v);
610
611void
612xfs_bmbt_set_startblock(
613 xfs_bmbt_rec_t *r,
614 xfs_fsblock_t v);
615
616void
617xfs_bmbt_set_startoff(
618 xfs_bmbt_rec_t *r,
619 xfs_fileoff_t v);
620
621void
622xfs_bmbt_set_state(
623 xfs_bmbt_rec_t *r,
624 xfs_exntst_t v);
625 368
626#ifndef XFS_NATIVE_HOST 369#ifndef XFS_NATIVE_HOST
627void 370extern void xfs_bmbt_disk_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
628xfs_bmbt_disk_set_all( 371extern void xfs_bmbt_disk_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o,
629 xfs_bmbt_rec_t *r, 372 xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
630 xfs_bmbt_irec_t *s);
631
632void
633xfs_bmbt_disk_set_allf(
634 xfs_bmbt_rec_t *r,
635 xfs_fileoff_t o,
636 xfs_fsblock_t b,
637 xfs_filblks_t c,
638 xfs_exntst_t v);
639#else 373#else
640#define xfs_bmbt_disk_set_all(r, s) \ 374#define xfs_bmbt_disk_set_all(r, s) xfs_bmbt_set_all(r, s)
641 xfs_bmbt_set_all(r, s) 375#define xfs_bmbt_disk_set_allf(r, o, b, c, v) xfs_bmbt_set_allf(r, o, b, c, v)
642#define xfs_bmbt_disk_set_allf(r, o, b, c, v) \
643 xfs_bmbt_set_allf(r, o, b, c, v)
644#endif /* XFS_NATIVE_HOST */ 376#endif /* XFS_NATIVE_HOST */
645 377
646void 378extern void xfs_bmbt_to_bmdr(xfs_bmbt_block_t *, int, xfs_bmdr_block_t *, int);
647xfs_bmbt_to_bmdr( 379extern int xfs_bmbt_update(struct xfs_btree_cur *, xfs_fileoff_t,
648 xfs_bmbt_block_t *, 380 xfs_fsblock_t, xfs_filblks_t, xfs_exntst_t);
649 int,
650 xfs_bmdr_block_t *,
651 int);
652
653int
654xfs_bmbt_update(
655 struct xfs_btree_cur *,
656 xfs_fileoff_t,
657 xfs_fsblock_t,
658 xfs_filblks_t,
659 xfs_exntst_t);
660 381
661#ifdef DEBUG 382#ifdef DEBUG
662/* 383/*
663 * Get the data from the pointed-to record. 384 * Get the data from the pointed-to record.
664 */ 385 */
665int 386extern int xfs_bmbt_get_rec(struct xfs_btree_cur *, xfs_fileoff_t *,
666xfs_bmbt_get_rec( 387 xfs_fsblock_t *, xfs_filblks_t *,
667 struct xfs_btree_cur *, 388 xfs_exntst_t *, int *);
668 xfs_fileoff_t *,
669 xfs_fsblock_t *,
670 xfs_filblks_t *,
671 xfs_exntst_t *,
672 int *);
673#endif 389#endif
674 390
675
676/* 391/*
677 * Search an extent list for the extent which includes block 392 * Search an extent list for the extent which includes block
678 * bno. 393 * bno.
679 */ 394 */
680xfs_bmbt_rec_t * 395xfs_bmbt_rec_t *xfs_bmap_do_search_extents(xfs_bmbt_rec_t *,
681xfs_bmap_do_search_extents( 396 xfs_extnum_t, xfs_extnum_t, xfs_fileoff_t, int *,
682 xfs_bmbt_rec_t *, 397 xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *);
683 xfs_extnum_t,
684 xfs_extnum_t,
685 xfs_fileoff_t,
686 int *,
687 xfs_extnum_t *,
688 xfs_bmbt_irec_t *,
689 xfs_bmbt_irec_t *);
690 398
691#endif /* __KERNEL__ */ 399#endif /* __KERNEL__ */
692 400