]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/xfs/xfs_dir2_leaf.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi...
[karo-tx-linux.git] / fs / xfs / xfs_dir2_leaf.c
index d36e97df1187ebc866e9c3885d6f848ca3373c5a..fb0aad4440c1a5cf8044110c95cc78cdb9d709ca 100644 (file)
  */
 static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, struct xfs_buf **lbpp,
                                    int *indexp, struct xfs_buf **dbpp);
-static void xfs_dir3_leaf_log_bests(struct xfs_trans *tp, struct xfs_buf *bp,
-                                   int first, int last);
-static void xfs_dir3_leaf_log_tail(struct xfs_trans *tp, struct xfs_buf *bp);
+static void xfs_dir3_leaf_log_bests(struct xfs_da_args *args,
+                                   struct xfs_buf *bp, int first, int last);
+static void xfs_dir3_leaf_log_tail(struct xfs_da_args *args,
+                                  struct xfs_buf *bp);
 
 /*
  * Check the internal consistency of a leaf1 block.
@@ -92,6 +93,7 @@ xfs_dir3_leaf_check_int(
        int                     i;
        const struct xfs_dir_ops *ops;
        struct xfs_dir3_icleaf_hdr leafhdr;
+       struct xfs_da_geometry  *geo = mp->m_dir_geo;
 
        /*
         * we can be passed a null dp here from a verifier, so we need to go the
@@ -105,14 +107,14 @@ xfs_dir3_leaf_check_int(
        }
 
        ents = ops->leaf_ents_p(leaf);
-       ltp = xfs_dir2_leaf_tail_p(mp, leaf);
+       ltp = xfs_dir2_leaf_tail_p(geo, leaf);
 
        /*
         * XXX (dgc): This value is not restrictive enough.
         * Should factor in the size of the bests table as well.
         * We can deduce a value for that from di_size.
         */
-       if (hdr->count > ops->leaf_max_ents(mp))
+       if (hdr->count > ops->leaf_max_ents(geo))
                return false;
 
        /* Leaves and bests don't overlap in leaf format. */
@@ -323,7 +325,7 @@ xfs_dir3_leaf_init(
        if (type == XFS_DIR2_LEAF1_MAGIC) {
                struct xfs_dir2_leaf_tail *ltp;
 
-               ltp = xfs_dir2_leaf_tail_p(mp, leaf);
+               ltp = xfs_dir2_leaf_tail_p(mp->m_dir_geo, leaf);
                ltp->bestcount = 0;
                bp->b_ops = &xfs_dir3_leaf1_buf_ops;
                xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_LEAF1_BUF);
@@ -347,18 +349,18 @@ xfs_dir3_leaf_get_buf(
        int                     error;
 
        ASSERT(magic == XFS_DIR2_LEAF1_MAGIC || magic == XFS_DIR2_LEAFN_MAGIC);
-       ASSERT(bno >= XFS_DIR2_LEAF_FIRSTDB(mp) &&
-              bno < XFS_DIR2_FREE_FIRSTDB(mp));
+       ASSERT(bno >= xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET) &&
+              bno < xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET));
 
-       error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, bno), -1, &bp,
-                              XFS_DATA_FORK);
+       error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, bno),
+                              -1, &bp, XFS_DATA_FORK);
        if (error)
                return error;
 
        xfs_dir3_leaf_init(mp, tp, bp, dp->i_ino, magic);
-       xfs_dir3_leaf_log_header(tp, dp, bp);
+       xfs_dir3_leaf_log_header(args, bp);
        if (magic == XFS_DIR2_LEAF1_MAGIC)
-               xfs_dir3_leaf_log_tail(tp, bp);
+               xfs_dir3_leaf_log_tail(args, bp);
        *bpp = bp;
        return 0;
 }
