aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap.c
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.c
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.c')
-rw-r--r--fs/xfs/xfs_bmap.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index b7f99d7576d0..09e4de4ed507 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -3051,15 +3051,15 @@ xfs_bmap_btree_to_extents(
3051 __be64 *pp; /* ptr to block address */ 3051 __be64 *pp; /* ptr to block address */
3052 xfs_bmbt_block_t *rblock;/* root btree block */ 3052 xfs_bmbt_block_t *rblock;/* root btree block */
3053 3053
3054 mp = ip->i_mount;
3054 ifp = XFS_IFORK_PTR(ip, whichfork); 3055 ifp = XFS_IFORK_PTR(ip, whichfork);
3055 ASSERT(ifp->if_flags & XFS_IFEXTENTS); 3056 ASSERT(ifp->if_flags & XFS_IFEXTENTS);
3056 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE); 3057 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE);
3057 rblock = ifp->if_broot; 3058 rblock = ifp->if_broot;
3058 ASSERT(be16_to_cpu(rblock->bb_level) == 1); 3059 ASSERT(be16_to_cpu(rblock->bb_level) == 1);
3059 ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1); 3060 ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1);
3060 ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1); 3061 ASSERT(xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0) == 1);
3061 mp = ip->i_mount; 3062 pp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, ifp->if_broot_bytes);
3062 pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes);
3063 cbno = be64_to_cpu(*pp); 3063 cbno = be64_to_cpu(*pp);
3064 *logflagsp = 0; 3064 *logflagsp = 0;
3065#ifdef DEBUG 3065#ifdef DEBUG
@@ -4221,7 +4221,7 @@ xfs_bmap_compute_maxlevels(
4221 maxleafents = MAXAEXTNUM; 4221 maxleafents = MAXAEXTNUM;
4222 sz = XFS_BMDR_SPACE_CALC(MINABTPTRS); 4222 sz = XFS_BMDR_SPACE_CALC(MINABTPTRS);
4223 } 4223 }
4224 maxrootrecs = (int)XFS_BTREE_BLOCK_MAXRECS(sz, xfs_bmdr, 0); 4224 maxrootrecs = xfs_bmdr_maxrecs(mp, sz, 0);
4225 minleafrecs = mp->m_bmap_dmnr[0]; 4225 minleafrecs = mp->m_bmap_dmnr[0];
4226 minnoderecs = mp->m_bmap_dmnr[1]; 4226 minnoderecs = mp->m_bmap_dmnr[1];
4227 maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs; 4227 maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs;
@@ -4555,7 +4555,7 @@ xfs_bmap_read_extents(
4555 */ 4555 */
4556 level = be16_to_cpu(block->bb_level); 4556 level = be16_to_cpu(block->bb_level);
4557 ASSERT(level > 0); 4557 ASSERT(level > 0);
4558 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); 4558 pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes);
4559 bno = be64_to_cpu(*pp); 4559 bno = be64_to_cpu(*pp);
4560 ASSERT(bno != NULLDFSBNO); 4560 ASSERT(bno != NULLDFSBNO);
4561 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); 4561 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount);
@@ -6205,13 +6205,13 @@ xfs_check_block(
6205 */ 6205 */
6206 6206
6207 if (root) { 6207 if (root) {
6208 pp = XFS_BMAP_BROOT_PTR_ADDR(block, i, sz); 6208 pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, i, sz);
6209 } else { 6209 } else {
6210 pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, i, dmxr); 6210 pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, i, dmxr);
6211 } 6211 }
6212 for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) { 6212 for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) {
6213 if (root) { 6213 if (root) {
6214 thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz); 6214 thispa = XFS_BMAP_BROOT_PTR_ADDR(mp, block, j, sz);
6215 } else { 6215 } else {
6216 thispa = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, j, 6216 thispa = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, j,
6217 dmxr); 6217 dmxr);
@@ -6266,7 +6266,7 @@ xfs_bmap_check_leaf_extents(
6266 level = be16_to_cpu(block->bb_level); 6266 level = be16_to_cpu(block->bb_level);
6267 ASSERT(level > 0); 6267 ASSERT(level > 0);
6268 xfs_check_block(block, mp, 1, ifp->if_broot_bytes); 6268 xfs_check_block(block, mp, 1, ifp->if_broot_bytes);
6269 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); 6269 pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes);
6270 bno = be64_to_cpu(*pp); 6270 bno = be64_to_cpu(*pp);
6271 6271
6272 ASSERT(bno != NULLDFSBNO); 6272 ASSERT(bno != NULLDFSBNO);
@@ -6426,7 +6426,7 @@ xfs_bmap_count_blocks(
6426 block = ifp->if_broot; 6426 block = ifp->if_broot;
6427 level = be16_to_cpu(block->bb_level); 6427 level = be16_to_cpu(block->bb_level);
6428 ASSERT(level > 0); 6428 ASSERT(level > 0);
6429 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); 6429 pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes);
6430 bno = be64_to_cpu(*pp); 6430 bno = be64_to_cpu(*pp);
6431 ASSERT(bno != NULLDFSBNO); 6431 ASSERT(bno != NULLDFSBNO);
6432 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); 6432 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount);