xfs: vectorise directory leaf operations
[cascardo/linux.git] / fs / xfs / xfs_dir2_node.c
index 4c3dba7..3a426ed 100644 (file)
  */
 #include "xfs.h"
 #include "xfs_fs.h"
-#include "xfs_types.h"
-#include "xfs_log.h"
-#include "xfs_trans.h"
+#include "xfs_format.h"
+#include "xfs_log_format.h"
+#include "xfs_trans_resv.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
 #include "xfs_mount.h"
+#include "xfs_da_format.h"
 #include "xfs_da_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_dinode.h"
 #include "xfs_inode.h"
 #include "xfs_bmap.h"
-#include "xfs_dir2_format.h"
 #include "xfs_dir2.h"
 #include "xfs_dir2_priv.h"
 #include "xfs_error.h"
 #include "xfs_trace.h"
+#include "xfs_trans.h"
 #include "xfs_buf_item.h"
 #include "xfs_cksum.h"
 
@@ -55,15 +54,15 @@ static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
  * Check internal consistency of a leafn block.
  */
 #ifdef DEBUG
-#define        xfs_dir3_leaf_check(mp, bp) \
+#define        xfs_dir3_leaf_check(dp, bp) \
 do { \
-       if (!xfs_dir3_leafn_check((mp), (bp))) \
+       if (!xfs_dir3_leafn_check((dp), (bp))) \
                ASSERT(0); \
 } while (0);
 
 static bool
 xfs_dir3_leafn_check(
-       struct xfs_mount        *mp,
+       struct xfs_inode        *dp,
        struct xfs_buf          *bp)
 {
        struct xfs_dir2_leaf    *leaf = bp->b_addr;
@@ -78,10 +77,10 @@ xfs_dir3_leafn_check(
        } else if (leafhdr.magic != XFS_DIR2_LEAFN_MAGIC)
                return false;
 
-       return xfs_dir3_leaf_check_int(mp, &leafhdr, leaf);
+       return xfs_dir3_leaf_check_int(dp->i_mount, dp, &leafhdr, leaf);
 }
 #else
-#define        xfs_dir3_leaf_check(mp, bp)
+#define        xfs_dir3_leaf_check(dp, bp)
 #endif
 
 static bool
@@ -409,8 +408,8 @@ xfs_dir2_leaf_to_node(
                leaf->hdr.info.magic = cpu_to_be16(XFS_DIR3_LEAFN_MAGIC);
        lbp->b_ops = &xfs_dir3_leafn_buf_ops;
        xfs_trans_buf_set_type(tp, lbp, XFS_BLFT_DIR_LEAFN_BUF);
-       xfs_dir3_leaf_log_header(tp, lbp);
-       xfs_dir3_leaf_check(mp, lbp);
+       xfs_dir3_leaf_log_header(tp, dp, lbp);
+       xfs_dir3_leaf_check(dp, lbp);
        return 0;
 }
 
@@ -444,7 +443,7 @@ xfs_dir2_leafn_add(
        tp = args->trans;
        leaf = bp->b_addr;
        xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
-       ents = xfs_dir3_leaf_ents_p(leaf);
+       ents = dp->d_ops->leaf_ents_p(leaf);
 
        /*
         * Quick check just to make sure we are not going to index
@@ -460,7 +459,7 @@ xfs_dir2_leafn_add(
         * a compact.
         */
 
-       if (leafhdr.count == xfs_dir3_max_leaf_ents(mp, leaf)) {
+       if (leafhdr.count == dp->d_ops->leaf_max_ents(mp)) {
                if (!leafhdr.stale)
                        return XFS_ERROR(ENOSPC);
                compact = leafhdr.stale > 1;
@@ -499,9 +498,9 @@ xfs_dir2_leafn_add(
                                args->blkno, args->index));
 
        xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr);
-       xfs_dir3_leaf_log_header(tp, bp);
-       xfs_dir3_leaf_log_ents(tp, bp, lfloglow, lfloghigh);
-       xfs_dir3_leaf_check(mp, bp);
+       xfs_dir3_leaf_log_header(tp, dp, bp);
+       xfs_dir3_leaf_log_ents(tp, dp, bp, lfloglow, lfloghigh);
+       xfs_dir3_leaf_check(dp, bp);
        return 0;
 }
 