@@ -403,8 +405,8 @@ xfs_dir2_block_to_leaf(
        if ((error = xfs_da_grow_inode(args, &blkno))) {
                return error;
        }
-       ldb = xfs_dir2_da_to_db(mp, blkno);
-       ASSERT(ldb == XFS_DIR2_LEAF_FIRSTDB(mp));
+       ldb = xfs_dir2_da_to_db(args->geo, blkno);
+       ASSERT(ldb == xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET));
        /*
         * Initialize the leaf block, get a buffer for it.
         */
@@ -415,7 +417,7 @@ xfs_dir2_block_to_leaf(
        leaf = lbp->b_addr;
        hdr = dbp->b_addr;
        xfs_dir3_data_check(dp, dbp);
-       btp = xfs_dir2_block_tail_p(mp, hdr);
+       btp = xfs_dir2_block_tail_p(args->geo, hdr);
        blp = xfs_dir2_block_leaf_p(btp);
        bf = dp->d_ops->data_bestfree_p(hdr);
        ents = dp->d_ops->leaf_ents_p(leaf);
@@ -427,23 +429,23 @@ xfs_dir2_block_to_leaf(
        leafhdr.count = be32_to_cpu(btp->count);
        leafhdr.stale = be32_to_cpu(btp->stale);
        dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
-       xfs_dir3_leaf_log_header(tp, dp, lbp);
+       xfs_dir3_leaf_log_header(args, lbp);
 
        /*
         * Could compact these but I think we always do the conversion
         * after squeezing out stale entries.
         */
        memcpy(ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t));
-       xfs_dir3_leaf_log_ents(tp, dp, lbp, 0, leafhdr.count - 1);
+       xfs_dir3_leaf_log_ents(args, lbp, 0, leafhdr.count - 1);
        needscan = 0;
        needlog = 1;
        /*
         * Make the space formerly occupied by the leaf entries and block
         * tail be free.
         */
-       xfs_dir2_data_make_free(tp, dp, dbp,
+       xfs_dir2_data_make_free(args, dbp,
                (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr),
-               (xfs_dir2_data_aoff_t)((char *)hdr + mp->m_dirblksize -
+               (xfs_dir2_data_aoff_t)((char *)hdr + args->geo->blksize -
                                       (char *)blp),
                &needlog, &needscan);
        /*
@@ -461,7 +463,7 @@ xfs_dir2_block_to_leaf(
        /*
         * Set up leaf tail and bests table.
         */
-       ltp = xfs_dir2_leaf_tail_p(mp, leaf);
+       ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
        ltp->bestcount = cpu_to_be32(1);
        bestsp = xfs_dir2_leaf_bests_p(ltp);
        bestsp[0] =  bf[0].length;
@@ -469,10 +471,10 @@ xfs_dir2_block_to_leaf(
         * Log the data header and leaf bests table.
         */
        if (needlog)
-               xfs_dir2_data_log_header(tp, dp, dbp);
+               xfs_dir2_data_log_header(args, dbp);
        xfs_dir3_leaf_check(dp, lbp);
        xfs_dir3_data_check(dp, dbp);
-       xfs_dir3_leaf_log_bests(tp, lbp, 0, 0);
+       xfs_dir3_leaf_log_bests(args, lbp, 0, 0);
        return 0;
 }
 
@@ -641,7 +643,7 @@ xfs_dir2_leaf_addname(
        tp = args->trans;
        mp = dp->i_mount;
 
-       error = xfs_dir3_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp);
+       error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp);
        if (error)
                return error;
 
@@ -653,7 +655,7 @@ xfs_dir2_leaf_addname(
         */
        index = xfs_dir2_leaf_search_hash(args, lbp);
        leaf = lbp->b_addr;
-       ltp = xfs_dir2_leaf_tail_p(mp, leaf);
+       ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
        ents = dp->d_ops->leaf_ents_p(leaf);
        dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
        bestsp = xfs_dir2_leaf_bests_p(ltp);
@@ -670,7 +672,7 @@ xfs_dir2_leaf_addname(
             index++, lep++) {
                if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
                        continue;
-               i = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
+               i = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
                ASSERT(i < be32_to_cpu(ltp->bestcount));
                ASSERT(bestsp[i] != cpu_to_be16(NULLDATAOFF));
                if (be16_to_cpu(bestsp[i]) >= length) {
@@ -810,14 +812,15 @@ xfs_dir2_leaf_addname(
                        memmove(&bestsp[0], &bestsp[1],
                                be32_to_cpu(ltp->bestcount) * sizeof(bestsp[0]));
                        be32_add_cpu(&ltp->bestcount, 1);
-                       xfs_dir3_leaf_log_tail(tp, lbp);
-                       xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
+                       xfs_dir3_leaf_log_tail(args, lbp);
+                       xfs_dir3_leaf_log_bests(args, lbp, 0,
+                                               be32_to_cpu(ltp->bestcount) - 1);
                }
                /*
                 * If we're filling in a previously empty block just log it.
                 */
                else
-                       xfs_dir3_leaf_log_bests(tp, lbp, use_block, use_block);
+                       xfs_dir3_leaf_log_bests(args, lbp, use_block, use_block);
                hdr = dbp->b_addr;
                bf = dp->d_ops->data_bestfree_p(hdr);
                bestsp[use_block] = bf[0].length;
@@ -828,8 +831,8 @@ xfs_dir2_leaf_addname(
                 * Just read that one in.
                 */
                error = xfs_dir3_data_read(tp, dp,
-                                          xfs_dir2_db_to_da(mp, use_block),
-                                          -1, &dbp);
+                                  xfs_dir2_db_to_da(args->geo, use_block),
+                                  -1, &dbp);
                if (error) {
                        xfs_trans_brelse(tp, lbp);
                        return error;
@@ -848,7 +851,7 @@ xfs_dir2_leaf_addname(
        /*
         * Mark the initial part of our freespace in use for the new entry.
         */
-       xfs_dir2_data_use_free(tp, dp, dbp, dup,
+       xfs_dir2_data_use_free(args, dbp, dup,
                (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
                &needlog, &needscan);
        /*
@@ -870,8 +873,8 @@ xfs_dir2_leaf_addname(
         * Need to log the data block's header.
         */
        if (needlog)
-               xfs_dir2_data_log_header(tp, dp, dbp);
-       xfs_dir2_data_log_entry(tp, dp, dbp, dep);
+               xfs_dir2_data_log_header(args, dbp);
+       xfs_dir2_data_log_entry(args, dbp, dep);
        /*
         * If the bests table needs to be changed, do it.
         * Log the change unless we've already done that.
@@ -879,7 +882,7 @@ xfs_dir2_leaf_addname(
        if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(bf[0].length)) {
                bestsp[use_block] = bf[0].length;
                if (!grown)
-                       xfs_dir3_leaf_log_bests(tp, lbp, use_block, use_block);
+                       xfs_dir3_leaf_log_bests(args, lbp, use_block, use_block);
        }
 
        lep = xfs_dir3_leaf_find_entry(&leafhdr, ents, index, compact, lowstale,
@@ -889,14 +892,15 @@ xfs_dir2_leaf_addname(
         * Fill in the new leaf entry.
         */
        lep->hashval = cpu_to_be32(args->hashval);
-       lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, use_block,
+       lep->address = cpu_to_be32(
+                               xfs_dir2_db_off_to_dataptr(args->geo, use_block,
                                be16_to_cpu(*tagp)));
        /*
         * Log the leaf fields and give up the buffers.
         */
        dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
-       xfs_dir3_leaf_log_header(tp, dp, lbp);
-       xfs_dir3_leaf_log_ents(tp, dp, lbp, lfloglow, lfloghigh);
+       xfs_dir3_leaf_log_header(args, lbp);
+       xfs_dir3_leaf_log_ents(args, lbp, lfloglow, lfloghigh);
        xfs_dir3_leaf_check(dp, lbp);
        xfs_dir3_data_check(dp, dbp);
        return 0;
@@ -948,9 +952,9 @@ xfs_dir3_leaf_compact(
        leafhdr->stale = 0;
 
        dp->d_ops->leaf_hdr_to_disk(leaf, leafhdr);
-       xfs_dir3_leaf_log_header(args->trans, dp, bp);
+       xfs_dir3_leaf_log_header(args, bp);
        if (loglow != -1)
-               xfs_dir3_leaf_log_ents(args->trans, dp, bp, loglow, to - 1);
+               xfs_dir3_leaf_log_ents(args, bp, loglow, to - 1);
 }
 
 /*
@@ -1052,7 +1056,7 @@ xfs_dir3_leaf_compact_x1(
  */
 static void
 xfs_dir3_leaf_log_bests(
-       xfs_trans_t             *tp,            /* transaction pointer */
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp,            /* leaf buffer */
        int                     first,          /* first entry to log */
        int                     last)           /* last entry to log */
@@ -1065,10 +1069,11 @@ xfs_dir3_leaf_log_bests(
        ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
               leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC));
 
-       ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf);
+       ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
        firstb = xfs_dir2_leaf_bests_p(ltp) + first;
        lastb = xfs_dir2_leaf_bests_p(ltp) + last;
-       xfs_trans_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf),
+       xfs_trans_log_buf(args->trans, bp,
+               (uint)((char *)firstb - (char *)leaf),
                (uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1));
 }
 
@@ -1077,8 +1082,7 @@ xfs_dir3_leaf_log_bests(
  */
 void
 xfs_dir3_leaf_log_ents(
-       struct xfs_trans        *tp,
-       struct xfs_inode        *dp,
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp,
        int                     first,
        int                     last)
@@ -1093,10 +1097,11 @@ xfs_dir3_leaf_log_ents(
               leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
               leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC));
 
-       ents = dp->d_ops->leaf_ents_p(leaf);
+       ents = args->dp->d_ops->leaf_ents_p(leaf);
        firstlep = &ents[first];
        lastlep = &ents[last];
-       xfs_trans_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf),
+       xfs_trans_log_buf(args->trans, bp,
+               (uint)((char *)firstlep - (char *)leaf),
                (uint)((char *)lastlep - (char *)leaf + sizeof(*lastlep) - 1));
 }
 
@@ -1105,8 +1110,7 @@ xfs_dir3_leaf_log_ents(
  */
 void
 xfs_dir3_leaf_log_header(
-       struct xfs_trans        *tp,
-       struct xfs_inode        *dp,
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp)
 {
        struct xfs_dir2_leaf    *leaf = bp->b_addr;
@@ -1116,8 +1120,9 @@ xfs_dir3_leaf_log_header(
               leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
               leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC));
 
-       xfs_trans_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf),
-                         dp->d_ops->leaf_hdr_size - 1);
+       xfs_trans_log_buf(args->trans, bp,
+                         (uint)((char *)&leaf->hdr - (char *)leaf),
+                         args->dp->d_ops->leaf_hdr_size - 1);
 }
 
 /*
@@ -1125,21 +1130,20 @@ xfs_dir3_leaf_log_header(
  */
 STATIC void
 xfs_dir3_leaf_log_tail(
-       struct xfs_trans        *tp,
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp)
 {
        struct xfs_dir2_leaf    *leaf = bp->b_addr;
        xfs_dir2_leaf_tail_t    *ltp;           /* leaf tail structure */
-       struct xfs_mount        *mp = tp->t_mountp;
 
        ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
               leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) ||
               leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
               leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC));
 
