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.h44
1 files changed, 21 insertions, 23 deletions
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 7478b1b1aa2b..e095a2d344ae 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -28,10 +28,9 @@ struct xfs_inode;
28/* 28/*
29 * Bmap root header, on-disk form only. 29 * Bmap root header, on-disk form only.
30 */ 30 */
31typedef struct xfs_bmdr_block 31typedef struct xfs_bmdr_block {
32{ 32 __be16 bb_level; /* 0 is a leaf */
33 __uint16_t bb_level; /* 0 is a leaf */ 33 __be16 bb_numrecs; /* current # of data records */
34 __uint16_t bb_numrecs; /* current # of data records */
35} xfs_bmdr_block_t; 34} xfs_bmdr_block_t;
36 35
37/* 36/*
@@ -212,36 +211,36 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
212 211
213#define XFS_BMAP_REC_DADDR(bb,i,cur) \ 212#define XFS_BMAP_REC_DADDR(bb,i,cur) \
214 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 213 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \
215 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 214 be16_to_cpu((bb)->bb_level), cur), \
216 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ 215 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
217 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))) 216 be16_to_cpu((bb)->bb_level), cur)))
218#define XFS_BMAP_REC_IADDR(bb,i,cur) \ 217#define XFS_BMAP_REC_IADDR(bb,i,cur) \
219 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \ 218 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \
220 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 219 be16_to_cpu((bb)->bb_level), cur), \
221 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ 220 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
222 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))) 221 be16_to_cpu((bb)->bb_level), cur)))
223 222
224#define XFS_BMAP_KEY_DADDR(bb,i,cur) \ 223#define XFS_BMAP_KEY_DADDR(bb,i,cur) \
225 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 224 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \
226 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 225 be16_to_cpu((bb)->bb_level), cur), \
227 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ 226 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
228 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))) 227 be16_to_cpu((bb)->bb_level), cur)))
229#define XFS_BMAP_KEY_IADDR(bb,i,cur) \ 228#define XFS_BMAP_KEY_IADDR(bb,i,cur) \
230 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \ 229 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \
231 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 230 be16_to_cpu((bb)->bb_level), cur), \
232 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ 231 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
233 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))) 232 be16_to_cpu((bb)->bb_level), cur)))
234 233
235#define XFS_BMAP_PTR_DADDR(bb,i,cur) \ 234#define XFS_BMAP_PTR_DADDR(bb,i,cur) \
236 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 235 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \
237 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 236 be16_to_cpu((bb)->bb_level), cur), \
238 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ 237 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
239 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))) 238 be16_to_cpu((bb)->bb_level), cur)))
240#define XFS_BMAP_PTR_IADDR(bb,i,cur) \ 239#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
241 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \ 240 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \
242 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 241 be16_to_cpu((bb)->bb_level), cur), \
243 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ 242 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
244 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))) 243 be16_to_cpu((bb)->bb_level), cur)))
245 244
246/* 245/*
247 * These are to be used when we know the size of the block and 246 * These are to be used when we know the size of the block and
@@ -254,7 +253,7 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
254#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \ 253#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \
255 (XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz))) 254 (XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
256 255
257#define XFS_BMAP_BROOT_NUMRECS(bb) INT_GET((bb)->bb_numrecs, ARCH_CONVERT) 256#define XFS_BMAP_BROOT_NUMRECS(bb) be16_to_cpu((bb)->bb_numrecs)
258#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0) 257#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0)
259 258
260#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ 259#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \
@@ -262,7 +261,7 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
262 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))) 261 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
263 262
264#define XFS_BMAP_BROOT_SPACE(bb) \ 263#define XFS_BMAP_BROOT_SPACE(bb) \
265 (XFS_BMAP_BROOT_SPACE_CALC(INT_GET((bb)->bb_numrecs, ARCH_CONVERT))) 264 (XFS_BMAP_BROOT_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs)))
266#define XFS_BMDR_SPACE_CALC(nrecs) \ 265#define XFS_BMDR_SPACE_CALC(nrecs) \
267 (int)(sizeof(xfs_bmdr_block_t) + \ 266 (int)(sizeof(xfs_bmdr_block_t) + \
268 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))) 267 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
@@ -273,11 +272,10 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
273#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[(w)]) 272#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[(w)])
274 273
275#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \ 274#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \
276 (INT_GET((bb)->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC && \ 275 (be32_to_cpu((bb)->bb_magic) == XFS_BMAP_MAGIC && \
277 INT_GET((bb)->bb_level, ARCH_CONVERT) == level && \ 276 be16_to_cpu((bb)->bb_level) == level && \
278 INT_GET((bb)->bb_numrecs, ARCH_CONVERT) > 0 && \ 277 be16_to_cpu((bb)->bb_numrecs) > 0 && \
279 INT_GET((bb)->bb_numrecs, ARCH_CONVERT) <= \ 278 be16_to_cpu((bb)->bb_numrecs) <= (mp)->m_bmap_dmxr[(level) != 0])
280 (mp)->m_bmap_dmxr[(level) != 0])
281 279
282 280
283#ifdef __KERNEL__ 281#ifdef __KERNEL__