aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap_btree.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 02:11:19 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:11:19 -0400
commit60197e8df364df326dcbb987519f367ad0ee1a11 (patch)
tree18b38d1711a49363fd5f20f04159b360ee3ec833 /fs/xfs/xfs_bmap_btree.h
parent5b4d89ae0f5ae45c7fa1dfc616fd2bb8634bb7b7 (diff)
[XFS] Cleanup maxrecs calculation.
Clean up the way the maximum and minimum records for the btree blocks are calculated. For the alloc and inobt btrees all the values are pre-calculated in xfs_mount_common, and we switch the current loop around the ugly generic macros that use cpp token pasting to generate type names to two small helpers in normal C code. For the bmbt and bmdr trees these helpers also exist, but can be called during runtime, too. Here we also kill various macros dealing with them and inline the logic into the get_minrecs / get_maxrecs / get_dmaxrecs methods in xfs_bmap_btree.c. Note that all these new helpers take an xfs_mount * argument which will be needed to determine the size of a btree block once we add support for extended btree blocks with CRCs and other RAS information. SGI-PV: 988146 SGI-Modid: xfs-linux-melb:xfs-kern:32292a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Donald Douwsma <donaldd@sgi.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.h48
1 files changed, 12 insertions, 36 deletions
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 5669242b52d3..835be2a84ca1 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -151,33 +151,6 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
151 151
152#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp)) 152#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp))
153 153
154#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize)
155#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \
156 ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \
157 (cur)->bc_private.b.whichfork)->if_broot_bytes)
158
159#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \
160 (((lev) == (cur)->bc_nlevels - 1 ? \
161 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \
162 xfs_bmdr, (lev) == 0) : \
163 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
164#define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) \
165 (((lev) == (cur)->bc_nlevels - 1 ? \
166 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\
167 xfs_bmbt, (lev) == 0) : \
168 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
169
170#define XFS_BMAP_BLOCK_DMINRECS(lev,cur) \
171 (((lev) == (cur)->bc_nlevels - 1 ? \
172 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur),\
173 xfs_bmdr, (lev) == 0) : \
174 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
175#define XFS_BMAP_BLOCK_IMINRECS(lev,cur) \
176 (((lev) == (cur)->bc_nlevels - 1 ? \
177 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\
178 xfs_bmbt, (lev) == 0) : \
179 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
180
181#define XFS_BMAP_REC_DADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i)) 154#define XFS_BMAP_REC_DADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i))
182 155
183#define XFS_BMAP_REC_IADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i)) 156#define XFS_BMAP_REC_IADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i))
@@ -192,8 +165,8 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
192 (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ 165 (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
193 be16_to_cpu((bb)->bb_level), cur))) 166 be16_to_cpu((bb)->bb_level), cur)))
194#define XFS_BMAP_PTR_IADDR(bb,i,cur) \ 167#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
195 (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ 168 (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, xfs_bmbt_get_maxrecs(cur, \
196 be16_to_cpu((bb)->bb_level), cur))) 169 be16_to_cpu((bb)->bb_level))))
197 170
198/* 171/*
199 * These are to be used when we know the size of the block and 172 * These are to be used when we know the size of the block and
@@ -203,11 +176,8 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
203 (XFS_BTREE_REC_ADDR(xfs_bmbt,bb,i)) 176 (XFS_BTREE_REC_ADDR(xfs_bmbt,bb,i))
204#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \ 177#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \
205 (XFS_BTREE_KEY_ADDR(xfs_bmbt,bb,i)) 178 (XFS_BTREE_KEY_ADDR(xfs_bmbt,bb,i))
206#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \ 179#define XFS_BMAP_BROOT_PTR_ADDR(mp, bb,i,sz) \
207 (XFS_BTREE_PTR_ADDR(xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz))) 180 (XFS_BTREE_PTR_ADDR(xfs_bmbt,bb,i,xfs_bmbt_maxrecs(mp, sz, 0)))
208
209#define XFS_BMAP_BROOT_NUMRECS(bb) be16_to_cpu((bb)->bb_numrecs)
210#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0)
211 181
212#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ 182#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \
213 (int)(sizeof(xfs_bmbt_block_t) + \ 183 (int)(sizeof(xfs_bmbt_block_t) + \
@@ -234,7 +204,8 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
234/* 204/*
235 * Prototypes for xfs_bmap.c to call. 205 * Prototypes for xfs_bmap.c to call.
236 */ 206 */
237extern void xfs_bmdr_to_bmbt(xfs_bmdr_block_t *, int, xfs_bmbt_block_t *, int); 207extern void xfs_bmdr_to_bmbt(struct xfs_mount *, xfs_bmdr_block_t *, int,
208 xfs_bmbt_block_t *, int);
238extern void xfs_bmbt_get_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s); 209extern void xfs_bmbt_get_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s);
239extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_host_t *r); 210extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_host_t *r);
240extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_host_t *r); 211extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_host_t *r);
@@ -257,7 +228,12 @@ extern void xfs_bmbt_disk_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
257extern void xfs_bmbt_disk_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o, 228extern void xfs_bmbt_disk_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o,
258 xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v); 229 xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
259 230
260extern void xfs_bmbt_to_bmdr(xfs_bmbt_block_t *, int, xfs_bmdr_block_t *, int); 231extern void xfs_bmbt_to_bmdr(struct xfs_mount *, xfs_bmbt_block_t *, int,
232 xfs_bmdr_block_t *, int);
233
234extern int xfs_bmbt_get_maxrecs(struct xfs_btree_cur *, int level);
235extern int xfs_bmdr_maxrecs(struct xfs_mount *, int blocklen, int leaf);
236extern int xfs_bmbt_maxrecs(struct xfs_mount *, int blocklen, int leaf);
261 237
262extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *, 238extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
263 struct xfs_trans *, struct xfs_inode *, int); 239 struct xfs_trans *, struct xfs_inode *, int);