-       ltp = xfs_dir2_leaf_tail_p(mp, leaf);
-       xfs_trans_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
-               (uint)(mp->m_dirblksize - 1));
+       ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
+       xfs_trans_log_buf(args->trans, bp, (uint)((char *)ltp - (char *)leaf),
+               (uint)(args->geo->blksize - 1));
 }
 
 /*
@@ -1185,7 +1189,7 @@ xfs_dir2_leaf_lookup(
         */
        dep = (xfs_dir2_data_entry_t *)
              ((char *)dbp->b_addr +
-              xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
+              xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
        /*
         * Return the found inode number & CI name if appropriate
         */
@@ -1231,7 +1235,7 @@ xfs_dir2_leaf_lookup_int(
        tp = args->trans;
        mp = dp->i_mount;
 
-       error = xfs_dir3_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp);
+       error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp);
        if (error)
                return error;
 
@@ -1260,7 +1264,8 @@ xfs_dir2_leaf_lookup_int(
                /*
                 * Get the new data block number.
                 */
-               newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
+               newdb = xfs_dir2_dataptr_to_db(args->geo,
+                                              be32_to_cpu(lep->address));
                /*
                 * If it's not the same as the old data block number,
                 * need to pitch the old one and read the new one.
@@ -1269,8 +1274,8 @@ xfs_dir2_leaf_lookup_int(
                        if (dbp)
                                xfs_trans_brelse(tp, dbp);
                        error = xfs_dir3_data_read(tp, dp,
-                                                  xfs_dir2_db_to_da(mp, newdb),
-                                                  -1, &dbp);
+                                          xfs_dir2_db_to_da(args->geo, newdb),
+                                          -1, &dbp);
                        if (error) {
                                xfs_trans_brelse(tp, lbp);
                                return error;
@@ -1281,7 +1286,8 @@ xfs_dir2_leaf_lookup_int(
                 * Point to the data entry.
                 */
                dep = (xfs_dir2_data_entry_t *)((char *)dbp->b_addr +
-                       xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
+                       xfs_dir2_dataptr_to_off(args->geo,
+                                               be32_to_cpu(lep->address)));
                /*
                 * Compare name and if it's an exact match, return the index
                 * and buffer. If it's the first case-insensitive match, store
@@ -1310,8 +1316,8 @@ xfs_dir2_leaf_lookup_int(
                if (cidb != curdb) {
                        xfs_trans_brelse(tp, dbp);
                        error = xfs_dir3_data_read(tp, dp,
-                                                  xfs_dir2_db_to_da(mp, cidb),
-                                                  -1, &dbp);
+                                          xfs_dir2_db_to_da(args->geo, cidb),
+                                          -1, &dbp);
                        if (error) {
                                xfs_trans_brelse(tp, lbp);
                                return error;
@@ -1380,18 +1386,18 @@ xfs_dir2_leaf_removename(
         * Point to the leaf entry, use that to point to the data entry.
         */
        lep = &ents[index];
-       db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
-       dep = (xfs_dir2_data_entry_t *)
-             ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
+       db = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
+       dep = (xfs_dir2_data_entry_t *)((char *)hdr +
+               xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
        needscan = needlog = 0;
        oldbest = be16_to_cpu(bf[0].length);
-       ltp = xfs_dir2_leaf_tail_p(mp, leaf);
+       ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
        bestsp = xfs_dir2_leaf_bests_p(ltp);
        ASSERT(be16_to_cpu(bestsp[db]) == oldbest);
        /*
         * Mark the former data entry unused.
         */
-       xfs_dir2_data_make_free(tp, dp, dbp,
+       xfs_dir2_data_make_free(args, dbp,
                (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
                dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
        /*
@@ -1399,10 +1405,10 @@ xfs_dir2_leaf_removename(
         */
        leafhdr.stale++;
        dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
-       xfs_dir3_leaf_log_header(tp, dp, lbp);
+       xfs_dir3_leaf_log_header(args, lbp);
 
        lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
-       xfs_dir3_leaf_log_ents(tp, dp, lbp, index, index);
+       xfs_dir3_leaf_log_ents(args, lbp, index, index);
 
        /*
         * Scan the freespace in the data block again if necessary,
@@ -1411,22 +1417,22 @@ xfs_dir2_leaf_removename(
        if (needscan)
                xfs_dir2_data_freescan(dp, hdr, &needlog);
        if (needlog)
-               xfs_dir2_data_log_header(tp, dp, dbp);
+               xfs_dir2_data_log_header(args, dbp);
        /*
         * If the longest freespace in the data block has changed,
         * put the new value in the bests table and log that.
         */
        if (be16_to_cpu(bf[0].length) != oldbest) {
                bestsp[db] = bf[0].length;
-               xfs_dir3_leaf_log_bests(tp, lbp, db, db);
+               xfs_dir3_leaf_log_bests(args, lbp, db, db);
        }
        xfs_dir3_data_check(dp, dbp);
        /*
         * If the data block is now empty then get rid of the data block.
         */
        if (be16_to_cpu(bf[0].length) ==
-                       mp->m_dirblksize - dp->d_ops->data_entry_offset) {
-               ASSERT(db != mp->m_dirdatablk);
+                       args->geo->blksize - dp->d_ops->data_entry_offset) {
+               ASSERT(db != args->geo->datablk);
                if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
                        /*
                         * Nope, can't get rid of it because it caused
@@ -1459,15 +1465,16 @@ xfs_dir2_leaf_removename(
                        memmove(&bestsp[db - i], bestsp,
                                (be32_to_cpu(ltp->bestcount) - (db - i)) * sizeof(*bestsp));
                        be32_add_cpu(&ltp->bestcount, -(db - i));
-                       xfs_dir3_leaf_log_tail(tp, lbp);
-                       xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
+                       xfs_dir3_leaf_log_tail(args, lbp);
+                       xfs_dir3_leaf_log_bests(args, lbp, 0,
+                                               be32_to_cpu(ltp->bestcount) - 1);
                } else
                        bestsp[db] = cpu_to_be16(NULLDATAOFF);
        }
        /*
         * If the data block was not the first one, drop it.
         */
-       else if (db != mp->m_dirdatablk)
+       else if (db != args->geo->datablk)
                dbp = NULL;
 
        xfs_dir3_leaf_check(dp, lbp);
@@ -1515,7 +1522,7 @@ xfs_dir2_leaf_replace(
         */
        dep = (xfs_dir2_data_entry_t *)
              ((char *)dbp->b_addr +
-              xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
+              xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
        ASSERT(args->inumber != be64_to_cpu(dep->inumber));
        /*
         * Put the new inode number in, log it.
@@ -1523,7 +1530,7 @@ xfs_dir2_leaf_replace(
        dep->inumber = cpu_to_be64(args->inumber);
        dp->d_ops->data_put_ftype(dep, args->filetype);
        tp = args->trans;
-       xfs_dir2_data_log_entry(tp, dp, dbp, dep);
+       xfs_dir2_data_log_entry(args, dbp, dep);
        xfs_dir3_leaf_check(dp, lbp);
        xfs_trans_brelse(tp, lbp);
        return 0;
@@ -1609,12 +1616,13 @@ xfs_dir2_leaf_trim_data(
        /*
         * Read the offending data block.  We need its buffer.
         */
-       error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(mp, db), -1, &dbp);
+       error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(args->geo, db),
+                                  -1, &dbp);
        if (error)
                return error;
 
        leaf = lbp->b_addr;
-       ltp = xfs_dir2_leaf_tail_p(mp, leaf);
+       ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
 
 #ifdef DEBUG
 {
@@ -1624,7 +1632,7 @@ xfs_dir2_leaf_trim_data(
        ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
               hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC));
        ASSERT(be16_to_cpu(bf[0].length) ==
-              mp->m_dirblksize - dp->d_ops->data_entry_offset);
+              args->geo->blksize - dp->d_ops->data_entry_offset);
        ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
 }
 #endif
@@ -1643,8 +1651,8 @@ xfs_dir2_leaf_trim_data(
        bestsp = xfs_dir2_leaf_bests_p(ltp);
        be32_add_cpu(&ltp->bestcount, -1);
        memmove(&bestsp[1], &bestsp[0], be32_to_cpu(ltp->bestcount) * sizeof(*bestsp));
-       xfs_dir3_leaf_log_tail(tp, lbp);
-       xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
+       xfs_dir3_leaf_log_tail(args, lbp);
+       xfs_dir3_leaf_log_bests(args, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
        return 0;
 }
 
@@ -1708,22 +1716,22 @@ xfs_dir2_node_to_leaf(
        /*
         * Get the last offset in the file.
         */
-       if ((error = xfs_bmap_last_offset(tp, dp, &fo, XFS_DATA_FORK))) {
+       if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK))) {
                return error;
        }
-       fo -= mp->m_dirblkfsbs;
+       fo -= args->geo->fsbcount;
        /*
         * If there are freespace blocks other than the first one,
         * take this opportunity to remove trailing empty freespace blocks
         * that may have been left behind during no-space-reservation
         * operations.
         */
-       while (fo > mp->m_dirfreeblk) {
+       while (fo > args->geo->freeblk) {
                if ((error = xfs_dir2_node_trim_free(args, fo, &rval))) {
                        return error;
                }
                if (rval)
-                       fo -= mp->m_dirblkfsbs;
+                       fo -= args->geo->fsbcount;
                else
                        return 0;
        }
@@ -1736,7 +1744,7 @@ xfs_dir2_node_to_leaf(
        /*
         * If it's not the single leaf block, give up.
         */
-       if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + mp->m_dirblksize)
+       if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + args->geo->blksize)
                return 0;
        lbp = state->path.blk[0].bp;
        leaf = lbp->b_addr;
@@ -1748,7 +1756,7 @@ xfs_dir2_node_to_leaf(
        /*
         * Read the freespace block.
         */
-       error = xfs_dir2_free_read(tp, dp,  mp->m_dirfreeblk, &fbp);
+       error = xfs_dir2_free_read(tp, dp,  args->geo->freeblk, &fbp);
        if (error)
                return error;
        free = fbp->b_addr;
@@ -1760,7 +1768,7 @@ xfs_dir2_node_to_leaf(
         * Now see if the leafn and free data will fit in a leaf1.
         * If not, release the buffer and give up.
         */
-       if (xfs_dir3_leaf_size(&leafhdr, freehdr.nvalid) > mp->m_dirblksize) {
+       if (xfs_dir3_leaf_size(&leafhdr, freehdr.nvalid) > args->geo->blksize) {
                xfs_trans_brelse(tp, fbp);
                return 0;
        }
@@ -1780,7 +1788,7 @@ xfs_dir2_node_to_leaf(
        /*
         * Set up the leaf tail from the freespace block.
         */
-       ltp = xfs_dir2_leaf_tail_p(mp, leaf);
+       ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
        ltp->bestcount = cpu_to_be32(freehdr.nvalid);
 
        /*
@@ -1790,15 +1798,17 @@ xfs_dir2_node_to_leaf(
                freehdr.nvalid * sizeof(xfs_dir2_data_off_t));
 
        dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
-       xfs_dir3_leaf_log_header(tp, dp, lbp);
-       xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
-       xfs_dir3_leaf_log_tail(tp, lbp);
+       xfs_dir3_leaf_log_header(args, lbp);
+       xfs_dir3_leaf_log_bests(args, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
+       xfs_dir3_leaf_log_tail(args, lbp);
        xfs_dir3_leaf_check(dp, lbp);
 
        /*
         * Get rid of the freespace block.
         */
-       error = xfs_dir2_shrink_inode(args, XFS_DIR2_FREE_FIRSTDB(mp), fbp);
+       error = xfs_dir2_shrink_inode(args,
+                       xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET),
+                       fbp);
        if (error) {
                /*
                 * This can't fail here because it can only happen when