[XFS] Concurrent Multi-File Data Streams
[linux-2.6-block.git] / fs / xfs / xfs_bmap.c
index 498ad50d1f452807eba88e042f55341ea4498c3d..51ba689a45526d51709fb9d36846c4adc8cbfee0 100644 (file)
@@ -52,6 +52,7 @@
 #include "xfs_quota.h"
 #include "xfs_trans_space.h"
 #include "xfs_buf_item.h"
+#include "xfs_filestream.h"
 
 
 #ifdef DEBUG
@@ -130,7 +131,6 @@ STATIC int                          /* error */
 xfs_bmap_add_extent_hole_delay(
        xfs_inode_t             *ip,    /* incore inode pointer */
        xfs_extnum_t            idx,    /* extent number to update/insert */
-       xfs_btree_cur_t         *cur,   /* if null, not a btree */
        xfs_bmbt_irec_t         *new,   /* new data to add to file extents */
        int                     *logflagsp,/* inode logging flags */
        xfs_extdelta_t          *delta, /* Change made to incore extents */
@@ -185,16 +185,6 @@ xfs_bmap_btree_to_extents(
        int                     *logflagsp, /* inode logging flags */
        int                     whichfork); /* data or attr fork */
 
-#ifdef DEBUG
-/*
- * Check that the extents list for the inode ip is in the right order.
- */
-STATIC void
-xfs_bmap_check_extents(
-       xfs_inode_t             *ip,            /* incore inode pointer */
-       int                     whichfork);     /* data or attr fork */
-#endif
-
 /*
  * Called by xfs_bmapi to update file extent records and the btree
  * after removing space (or undoing a delayed allocation).
@@ -409,8 +399,6 @@ xfs_bmap_count_leaves(
 
 STATIC int
 xfs_bmap_disk_count_leaves(
-       xfs_ifork_t             *ifp,
-       xfs_mount_t             *mp,
        xfs_extnum_t            idx,
        xfs_bmbt_block_t        *block,
        int                     numrecs,
@@ -591,7 +579,7 @@ xfs_bmap_add_extent(
                if (cur)
                        ASSERT((cur->bc_private.b.flags &
                                XFS_BTCUR_BPRV_WASDEL) == 0);
-               if ((error = xfs_bmap_add_extent_hole_delay(ip, idx, cur, new,
+               if ((error = xfs_bmap_add_extent_hole_delay(ip, idx, new,
                                &logflags, delta, rsvd)))
                        goto done;
        }
@@ -684,7 +672,7 @@ xfs_bmap_add_extent(
                ASSERT(nblks <= da_old);
                if (nblks < da_old)
                        xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS,
-                               (int)(da_old - nblks), rsvd);
+                               (int64_t)(da_old - nblks), rsvd);
        }
        /*
         * Clear out the allocated field, done with it now in any case.
@@ -1209,7 +1197,7 @@ xfs_bmap_add_extent_delay_real(
                diff = (int)(temp + temp2 - STARTBLOCKVAL(PREV.br_startblock) -
                        (cur ? cur->bc_private.b.allocated : 0));
                if (diff > 0 &&
-                   xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS, -diff, rsvd)) {
+                   xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd)) {
                        /*
                         * Ick gross gag me with a spoon.
                         */
@@ -1220,7 +1208,7 @@ xfs_bmap_add_extent_delay_real(
                                        diff--;
                                        if (!diff ||
                                            !xfs_mod_incore_sb(ip->i_mount,
-                                                   XFS_SBS_FDBLOCKS, -diff, rsvd))
+                                                   XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd))
                                                break;
                                }
                                if (temp2) {
@@ -1228,7 +1216,7 @@ xfs_bmap_add_extent_delay_real(
                                        diff--;
                                        if (!diff ||
                                            !xfs_mod_incore_sb(ip->i_mount,
-                                                   XFS_SBS_FDBLOCKS, -diff, rsvd))
+                                                   XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd))
                                                break;
                                }
                        }
