aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap_btree.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 02:11:40 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:11:40 -0400
commit136341b41ad4883bd668120f727a52c42331fe8a (patch)
tree0cb1b220073948f2632911354a828606a9e276bb /fs/xfs/xfs_bmap_btree.h
parent6c7699c047c50403149ad91331dd39de47dea070 (diff)
[XFS] cleanup btree record / key / ptr addressing macros.
Replace the generic record / key / ptr addressing macros that use cpp token pasting with simpler macros that do the job for just one given btree type. The new macros lose the cur argument and thus can be used outside the core btree code, but also gain an xfs_mount * argument to allow for checking the CRC flag in the near future. Note that many of these macros aren't actually used in the kernel code, but only in userspace (mostly in xfs_repair). SGI-PV: 988146 SGI-Modid: xfs-linux-melb:xfs-kern:32295a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Donald Douwsma <donaldd@sgi.com> Signed-off-by: David Chinner <david@fromorbit.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_bmap_btree.h')
-rw-r--r--fs/xfs/xfs_bmap_btree.h62
1 files changed, 40 insertions, 22 deletions
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 835be2a84ca1..7f001072db47 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -21,6 +21,7 @@
21#define XFS_BMAP_MAGIC 0x424d4150 /* 'BMAP' */ 21#define XFS_BMAP_MAGIC 0x424d4150 /* 'BMAP' */
22 22
23struct xfs_btree_cur; 23struct xfs_btree_cur;
24struct xfs_btree_block;
24struct xfs_btree_lblock; 25struct xfs_btree_lblock;
25struct xfs_mount; 26struct xfs_mount;
26struct xfs_inode; 27struct xfs_inode;
@@ -151,33 +152,50 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
151 152
152#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp)) 153#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp))
153 154
154#define XFS_BMAP_REC_DADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i)) 155#define XFS_BMBT_REC_ADDR(mp, block, index) \
155 156 ((xfs_bmbt_rec_t *) \
156#define XFS_BMAP_REC_IADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i)) 157 ((char *)(block) + \
157 158 sizeof(struct xfs_btree_lblock) + \
158#define XFS_BMAP_KEY_DADDR(bb,i,cur) \ 159 ((index) - 1) * sizeof(xfs_bmbt_rec_t)))
159 (XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i)) 160
160 161#define XFS_BMBT_KEY_ADDR(mp, block, index) \
161#define XFS_BMAP_KEY_IADDR(bb,i,cur) \ 162 ((xfs_bmbt_key_t *) \
162 (XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i)) 163 ((char *)(block) + \
163 164 sizeof(struct xfs_btree_lblock) + \
164#define XFS_BMAP_PTR_DADDR(bb,i,cur) \ 165 ((index) - 1) * sizeof(xfs_bmbt_key_t)))
165 (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ 166
166 be16_to_cpu((bb)->bb_level), cur))) 167#define XFS_BMBT_PTR_ADDR(mp, block, index, maxrecs) \
167#define XFS_BMAP_PTR_IADDR(bb,i,cur) \ 168 ((xfs_bmbt_ptr_t *) \
168 (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, xfs_bmbt_get_maxrecs(cur, \ 169 ((char *)(block) + \
169 be16_to_cpu((bb)->bb_level)))) 170 sizeof(struct xfs_btree_lblock) + \
171 (maxrecs) * sizeof(xfs_bmbt_key_t) + \
172 ((index) - 1) * sizeof(xfs_bmbt_ptr_t)))
173
174#define XFS_BMDR_REC_ADDR(block, index) \
175 ((xfs_bmdr_rec_t *) \
176 ((char *)(block) + \
177 sizeof(struct xfs_bmdr_block) + \
178 ((index) - 1) * sizeof(xfs_bmdr_rec_t)))
179
180#define XFS_BMDR_KEY_ADDR(block, index) \
181 ((xfs_bmdr_key_t *) \
182 ((char *)(block) + \
183 sizeof(struct xfs_bmdr_block) + \
184 ((index) - 1) * sizeof(xfs_bmdr_key_t)))
185
186#define XFS_BMDR_PTR_ADDR(block, index, maxrecs) \
187 ((xfs_bmdr_ptr_t *) \
188 ((char *)(block) + \
189 sizeof(struct xfs_bmdr_block) + \
190 (maxrecs) * sizeof(xfs_bmdr_key_t) + \
191 ((index) - 1) * sizeof(xfs_bmdr_ptr_t)))
170 192
171/* 193/*
172 * These are to be used when we know the size of the block and 194 * These are to be used when we know the size of the block and
173 * we don't have a cursor. 195 * we don't have a cursor.
174 */ 196 */
175#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \ 197#define XFS_BMAP_BROOT_PTR_ADDR(mp, bb, i, sz) \
176 (XFS_BTREE_REC_ADDR(xfs_bmbt,bb,i)) 198 XFS_BMBT_PTR_ADDR(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, 0))
177#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \
178 (XFS_BTREE_KEY_ADDR(xfs_bmbt,bb,i))
179#define XFS_BMAP_BROOT_PTR_ADDR(mp, bb,i,sz) \
180 (XFS_BTREE_PTR_ADDR(xfs_bmbt,bb,i,xfs_bmbt_maxrecs(mp, sz, 0)))
181 199
182#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ 200#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \
183 (int)(sizeof(xfs_bmbt_block_t) + \ 201 (int)(sizeof(xfs_bmbt_block_t) + \