@@ -530,6 +529,7 @@ xfs_dir2_free_hdr_check(
  */
 xfs_dahash_t                                   /* hash value */
 xfs_dir2_leafn_lasthash(
+       struct xfs_inode *dp,
        struct xfs_buf  *bp,                    /* leaf buffer */
        int             *count)                 /* count of entries in leaf */
 {
@@ -547,7 +547,7 @@ xfs_dir2_leafn_lasthash(
        if (!leafhdr.count)
                return 0;
 
-       ents = xfs_dir3_leaf_ents_p(leaf);
+       ents = dp->d_ops->leaf_ents_p(leaf);
        return be32_to_cpu(ents[leafhdr.count - 1].hashval);
 }
 
@@ -585,9 +585,9 @@ xfs_dir2_leafn_lookup_for_addname(
        mp = dp->i_mount;
        leaf = bp->b_addr;
        xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
-       ents = xfs_dir3_leaf_ents_p(leaf);
+       ents = dp->d_ops->leaf_ents_p(leaf);
 
-       xfs_dir3_leaf_check(mp, bp);
+       xfs_dir3_leaf_check(dp, bp);
        ASSERT(leafhdr.count > 0);
 
        /*
@@ -605,7 +605,7 @@ xfs_dir2_leafn_lookup_for_addname(
                ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
                       free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
        }
-       length = xfs_dir3_data_entsize(mp, args->namelen);
+       length = dp->d_ops->data_entsize(args->namelen);
        /*
         * Loop over leaf entries with the right hash value.
         */
@@ -735,9 +735,9 @@ xfs_dir2_leafn_lookup_for_entry(
        mp = dp->i_mount;
        leaf = bp->b_addr;
        xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
-       ents = xfs_dir3_leaf_ents_p(leaf);
+       ents = dp->d_ops->leaf_ents_p(leaf);
 
-       xfs_dir3_leaf_check(mp, bp);
+       xfs_dir3_leaf_check(dp, bp);
        ASSERT(leafhdr.count > 0);
 
        /*
@@ -816,7 +816,7 @@ xfs_dir2_leafn_lookup_for_entry(
                                xfs_trans_brelse(tp, state->extrablk.bp);
                        args->cmpresult = cmp;
                        args->inumber = be64_to_cpu(dep->inumber);
-                       args->filetype = xfs_dir3_dirent_get_ftype(mp, dep);
+                       args->filetype = dp->d_ops->data_get_ftype(dep);
                        *indexp = index;
                        state->extravalid = 1;
                        state->extrablk.bp = curbp;
@@ -907,7 +907,7 @@ xfs_dir3_leafn_moveents(
        if (start_d < dhdr->count) {
                memmove(&dents[start_d + count], &dents[start_d],
                        (dhdr->count - start_d) * sizeof(xfs_dir2_leaf_entry_t));
-               xfs_dir3_leaf_log_ents(tp, bp_d, start_d + count,
+               xfs_dir3_leaf_log_ents(tp, args->dp, bp_d, start_d + count,
                                       count + dhdr->count - 1);
        }
        /*
@@ -929,7 +929,8 @@ xfs_dir3_leafn_moveents(
         */
        memcpy(&dents[start_d], &sents[start_s],
                count * sizeof(xfs_dir2_leaf_entry_t));
-       xfs_dir3_leaf_log_ents(tp, bp_d, start_d, start_d + count - 1);
+       xfs_dir3_leaf_log_ents(tp, args->dp, bp_d,
+                              start_d, start_d + count - 1);
 
        /*
         * If there are source entries after the ones we copied,
@@ -938,7 +939,8 @@ xfs_dir3_leafn_moveents(
        if (start_s + count < shdr->count) {
                memmove(&sents[start_s], &sents[start_s + count],
                        count * sizeof(xfs_dir2_leaf_entry_t));
-               xfs_dir3_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1);
+               xfs_dir3_leaf_log_ents(tp, args->dp, bp_s,
+                                      start_s, start_s + count - 1);
        }
 
        /*
@@ -956,6 +958,7 @@ xfs_dir3_leafn_moveents(
  */
 int                                            /* sort order */
 xfs_dir2_leafn_order(
+       struct xfs_inode        *dp,
        struct xfs_buf          *leaf1_bp,              /* leaf1 buffer */
        struct xfs_buf          *leaf2_bp)              /* leaf2 buffer */
 {
@@ -968,8 +971,8 @@ xfs_dir2_leafn_order(
 
        xfs_dir3_leaf_hdr_from_disk(&hdr1, leaf1);
        xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf2);
-       ents1 = xfs_dir3_leaf_ents_p(leaf1);
-       ents2 = xfs_dir3_leaf_ents_p(leaf2);
+       ents1 = dp->d_ops->leaf_ents_p(leaf1);
+       ents2 = dp->d_ops->leaf_ents_p(leaf2);
 
        if (hdr1.count > 0 && hdr2.count > 0 &&
            (be32_to_cpu(ents2[0].hashval) < be32_to_cpu(ents1[0].hashval) ||
@@ -1007,12 +1010,13 @@ xfs_dir2_leafn_rebalance(
        struct xfs_dir2_leaf_entry *ents2;
        struct xfs_dir3_icleaf_hdr hdr1;
        struct xfs_dir3_icleaf_hdr hdr2;
+       struct xfs_inode        *dp = state->args->dp;
 
        args = state->args;
        /*
         * If the block order is wrong, swap the arguments.
         */
-       if ((swap = xfs_dir2_leafn_order(blk1->bp, blk2->bp))) {
+       if ((swap = xfs_dir2_leafn_order(dp, blk1->bp, blk2->bp))) {
                xfs_da_state_blk_t      *tmp;   /* temp for block swap */
 
                tmp = blk1;
@@ -1023,8 +1027,8 @@ xfs_dir2_leafn_rebalance(
        leaf2 = blk2->bp->b_addr;
        xfs_dir3_leaf_hdr_from_disk(&hdr1, leaf1);
        xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf2);
-       ents1 = xfs_dir3_leaf_ents_p(leaf1);
-       ents2 = xfs_dir3_leaf_ents_p(leaf2);
+       ents1 = dp->d_ops->leaf_ents_p(leaf1);
+       ents2 = dp->d_ops->leaf_ents_p(leaf2);
 
        oldsum = hdr1.count + hdr2.count;
 #if defined(DEBUG) || defined(XFS_WARN)
@@ -1072,11 +1076,11 @@ xfs_dir2_leafn_rebalance(
        /* log the changes made when moving the entries */
        xfs_dir3_leaf_hdr_to_disk(leaf1, &hdr1);
        xfs_dir3_leaf_hdr_to_disk(leaf2, &hdr2);
-       xfs_dir3_leaf_log_header(args->trans, blk1->bp);
-       xfs_dir3_leaf_log_header(args->trans, blk2->bp);
+       xfs_dir3_leaf_log_header(args->trans, dp, blk1->bp);
+       xfs_dir3_leaf_log_header(args->trans, dp, blk2->bp);
 
-       xfs_dir3_leaf_check(args->dp->i_mount, blk1->bp);
-       xfs_dir3_leaf_check(args->dp->i_mount, blk2->bp);
+       xfs_dir3_leaf_check(dp, blk1->bp);
+       xfs_dir3_leaf_check(dp, blk2->bp);
 
        /*
         * Mark whether we're inserting into the old or new leaf.
@@ -1097,11 +1101,11 @@ xfs_dir2_leafn_rebalance(
         * Finally sanity check just to make sure we are not returning a
         * negative index
         */
-       if(blk2->index < 0) {
+       if (blk2->index < 0) {
                state->inleaf = 1;
                blk2->index = 0;
-               xfs_alert(args->dp->i_mount,
-       "%s: picked the wrong leaf? reverting original leaf: blk1->index %d\n",
+               xfs_alert(dp->i_mount,
+       "%s: picked the wrong leaf? reverting original leaf: blk1->index %d",
                        __func__, blk1->index);
        }
 }
@@ -1223,7 +1227,7 @@ xfs_dir2_leafn_remove(
        mp = dp->i_mount;
        leaf = bp->b_addr;
        xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
-       ents = xfs_dir3_leaf_ents_p(leaf);
+       ents = dp->d_ops->leaf_ents_p(leaf);
 
        /*
         * Point to the entry we're removing.
@@ -1244,10 +1248,10 @@ xfs_dir2_leafn_remove(
         */
        leafhdr.stale++;
        xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr);
-       xfs_dir3_leaf_log_header(tp, bp);
+       xfs_dir3_leaf_log_header(tp, dp, bp);
 
        lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
-       xfs_dir3_leaf_log_ents(tp, bp, index, index);
+       xfs_dir3_leaf_log_ents(tp, dp, bp, index, index);
 
        /*
         * Make the data entry free.  Keep track of the longest freespace
@@ -1256,19 +1260,19 @@ xfs_dir2_leafn_remove(
        dbp = dblk->bp;
        hdr = dbp->b_addr;
        dep = (xfs_dir2_data_entry_t *)((char *)hdr + off);
-       bf = xfs_dir3_data_bestfree_p(hdr);
+       bf = dp->d_ops->data_bestfree_p(hdr);
        longest = be16_to_cpu(bf[0].length);
        needlog = needscan = 0;
-       xfs_dir2_data_make_free(tp, dbp, off,
-               xfs_dir3_data_entsize(mp, dep->namelen), &needlog, &needscan);
+       xfs_dir2_data_make_free(tp, dp, dbp, off,
+               dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
        /*
         * Rescan the data block freespaces for bestfree.
         * Log the data block header if needed.
         */
        if (needscan)
-               xfs_dir2_data_freescan(mp, hdr, &needlog);
+               xfs_dir2_data_freescan(dp, hdr, &needlog);
        if (needlog)
-               xfs_dir2_data_log_header(tp, dbp);
+               xfs_dir2_data_log_header(tp, dp, dbp);
        xfs_dir3_data_check(dp, dbp);
        /*
         * If the longest data block freespace changes, need to update
@@ -1309,7 +1313,7 @@ xfs_dir2_leafn_remove(
                 * (usually).
                 */
                if (longest == mp->m_dirblksize -
-                              xfs_dir3_data_entry_offset(hdr)) {
+                              dp->d_ops->data_entry_offset()) {
                        /*
                         * Try to punch out the data block.
                         */
@@ -1336,12 +1340,12 @@ xfs_dir2_leafn_remove(
                        return error;
        }
 
-       xfs_dir3_leaf_check(mp, bp);
+       xfs_dir3_leaf_check(dp, bp);
        /*
         * Return indication of whether this leaf block is empty enough
         * to justify trying to join it with a neighbor.
         */
-       *rval = (xfs_dir3_leaf_hdr_size(leaf) +
+       *rval = (dp->d_ops->leaf_hdr_size() +
                 (uint)sizeof(ents[0]) * (leafhdr.count - leafhdr.stale)) <
                mp->m_dir_magicpct;
        return 0;
@@ -1360,12 +1364,14 @@ xfs_dir2_leafn_split(
        xfs_dablk_t             blkno;          /* new leaf block number */
        int                     error;          /* error return value */
        xfs_mount_t             *mp;            /* filesystem mount point */
+       struct xfs_inode        *dp;
 
        /*
         * Allocate space for a new leaf node.
         */
        args = state->args;
-       mp = args->dp->i_mount;
+       dp = args->dp;
+       mp = dp->i_mount;
        ASSERT(args != NULL);
        ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC);
        error = xfs_da_grow_inode(args, &blkno);
@@ -1401,10 +1407,10 @@ xfs_dir2_leafn_split(
        /*
         * Update last hashval in each block since we added the name.
         */
-       oldblk->hashval = xfs_dir2_leafn_lasthash(oldblk->bp, NULL);
-       newblk->hashval = xfs_dir2_leafn_lasthash(newblk->bp, NULL);
-       xfs_dir3_leaf_check(mp, oldblk->bp);
-       xfs_dir3_leaf_check(mp, newblk->bp);
+       oldblk->hashval = xfs_dir2_leafn_lasthash(dp, oldblk->bp, NULL);
+       newblk->hashval = xfs_dir2_leafn_lasthash(dp, newblk->bp, NULL);
+       xfs_dir3_leaf_check(dp, oldblk->bp);
+       xfs_dir3_leaf_check(dp, newblk->bp);
        return error;
 }
 
@@ -1434,6 +1440,7 @@ xfs_dir2_leafn_toosmall(
        int                     rval;           /* result from path_shift */
        struct xfs_dir3_icleaf_hdr leafhdr;
        struct xfs_dir2_leaf_entry *ents;
+       struct xfs_inode        *dp = state->args->dp;
 
        /*
         * Check for the degenerate case of the block being over 50% full.
@@ -1443,11 +1450,11 @@ xfs_dir2_leafn_toosmall(
        blk = &state->path.blk[state->path.active - 1];
        leaf = blk->bp->b_addr;
        xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
-       ents = xfs_dir3_leaf_ents_p(leaf);
-       xfs_dir3_leaf_check(state->args->dp->i_mount, blk->bp);
+       ents = dp->d_ops->leaf_ents_p(leaf);
+       xfs_dir3_leaf_check(dp, blk->bp);
 
        count = leafhdr.count - leafhdr.stale;
-       bytes = xfs_dir3_leaf_hdr_size(leaf) + count * sizeof(ents[0]);
+       bytes = dp->d_ops->leaf_hdr_size() + count * sizeof(ents[0]);
        if (bytes > (state->blocksize >> 1)) {
                /*
                 * Blk over 50%, don't try to join.
@@ -1492,7 +1499,7 @@ xfs_dir2_leafn_toosmall(
                /*
                 * Read the sibling leaf block.
                 */
-               error = xfs_dir3_leafn_read(state->args->trans, state->args->dp,
+               error = xfs_dir3_leafn_read(state->args->trans, dp,
                                            blkno, -1, &bp);
                if (error)
                        return error;
@@ -1505,7 +1512,7 @@ xfs_dir2_leafn_toosmall(
 
                leaf = bp->b_addr;
                xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf);
-               ents = xfs_dir3_leaf_ents_p(leaf);
+               ents = dp->d_ops->leaf_ents_p(leaf);
                count += hdr2.count - hdr2.stale;
                bytes -= count * sizeof(ents[0]);
 
@@ -1559,6 +1566,7 @@ xfs_dir2_leafn_unbalance(
        struct xfs_dir3_icleaf_hdr drophdr;
        struct xfs_dir2_leaf_entry *sents;
        struct xfs_dir2_leaf_entry *dents;
+       struct xfs_inode        *dp = state->args->dp;
 
        args = state->args;
        ASSERT(drop_blk->magic == XFS_DIR2_LEAFN_MAGIC);
@@ -1568,8 +1576,8 @@ xfs_dir2_leafn_unbalance(
 
        xfs_dir3_leaf_hdr_from_disk(&savehdr, save_leaf);
        xfs_dir3_leaf_hdr_from_disk(&drophdr, drop_leaf);
-       sents = xfs_dir3_leaf_ents_p(save_leaf);
-       dents = xfs_dir3_leaf_ents_p(drop_leaf);
+       sents = args->dp->d_ops->leaf_ents_p(save_leaf);
+       dents = args->dp->d_ops->leaf_ents_p(drop_leaf);
 
        /*
         * If there are any stale leaf entries, take this opportunity
@@ -1584,7 +1592,7 @@ xfs_dir2_leafn_unbalance(
         * Move the entries from drop to the appropriate end of save.
         */
        drop_blk->hashval = be32_to_cpu(dents[drophdr.count - 1].hashval);
-       if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp))
+       if (xfs_dir2_leafn_order(dp, save_blk->bp, drop_blk->bp))
                xfs_dir3_leafn_moveents(args, drop_blk->bp, &drophdr, dents, 0,
                                        save_blk->bp, &savehdr, sents, 0,
                                        drophdr.count);
@@ -1597,11 +1605,11 @@ xfs_dir2_leafn_unbalance(
        /* log the changes made when moving the entries */
        xfs_dir3_leaf_hdr_to_disk(save_leaf, &savehdr);
        xfs_dir3_leaf_hdr_to_disk(drop_leaf, &drophdr);
-       xfs_dir3_leaf_log_header(args->trans, save_blk->bp);
-       xfs_dir3_leaf_log_header(args->trans, drop_blk->bp);
+       xfs_dir3_leaf_log_header(args->trans, dp, save_blk->bp);
+       xfs_dir3_leaf_log_header(args->trans, dp, drop_blk->bp);
 
-       xfs_dir3_leaf_check(args->dp->i_mount, save_blk->bp);
-       xfs_dir3_leaf_check(args->dp->i_mount, drop_blk->bp);
+       xfs_dir3_leaf_check(dp, save_blk->bp);
+       xfs_dir3_leaf_check(dp, drop_blk->bp);
 }
 
 /*
@@ -1712,7 +1720,7 @@ xfs_dir2_node_addname_int(
        dp = args->dp;
        mp = dp->i_mount;
        tp = args->trans;
-       length = xfs_dir3_data_entsize(mp, args->namelen);
+       length = dp->d_ops->data_entsize(args->namelen);
        /*
         * If we came in with a freespace block that means that lookup
         * found an entry with our hash value.  This is the freespace
@@ -1963,7 +1971,7 @@ xfs_dir2_node_addname_int(
                 * change again.
                 */
                hdr = dbp->b_addr;
-               bf = xfs_dir3_data_bestfree_p(hdr);
+               bf = dp->d_ops->data_bestfree_p(hdr);
                bests[findex] = bf[0].length;
                logfree = 1;
        }
@@ -1985,7 +1993,7 @@ xfs_dir2_node_addname_int(
                if (error)
                        return error;
                hdr = dbp->b_addr;
-               bf = xfs_dir3_data_bestfree_p(hdr);
+               bf = dp->d_ops->data_bestfree_p(hdr);
                logfree = 0;
        }
        ASSERT(be16_to_cpu(bf[0].length) >= length);
@@ -1998,7 +2006,7 @@ xfs_dir2_node_addname_int(
        /*
         * Mark the first part of the unused space, inuse for us.
         */
-       xfs_dir2_data_use_free(tp, dbp, dup,
+       xfs_dir2_data_use_free(tp, dp, dbp, dup,
                (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
                &needlog, &needscan);
        /*
@@ -2008,20 +2016,20 @@ xfs_dir2_node_addname_int(
        dep->inumber = cpu_to_be64(args->inumber);
        dep->namelen = args->namelen;
        memcpy(dep->name, args->name, dep->namelen);
-       xfs_dir3_dirent_put_ftype(mp, dep, args->filetype);
-       tagp = xfs_dir3_data_entry_tag_p(mp, dep);
+       dp->d_ops->data_put_ftype(dep, args->filetype);
+       tagp = dp->d_ops->data_entry_tag_p(dep);
        *tagp = cpu_to_be16((char *)dep - (char *)hdr);
-       xfs_dir2_data_log_entry(tp, dbp, dep);
+       xfs_dir2_data_log_entry(tp, dp, dbp, dep);
        /*
         * Rescan the block for bestfree if needed.
         */
        if (needscan)
-               xfs_dir2_data_freescan(mp, hdr, &needlog);
+               xfs_dir2_data_freescan(dp, hdr, &needlog);
        /*
         * Log the data block header if needed.
         */
        if (needlog)
-               xfs_dir2_data_log_header(tp, dbp);
+               xfs_dir2_data_log_header(tp, dp, dbp);
        /*
         * If the freespace entry is now wrong, update it.
         */
@@ -2212,7 +2220,7 @@ xfs_dir2_node_replace(
                blk = &state->path.blk[state->path.active - 1];
                ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC);
                leaf = blk->bp->b_addr;
-               ents = xfs_dir3_leaf_ents_p(leaf);
+               ents = args->dp->d_ops->leaf_ents_p(leaf);
                lep = &ents[blk->index];
                ASSERT(state->extravalid);
                /*
@@ -2229,8 +2237,9 @@ xfs_dir2_node_replace(
                 * Fill in the new inode number and log the entry.
                 */
                dep->inumber = cpu_to_be64(inum);
-               xfs_dir3_dirent_put_ftype(state->mp, dep, args->filetype);
-               xfs_dir2_data_log_entry(args->trans, state->extrablk.bp, dep);
+               args->dp->d_ops->data_put_ftype(dep, args->filetype);
+               xfs_dir2_data_log_entry(args->trans, args->dp,
+                                       state->extrablk.bp, dep);
                rval = 0;
        }
        /*