@@ -1852,7 +1840,6 @@ STATIC int                                /* error */
 xfs_bmap_add_extent_hole_delay(
        xfs_inode_t             *ip,    /* incore inode pointer */
        xfs_extnum_t            idx,    /* extent number to update/insert */
-       xfs_btree_cur_t         *cur,   /* if null, not a btree */
        xfs_bmbt_irec_t         *new,   /* new data to add to file extents */
        int                     *logflagsp, /* inode logging flags */
        xfs_extdelta_t          *delta, /* Change made to incore extents */
@@ -2015,7 +2002,7 @@ xfs_bmap_add_extent_hole_delay(
        if (oldlen != newlen) {
                ASSERT(oldlen > newlen);
                xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS,
-                       (int)(oldlen - newlen), rsvd);
+                       (int64_t)(oldlen - newlen), rsvd);
                /*
                 * Nothing to do for disk quota accounting here.
                 */
@@ -2619,12 +2606,10 @@ xfs_bmap_rtalloc(
        xfs_extlen_t    prod = 0;       /* product factor for allocators */
        xfs_extlen_t    ralen = 0;      /* realtime allocation length */
        xfs_extlen_t    align;          /* minimum allocation alignment */
-       xfs_rtblock_t   rtx;            /* realtime extent number */
        xfs_rtblock_t   rtb;
 
        mp = ap->ip->i_mount;
-       align = ap->ip->i_d.di_extsize ?
-               ap->ip->i_d.di_extsize : mp->m_sb.sb_rextsize;
+       align = xfs_get_extsz_hint(ap->ip);
        prod = align / mp->m_sb.sb_rextsize;
        error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
                                        align, 1, ap->eof, 0,
@@ -2658,6 +2643,8 @@ xfs_bmap_rtalloc(
         * pick an extent that will space things out in the rt area.
         */
        if (ap->eof && ap->off == 0) {
+               xfs_rtblock_t uninitialized_var(rtx); /* realtime extent no */
+
                error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx);
                if (error)
                        return error;
@@ -2729,9 +2716,7 @@ xfs_bmap_btalloc(
        int             error;
 
        mp = ap->ip->i_mount;
-       align = (ap->userdata && ap->ip->i_d.di_extsize &&
-               (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)) ?
-               ap->ip->i_d.di_extsize : 0;
+       align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0;
        if (unlikely(align)) {
                error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
                                                align, 0, ap->eof, 0, ap->conv,
@@ -2741,9 +2726,15 @@ xfs_bmap_btalloc(
        }
        nullfb = ap->firstblock == NULLFSBLOCK;
        fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, ap->firstblock);
-       if (nullfb)
-               ap->rval = XFS_INO_TO_FSB(mp, ap->ip->i_ino);
-       else
+       if (nullfb) {
+               if (ap->userdata && xfs_inode_is_filestream(ap->ip)) {
+                       ag = xfs_filestream_lookup_ag(ap->ip);
+                       ag = (ag != NULLAGNUMBER) ? ag : 0;
+                       ap->rval = XFS_AGB_TO_FSB(mp, ag, 0);
+               } else {
+                       ap->rval = XFS_INO_TO_FSB(mp, ap->ip->i_ino);
+               }
+       } else
                ap->rval = ap->firstblock;
 
        xfs_bmap_adjacent(ap);
@@ -2767,13 +2758,22 @@ xfs_bmap_btalloc(
        args.firstblock = ap->firstblock;
        blen = 0;
        if (nullfb) {
-               args.type = XFS_ALLOCTYPE_START_BNO;
+               if (ap->userdata && xfs_inode_is_filestream(ap->ip))
+                       args.type = XFS_ALLOCTYPE_NEAR_BNO;
+               else
+                       args.type = XFS_ALLOCTYPE_START_BNO;
                args.total = ap->total;
+
                /*
-                * Find the longest available space.
-                * We're going to try for the whole allocation at once.
+                * Search for an allocation group with a single extent
+                * large enough for the request.
+                *
+                * If one isn't found, then adjust the minimum allocation
+                * size to the largest space found.
                 */
                startag = ag = XFS_FSB_TO_AGNO(mp, args.fsbno);
+               if (startag == NULLAGNUMBER)
+                       startag = ag = 0;
                notinit = 0;
                down_read(&mp->m_peraglock);
                while (blen < ap->alen) {
@@ -2799,6 +2799,35 @@ xfs_bmap_btalloc(
                                        blen = longest;
                        } else
                                notinit = 1;
+
+                       if (xfs_inode_is_filestream(ap->ip)) {
+                               if (blen >= ap->alen)
+                                       break;
+
+                               if (ap->userdata) {
+                                       /*
+                                        * If startag is an invalid AG, we've
+                                        * come here once before and
+                                        * xfs_filestream_new_ag picked the
+                                        * best currently available.
+                                        *
+                                        * Don't continue looping, since we
+                                        * could loop forever.
+                                        */
+                                       if (startag == NULLAGNUMBER)
+                                               break;
+
+                                       error = xfs_filestream_new_ag(ap, &ag);
+                                       if (error) {
+                                               up_read(&mp->m_peraglock);
+                                               return error;
+                                       }
+
+                                       /* loop again to set 'blen'*/
+                                       startag = NULLAGNUMBER;
+                                       continue;
+                               }
+                       }
                        if (++ag == mp->m_sb.sb_agcount)
                                ag = 0;
                        if (ag == startag)
@@ -2823,17 +2852,27 @@ xfs_bmap_btalloc(
                 */
                else
                        args.minlen = ap->alen;
+
+               /*
+                * set the failure fallback case to look in the selected
+                * AG as the stream may have moved.
+                */
+               if (xfs_inode_is_filestream(ap->ip))
+                       ap->rval = args.fsbno = XFS_AGB_TO_FSB(mp, ag, 0);
        } else if (ap->low) {
-               args.type = XFS_ALLOCTYPE_START_BNO;
+               if (xfs_inode_is_filestream(ap->ip))
+                       args.type = XFS_ALLOCTYPE_FIRST_AG;
+               else
+                       args.type = XFS_ALLOCTYPE_START_BNO;
                args.total = args.minlen = ap->minlen;
        } else {
                args.type = XFS_ALLOCTYPE_NEAR_BNO;
                args.total = ap->total;
                args.minlen = ap->minlen;
        }
-       if (unlikely(ap->userdata && ap->ip->i_d.di_extsize &&
-                   (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE))) {
-               args.prod = ap->ip->i_d.di_extsize;
+       /* apply extent size hints if obtained earlier */
+       if (unlikely(align)) {
+               args.prod = align;
                if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod)))
                        args.mod = (xfs_extlen_t)(args.prod - args.mod);
        } else if (mp->m_sb.sb_blocksize >= NBPP) {
@@ -3359,7 +3398,7 @@ xfs_bmap_del_extent(
         */
        ASSERT(da_old >= da_new);
        if (da_old > da_new)
-               xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, (int)(da_old - da_new),
+               xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, (int64_t)(da_old - da_new),
                        rsvd);
        if (delta) {
                /* DELTA: report the original extent. */
@@ -3543,6 +3582,7 @@ xfs_bmap_forkoff_reset(
        if (whichfork == XFS_ATTR_FORK &&
            (ip->i_d.di_format != XFS_DINODE_FMT_DEV) &&
            (ip->i_d.di_format != XFS_DINODE_FMT_UUID) &&
+           (ip->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
            ((mp->m_attroffset >> 3) > ip->i_d.di_forkoff)) {
                ip->i_d.di_forkoff = mp->m_attroffset >> 3;
                ip->i_df.if_ext_max = XFS_IFORK_DSIZE(ip) /
@@ -4079,9 +4119,9 @@ xfs_bmap_add_attrfork(
                } else
                        XFS_SB_UNLOCK(mp, s);
        }
-       if ((error = xfs_bmap_finish(&tp, &flist, firstblock, &committed)))
+       if ((error = xfs_bmap_finish(&tp, &flist, &committed)))
                goto error2;
-       error = xfs_trans_commit(tp, XFS_TRANS_PERM_LOG_RES, NULL);
+       error = xfs_trans_commit(tp, XFS_TRANS_PERM_LOG_RES);
        ASSERT(ip->i_df.if_ext_max ==
               XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));
        return error;
@@ -4212,7 +4252,6 @@ int                                               /* error */
 xfs_bmap_finish(
        xfs_trans_t             **tp,           /* transaction pointer addr */
        xfs_bmap_free_t         *flist,         /* i/o: list extents to free */
-       xfs_fsblock_t           firstblock,     /* controlled ag for allocs */
        int                     *committed)     /* xact committed or not */
 {
        xfs_efd_log_item_t      *efd;           /* extent free data */
@@ -4238,7 +4277,7 @@ xfs_bmap_finish(
        logres = ntp->t_log_res;
        logcount = ntp->t_log_count;
        ntp = xfs_trans_dup(*tp);
-       error = xfs_trans_commit(*tp, 0, NULL);
+       error = xfs_trans_commit(*tp, 0);
        *tp = ntp;
        *committed = 1;
        /*
@@ -4458,8 +4497,11 @@ xfs_bmap_one_block(
        xfs_bmbt_irec_t s;              /* internal version of extent */
 
 #ifndef DEBUG
-       if (whichfork == XFS_DATA_FORK)
-               return ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize;
+       if (whichfork == XFS_DATA_FORK) {
+               return ((ip->i_d.di_mode & S_IFMT) == S_IFREG) ?
+                       (ip->i_size == ip->i_mount->m_sb.sb_blocksize) :
+                       (ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize);
+       }
 #endif /* !DEBUG */
        if (XFS_IFORK_NEXTENTS(ip, whichfork) != 1)
                return 0;
@@ -4471,7 +4513,7 @@ xfs_bmap_one_block(
        xfs_bmbt_get_all(ep, &s);
        rval = s.br_startoff == 0 && s.br_blockcount == 1;
        if (rval && whichfork == XFS_DATA_FORK)
-               ASSERT(ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize);
+               ASSERT(ip->i_size == ip->i_mount->m_sb.sb_blocksize);
        return rval;
 }
 
@@ -4533,8 +4575,7 @@ xfs_bmap_read_extents(
                        error0);
                if (level == 0)
                        break;
-               pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block,
-                       1, mp->m_bmap_dmxr[1]);
+               pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
                bno = be64_to_cpu(*pp);
                XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0);
                xfs_trans_brelse(tp, bp);
@@ -4577,8 +4618,7 @@ xfs_bmap_read_extents(
                /*
                 * Copy records into the extent records.
                 */
-               frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt,
-                       block, 1, mp->m_bmap_dmxr[0]);
+               frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1);
                start = i;
                for (j = 0; j < num_recs; j++, i++, frp++) {
                        trp = xfs_iext_get_ext(ifp, i);
@@ -4881,12 +4921,7 @@ xfs_bmapi(
                                xfs_extlen_t    extsz;
 
                                /* Figure out the extent size, adjust alen */
-                               if (rt) {
-                                       if (!(extsz = ip->i_d.di_extsize))
-                                               extsz = mp->m_sb.sb_rextsize;
-                               } else {
-                                       extsz = ip->i_d.di_extsize;
-                               }
+                               extsz = xfs_get_extsz_hint(ip);
                                if (extsz) {
                                        error = xfs_bmap_extsize_align(mp,
                                                        &got, &prev, extsz,
@@ -4929,28 +4964,28 @@ xfs_bmapi(
                                if (rt) {
                                        error = xfs_mod_incore_sb(mp,
                                                        XFS_SBS_FREXTENTS,
-                                                       -(extsz), (flags &
+                                                       -((int64_t)extsz), (flags &
                                                        XFS_BMAPI_RSVBLOCKS));
                                } else {
                                        error = xfs_mod_incore_sb(mp,
                                                        XFS_SBS_FDBLOCKS,
-                                                       -(alen), (flags &
+                                                       -((int64_t)alen), (flags &
                                                        XFS_BMAPI_RSVBLOCKS));
                                }
                                if (!error) {
                                        error = xfs_mod_incore_sb(mp,
                                                        XFS_SBS_FDBLOCKS,
-                                                       -(indlen), (flags &
+                                                       -((int64_t)indlen), (flags &
                                                        XFS_BMAPI_RSVBLOCKS));
                                        if (error && rt)
                                                xfs_mod_incore_sb(mp,
                                                        XFS_SBS_FREXTENTS,
-                                                       extsz, (flags &
+                                                       (int64_t)extsz, (flags &
                                                        XFS_BMAPI_RSVBLOCKS));
                                        else if (error)
                                                xfs_mod_incore_sb(mp,
                                                        XFS_SBS_FDBLOCKS,
-                                                       alen, (flags &
+                                                       (int64_t)alen, (flags &
                                                        XFS_BMAPI_RSVBLOCKS));
                                }
 
@@ -5232,10 +5267,10 @@ xfs_bmapi(
                 * Else go on to the next record.
                 */
                ep = xfs_iext_get_ext(ifp, ++lastx);
-               if (lastx >= nextents) {
+               prev = got;
+               if (lastx >= nextents)
                        eof = 1;
-                       prev = got;
-               } else
+               else
                        xfs_bmbt_get_all(ep, &got);
        }
        ifp->if_lastex = lastx;
@@ -5616,13 +5651,13 @@ xfs_bunmapi(
                                rtexts = XFS_FSB_TO_B(mp, del.br_blockcount);
                                do_div(rtexts, mp->m_sb.sb_rextsize);
                                xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS,
-                                               (int)rtexts, rsvd);
+                                               (int64_t)rtexts, rsvd);
                                (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp,
                                        NULL, ip, -((long)del.br_blockcount), 0,
                                        XFS_QMOPT_RES_RTBLKS);
                        } else {
                                xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS,
-                                               (int)del.br_blockcount, rsvd);
+                                               (int64_t)del.br_blockcount, rsvd);
                                (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp,
                                        NULL, ip, -((long)del.br_blockcount), 0,
                                        XFS_QMOPT_RES_REGBLKS);
@@ -5826,14 +5861,13 @@ xfs_getbmap(
                   ip->i_d.di_format != XFS_DINODE_FMT_LOCAL)
                return XFS_ERROR(EINVAL);
        if (whichfork == XFS_DATA_FORK) {
-               if ((ip->i_d.di_extsize && (ip->i_d.di_flags &
-                               (XFS_DIFLAG_REALTIME|XFS_DIFLAG_EXTSIZE))) ||
+               if (xfs_get_extsz_hint(ip) ||
                    ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){
                        prealloced = 1;
                        fixlen = XFS_MAXIOFFSET(mp);
                } else {
                        prealloced = 0;
-                       fixlen = ip->i_d.di_size;
+                       fixlen = ip->i_size;
                }
        } else {
                prealloced = 0;
@@ -5857,7 +5891,8 @@ xfs_getbmap(
 
        xfs_ilock(ip, XFS_IOLOCK_SHARED);
 
-       if (whichfork == XFS_DATA_FORK && ip->i_delayed_blks) {
+       if (whichfork == XFS_DATA_FORK &&
+               (ip->i_delayed_blks || ip->i_size > ip->i_d.di_size)) {
                /* xfs_fsize_t last_byte = xfs_file_last_byte(ip); */
                error = bhv_vop_flush_pages(vp, (xfs_off_t)0, -1, 0, FI_REMAPF);
        }
@@ -6048,32 +6083,6 @@ xfs_bmap_eof(
 }
 
 #ifdef DEBUG
-/*
- * Check that the extents list for the inode ip is in the right order.
- */
-STATIC void
-xfs_bmap_check_extents(
-       xfs_inode_t             *ip,            /* incore inode pointer */
-       int                     whichfork)      /* data or attr fork */
-{
-       xfs_bmbt_rec_t          *ep;            /* current extent entry */
-       xfs_extnum_t            idx;            /* extent record index */
-       xfs_ifork_t             *ifp;           /* inode fork pointer */
-       xfs_extnum_t            nextents;       /* number of extents in list */
-       xfs_bmbt_rec_t          *nextp;         /* next extent entry */
-
-       ifp = XFS_IFORK_PTR(ip, whichfork);
-       ASSERT(ifp->if_flags & XFS_IFEXTENTS);
-       nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
-       ep = xfs_iext_get_ext(ifp, 0);
-       for (idx = 0; idx < nextents - 1; idx++) {
-               nextp = xfs_iext_get_ext(ifp, idx + 1);
-               xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)ep,
-                       (void *)(nextp));
-               ep = nextp;
-       }
-}
-
 STATIC
 xfs_buf_t *
 xfs_bmap_get_bp(
@@ -6156,8 +6165,7 @@ xfs_check_block(
                if (root) {
                        keyp = XFS_BMAP_BROOT_KEY_ADDR(block, i, sz);
                } else {
-                       keyp = XFS_BTREE_KEY_ADDR(mp->m_sb.sb_blocksize,
-                               xfs_bmbt, block, i, dmxr);
+                       keyp = XFS_BTREE_KEY_ADDR(xfs_bmbt, block, i);
                }
 
                if (prevp) {
@@ -6172,15 +6180,14 @@ xfs_check_block(
                if (root) {
                        pp = XFS_BMAP_BROOT_PTR_ADDR(block, i, sz);
                } else {
-                       pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize,
-                               xfs_bmbt, block, i, dmxr);
+                       pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, i, dmxr);
                }
                for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) {
                        if (root) {
                                thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz);
                        } else {
-                               thispa = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize,
-                                       xfs_bmbt, block, j, dmxr);
+                               thispa = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, j,
+                                                           dmxr);
                        }
                        if (*thispa == *pp) {
                                cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld",
@@ -6267,8 +6274,7 @@ xfs_bmap_check_leaf_extents(
                 */
 
                xfs_check_block(block, mp, 0, 0);
-               pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block,
-                       1, mp->m_bmap_dmxr[1]);
+               pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
                bno = be64_to_cpu(*pp);
                XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0);
                if (bp_release) {
@@ -6305,11 +6311,9 @@ xfs_bmap_check_leaf_extents(
                 * conform with the first entry in this one.
                 */
 
-               ep = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt,
-                       block, 1, mp->m_bmap_dmxr[0]);
+               ep = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1);
                for (j = 1; j < num_recs; j++) {
-                       nextp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt,
-                               block, j + 1, mp->m_bmap_dmxr[0]);
+                       nextp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, j + 1);
                        if (lastp) {
                                xfs_btree_check_rec(XFS_BTNUM_BMAP,
                                        (void *)lastp, (void *)ep);
@@ -6454,8 +6458,7 @@ xfs_bmap_count_tree(
                }
 
                /* Dive to the next level */
-               pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize,
-                       xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
+               pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
                bno = be64_to_cpu(*pp);
                if (unlikely((error =
                     xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) {
@@ -6470,8 +6473,8 @@ xfs_bmap_count_tree(
                for (;;) {
                        nextbno = be64_to_cpu(block->bb_rightsib);
                        numrecs = be16_to_cpu(block->bb_numrecs);
-                       if (unlikely(xfs_bmap_disk_count_leaves(ifp, mp,
-                                       0, block, numrecs, count) < 0)) {
+                       if (unlikely(xfs_bmap_disk_count_leaves(0,
+                                       block, numrecs, count) < 0)) {
                                xfs_trans_brelse(tp, bp);
                                XFS_ERROR_REPORT("xfs_bmap_count_tree(2)",
                                                 XFS_ERRLEVEL_LOW, mp);
@@ -6517,8 +6520,6 @@ xfs_bmap_count_leaves(
  */
 int
 xfs_bmap_disk_count_leaves(
-       xfs_ifork_t             *ifp,
-       xfs_mount_t             *mp,
        xfs_extnum_t            idx,
        xfs_bmbt_block_t        *block,
        int                     numrecs,
@@ -6528,8 +6529,7 @@ xfs_bmap_disk_count_leaves(
        xfs_bmbt_rec_t  *frp;
 
        for (b = 1; b <= numrecs; b++) {
-               frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize,
-                       xfs_bmbt, block, idx + b, mp->m_bmap_dmxr[0]);
+               frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, idx + b);
                *count += xfs_bmbt_disk_get_blockcount(frp);
        }
        return 0;