]> Pileus Git - ~andy/linux/blobdiff - fs/xfs/xfs_dir2_node.c
ARM: at91: fixed unresolved symbol "at91_pm_set_standby" when built without CONFIG_PM
[~andy/linux] / fs / xfs / xfs_dir2_node.c
index 9cfc00323b196e43d6b9438244dbcfaa92b5e8d5..56369d4509d5603cff44adeb17902324a547f48b 100644 (file)
@@ -54,21 +54,21 @@ 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;
        struct xfs_dir3_icleaf_hdr leafhdr;
 
-       xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
+       dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
 
        if (leafhdr.magic == XFS_DIR3_LEAFN_MAGIC) {
                struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr;
@@ -77,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
@@ -192,53 +192,6 @@ xfs_dir2_free_try_read(
        return __xfs_dir3_free_read(tp, dp, fbno, -2, bpp);
 }
 
-
-void
-xfs_dir3_free_hdr_from_disk(
-       struct xfs_dir3_icfree_hdr      *to,
-       struct xfs_dir2_free            *from)
-{
-       if (from->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)) {
-               to->magic = be32_to_cpu(from->hdr.magic);
-               to->firstdb = be32_to_cpu(from->hdr.firstdb);
-               to->nvalid = be32_to_cpu(from->hdr.nvalid);
-               to->nused = be32_to_cpu(from->hdr.nused);
-       } else {
-               struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)from;
-
-               to->magic = be32_to_cpu(hdr3->hdr.magic);
-               to->firstdb = be32_to_cpu(hdr3->firstdb);
-               to->nvalid = be32_to_cpu(hdr3->nvalid);
-               to->nused = be32_to_cpu(hdr3->nused);
-       }
-
-       ASSERT(to->magic == XFS_DIR2_FREE_MAGIC ||
-              to->magic == XFS_DIR3_FREE_MAGIC);
-}
-
-static void
-xfs_dir3_free_hdr_to_disk(
-       struct xfs_dir2_free            *to,
-       struct xfs_dir3_icfree_hdr      *from)
-{
-       ASSERT(from->magic == XFS_DIR2_FREE_MAGIC ||
-              from->magic == XFS_DIR3_FREE_MAGIC);
-
-       if (from->magic == XFS_DIR2_FREE_MAGIC) {
-               to->hdr.magic = cpu_to_be32(from->magic);
-               to->hdr.firstdb = cpu_to_be32(from->firstdb);
-               to->hdr.nvalid = cpu_to_be32(from->nvalid);
-               to->hdr.nused = cpu_to_be32(from->nused);
-       } else {
-               struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)to;
-
-               hdr3->hdr.magic = cpu_to_be32(from->magic);
-               hdr3->firstdb = cpu_to_be32(from->firstdb);
-               hdr3->nvalid = cpu_to_be32(from->nvalid);
-               hdr3->nused = cpu_to_be32(from->nused);
-       }
-}
-
 static int
 xfs_dir3_free_get_buf(
        struct xfs_trans        *tp,
@@ -276,7 +229,7 @@ xfs_dir3_free_get_buf(
                uuid_copy(&hdr3->hdr.uuid, &mp->m_sb.sb_uuid);
        } else
                hdr.magic = XFS_DIR2_FREE_MAGIC;
-       xfs_dir3_free_hdr_to_disk(bp->b_addr, &hdr);
+       dp->d_ops->free_hdr_to_disk(bp->b_addr, &hdr);
        *bpp = bp;
        return 0;
 }
@@ -287,6 +240,7 @@ xfs_dir3_free_get_buf(
 STATIC void
 xfs_dir2_free_log_bests(
        struct xfs_trans        *tp,
+       struct xfs_inode        *dp,
        struct xfs_buf          *bp,
        int                     first,          /* first entry to log */
        int                     last)           /* last entry to log */
@@ -295,7 +249,7 @@ xfs_dir2_free_log_bests(
        __be16                  *bests;
 
        free = bp->b_addr;
-       bests = xfs_dir3_free_bests_p(tp->t_mountp, free);
+       bests = dp->d_ops->free_bests_p(free);
        ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
               free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
        xfs_trans_log_buf(tp, bp,
@@ -310,6 +264,7 @@ xfs_dir2_free_log_bests(
 static void
 xfs_dir2_free_log_header(
        struct xfs_trans        *tp,
+       struct xfs_inode        *dp,
        struct xfs_buf          *bp)
 {
 #ifdef DEBUG
@@ -319,7 +274,7 @@ xfs_dir2_free_log_header(
        ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
               free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
 #endif
-       xfs_trans_log_buf(tp, bp, 0, xfs_dir3_free_hdr_size(tp->t_mountp) - 1);
+       xfs_trans_log_buf(tp, bp, 0, dp->d_ops->free_hdr_size - 1);
 }
 
 /*
@@ -368,7 +323,7 @@ xfs_dir2_leaf_to_node(
                return error;
 
        free = fbp->b_addr;
-       xfs_dir3_free_hdr_from_disk(&freehdr, free);
+       dp->d_ops->free_hdr_from_disk(&freehdr, free);
        leaf = lbp->b_addr;
        ltp = xfs_dir2_leaf_tail_p(mp, leaf);
        ASSERT(be32_to_cpu(ltp->bestcount) <=
@@ -379,7 +334,7 @@ xfs_dir2_leaf_to_node(
         * Count active entries.
         */
        from = xfs_dir2_leaf_bests_p(ltp);
-       to = xfs_dir3_free_bests_p(mp, free);
+       to = dp->d_ops->free_bests_p(free);
        for (i = n = 0; i < be32_to_cpu(ltp->bestcount); i++, from++, to++) {
                if ((off = be16_to_cpu(*from)) != NULLDATAOFF)
                        n++;
@@ -392,9 +347,9 @@ xfs_dir2_leaf_to_node(
        freehdr.nused = n;
        freehdr.nvalid = be32_to_cpu(ltp->bestcount);
 
-       xfs_dir3_free_hdr_to_disk(fbp->b_addr, &freehdr);
-       xfs_dir2_free_log_bests(tp, fbp, 0, freehdr.nvalid - 1);
-       xfs_dir2_free_log_header(tp, fbp);
+       dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
+       xfs_dir2_free_log_bests(tp, dp, fbp, 0, freehdr.nvalid - 1);
+       xfs_dir2_free_log_header(tp, dp, fbp);
 
        /*
         * Converting the leaf to a leafnode is just a matter of changing the
@@ -408,8 +363,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;
 }
 
@@ -442,8 +397,8 @@ xfs_dir2_leafn_add(
        mp = dp->i_mount;
        tp = args->trans;
        leaf = bp->b_addr;
-       xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
-       ents = xfs_dir3_leaf_ents_p(leaf);
+       dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
+       ents = dp->d_ops->leaf_ents_p(leaf);
 
        /*
         * Quick check just to make sure we are not going to index
@@ -459,7 +414,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;
@@ -497,30 +452,30 @@ xfs_dir2_leafn_add(
        lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp,
                                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);
+       dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
+       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;
 }
 
 #ifdef DEBUG
 static void
 xfs_dir2_free_hdr_check(
-       struct xfs_mount *mp,
+       struct xfs_inode *dp,
        struct xfs_buf  *bp,
        xfs_dir2_db_t   db)
 {
        struct xfs_dir3_icfree_hdr hdr;
 
-       xfs_dir3_free_hdr_from_disk(&hdr, bp->b_addr);
+       dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr);
 
-       ASSERT((hdr.firstdb % xfs_dir3_free_max_bests(mp)) == 0);
+       ASSERT((hdr.firstdb % dp->d_ops->free_max_bests(dp->i_mount)) == 0);
        ASSERT(hdr.firstdb <= db);
        ASSERT(db < hdr.firstdb + hdr.nvalid);
 }
 #else
-#define xfs_dir2_free_hdr_check(mp, dp, db)
+#define xfs_dir2_free_hdr_check(dp, bp, db)
 #endif /* DEBUG */
 
 /*
@@ -529,6 +484,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 */
 {
@@ -536,7 +492,7 @@ xfs_dir2_leafn_lasthash(
        struct xfs_dir2_leaf_entry *ents;
        struct xfs_dir3_icleaf_hdr leafhdr;
 
-       xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
+       dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
 
        ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC ||
               leafhdr.magic == XFS_DIR3_LEAFN_MAGIC);
@@ -546,7 +502,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);
 }
 
@@ -583,10 +539,10 @@ xfs_dir2_leafn_lookup_for_addname(
        tp = args->trans;
        mp = dp->i_mount;
        leaf = bp->b_addr;
-       xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
-       ents = xfs_dir3_leaf_ents_p(leaf);
+       dp->d_ops->leaf_hdr_from_disk(&leafhdr, 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);
 
        /*
@@ -636,7 +592,7 @@ xfs_dir2_leafn_lookup_for_addname(
                         * Convert the data block to the free block
                         * holding its freespace information.
                         */
-                       newfdb = xfs_dir2_db_to_fdb(mp, newdb);
+                       newfdb = dp->d_ops->db_to_fdb(mp, newdb);
                        /*
                         * If it's not the one we have in hand, read it in.
                         */
@@ -654,16 +610,16 @@ xfs_dir2_leafn_lookup_for_addname(
                                        return error;
                                free = curbp->b_addr;
 
-                               xfs_dir2_free_hdr_check(mp, curbp, curdb);
+                               xfs_dir2_free_hdr_check(dp, curbp, curdb);
                        }
                        /*
                         * Get the index for our entry.
                         */
-                       fi = xfs_dir2_db_to_fdindex(mp, curdb);
+                       fi = dp->d_ops->db_to_fdindex(mp, curdb);
                        /*
                         * If it has room, return it.
                         */
-                       bests = xfs_dir3_free_bests_p(mp, free);
+                       bests = dp->d_ops->free_bests_p(free);
                        if (unlikely(bests[fi] == cpu_to_be16(NULLDATAOFF))) {
                                XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int",
                                                        XFS_ERRLEVEL_LOW, mp);
@@ -733,10 +689,10 @@ xfs_dir2_leafn_lookup_for_entry(
        tp = args->trans;
        mp = dp->i_mount;
        leaf = bp->b_addr;
-       xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
-       ents = xfs_dir3_leaf_ents_p(leaf);
+       dp->d_ops->leaf_hdr_from_disk(&leafhdr, 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);
 
        /*
@@ -906,7 +862,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);
        }
        /*
@@ -928,7 +884,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,
@@ -937,7 +894,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);
        }
 
        /*
@@ -955,6 +913,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 */
 {
@@ -965,10 +924,10 @@ xfs_dir2_leafn_order(
        struct xfs_dir3_icleaf_hdr hdr1;
        struct xfs_dir3_icleaf_hdr hdr2;
 
-       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);
+       dp->d_ops->leaf_hdr_from_disk(&hdr1, leaf1);
+       dp->d_ops->leaf_hdr_from_disk(&hdr2, 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) ||
@@ -1006,12 +965,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;
@@ -1020,10 +980,10 @@ xfs_dir2_leafn_rebalance(
        }
        leaf1 = blk1->bp->b_addr;
        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);
+       dp->d_ops->leaf_hdr_from_disk(&hdr1, leaf1);
+       dp->d_ops->leaf_hdr_from_disk(&hdr2, 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)
@@ -1069,13 +1029,13 @@ xfs_dir2_leafn_rebalance(
        ASSERT(hdr1.stale + hdr2.stale == oldstale);
 
        /* 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);
+       dp->d_ops->leaf_hdr_to_disk(leaf1, &hdr1);
+       dp->d_ops->leaf_hdr_to_disk(leaf2, &hdr2);
+       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.
@@ -1096,10 +1056,10 @@ 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,
+               xfs_alert(dp->i_mount,
        "%s: picked the wrong leaf? reverting original leaf: blk1->index %d",
                        __func__, blk1->index);
        }
@@ -1119,17 +1079,17 @@ xfs_dir3_data_block_free(
        int                     logfree = 0;
        __be16                  *bests;
        struct xfs_dir3_icfree_hdr freehdr;
+       struct xfs_inode        *dp = args->dp;
 
-       xfs_dir3_free_hdr_from_disk(&freehdr, free);
-
-       bests = xfs_dir3_free_bests_p(tp->t_mountp, free);
+       dp->d_ops->free_hdr_from_disk(&freehdr, free);
+       bests = dp->d_ops->free_bests_p(free);
        if (hdr) {
                /*
                 * Data block is not empty, just set the free entry to the new
                 * value.
                 */
                bests[findex] = cpu_to_be16(longest);
-               xfs_dir2_free_log_bests(tp, fbp, findex, findex);
+               xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex);
                return 0;
        }
 
@@ -1156,8 +1116,8 @@ xfs_dir3_data_block_free(
                logfree = 1;
        }
 
-       xfs_dir3_free_hdr_to_disk(free, &freehdr);
-       xfs_dir2_free_log_header(tp, fbp);
+       dp->d_ops->free_hdr_to_disk(free, &freehdr);
+       xfs_dir2_free_log_header(tp, dp, fbp);
 
        /*
         * If there are no useful entries left in the block, get rid of the
@@ -1181,7 +1141,7 @@ xfs_dir3_data_block_free(
 
        /* Log the free entry that changed, unless we got rid of it.  */
        if (logfree)
-               xfs_dir2_free_log_bests(tp, fbp, findex, findex);
+               xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex);
        return 0;
 }
 
@@ -1221,8 +1181,8 @@ xfs_dir2_leafn_remove(
        tp = args->trans;
        mp = dp->i_mount;
        leaf = bp->b_addr;
-       xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
-       ents = xfs_dir3_leaf_ents_p(leaf);
+       dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
+       ents = dp->d_ops->leaf_ents_p(leaf);
 
        /*
         * Point to the entry we're removing.
@@ -1242,11 +1202,11 @@ xfs_dir2_leafn_remove(
         * Log the leaf block changes.
         */
        leafhdr.stale++;
-       xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr);
-       xfs_dir3_leaf_log_header(tp, bp);
+       dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
+       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
@@ -1284,7 +1244,7 @@ xfs_dir2_leafn_remove(
                 * Convert the data block number to a free block,
                 * read in the free block.
                 */
-               fdb = xfs_dir2_db_to_fdb(mp, db);
+               fdb = dp->d_ops->db_to_fdb(mp, db);
                error = xfs_dir2_free_read(tp, dp, xfs_dir2_db_to_da(mp, fdb),
                                           &fbp);
                if (error)
@@ -1293,22 +1253,22 @@ xfs_dir2_leafn_remove(
 #ifdef DEBUG
        {
                struct xfs_dir3_icfree_hdr freehdr;
-               xfs_dir3_free_hdr_from_disk(&freehdr, free);
-               ASSERT(freehdr.firstdb == xfs_dir3_free_max_bests(mp) *
+               dp->d_ops->free_hdr_from_disk(&freehdr, free);
+               ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(mp) *
                                          (fdb - XFS_DIR2_FREE_FIRSTDB(mp)));
        }
 #endif
                /*
                 * Calculate which entry we need to fix.
                 */
-               findex = xfs_dir2_db_to_fdindex(mp, db);
+               findex = dp->d_ops->db_to_fdindex(mp, db);
                longest = be16_to_cpu(bf[0].length);
                /*
                 * If the data block is now empty we can get rid of it
                 * (usually).
                 */
                if (longest == mp->m_dirblksize -
-                              dp->d_ops->data_entry_offset()) {
+                              dp->d_ops->data_entry_offset) {
                        /*
                         * Try to punch out the data block.
                         */
@@ -1335,12 +1295,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;
@@ -1359,13 +1319,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;
-       ASSERT(args != NULL);
+       dp = args->dp;
+       mp = dp->i_mount;
        ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC);
        error = xfs_da_grow_inode(args, &blkno);
        if (error) {
@@ -1400,10 +1361,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;
 }
 
@@ -1433,6 +1394,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.
@@ -1441,12 +1403,12 @@ 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);
+       dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
+       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.
@@ -1491,7 +1453,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;
@@ -1503,8 +1465,8 @@ xfs_dir2_leafn_toosmall(
                bytes = state->blocksize - (state->blocksize >> 2);
 
                leaf = bp->b_addr;
-               xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf);
-               ents = xfs_dir3_leaf_ents_p(leaf);
+               dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf);
+               ents = dp->d_ops->leaf_ents_p(leaf);
                count += hdr2.count - hdr2.stale;
                bytes -= count * sizeof(ents[0]);
 
@@ -1558,6 +1520,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);
@@ -1565,10 +1528,10 @@ xfs_dir2_leafn_unbalance(
        drop_leaf = drop_blk->bp->b_addr;
        save_leaf = save_blk->bp->b_addr;
 
-       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);
+       dp->d_ops->leaf_hdr_from_disk(&savehdr, save_leaf);
+       dp->d_ops->leaf_hdr_from_disk(&drophdr, drop_leaf);
+       sents = dp->d_ops->leaf_ents_p(save_leaf);
+       dents = dp->d_ops->leaf_ents_p(drop_leaf);
 
        /*
         * If there are any stale leaf entries, take this opportunity
@@ -1583,7 +1546,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);
@@ -1594,13 +1557,13 @@ xfs_dir2_leafn_unbalance(
        save_blk->hashval = be32_to_cpu(sents[savehdr.count - 1].hashval);
 
        /* 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);
+       dp->d_ops->leaf_hdr_to_disk(save_leaf, &savehdr);
+       dp->d_ops->leaf_hdr_to_disk(drop_leaf, &drophdr);
+       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);
 }
 
 /*
@@ -1725,8 +1688,8 @@ xfs_dir2_node_addname_int(
                ifbno = fblk->blkno;
                free = fbp->b_addr;
                findex = fblk->index;
-               bests = xfs_dir3_free_bests_p(mp, free);
-               xfs_dir3_free_hdr_from_disk(&freehdr, free);
+               bests = dp->d_ops->free_bests_p(free);
+               dp->d_ops->free_hdr_from_disk(&freehdr, free);
 
                /*
                 * This means the free entry showed that the data block had
@@ -1818,8 +1781,8 @@ xfs_dir2_node_addname_int(
                 * and the freehdr are actually initialised if they are placed
                 * there, so we have to do it here to avoid warnings. Blech.
                 */
-               bests = xfs_dir3_free_bests_p(mp, free);
-               xfs_dir3_free_hdr_from_disk(&freehdr, free);
+               bests = dp->d_ops->free_bests_p(free);
+               dp->d_ops->free_hdr_from_disk(&freehdr, free);
                if (be16_to_cpu(bests[findex]) != NULLDATAOFF &&
                    be16_to_cpu(bests[findex]) >= length)
                        dbno = freehdr.firstdb + findex;
@@ -1870,7 +1833,7 @@ xfs_dir2_node_addname_int(
                 * Get the freespace block corresponding to the data block
                 * that was just allocated.
                 */
-               fbno = xfs_dir2_db_to_fdb(mp, dbno);
+               fbno = dp->d_ops->db_to_fdb(mp, dbno);
                error = xfs_dir2_free_try_read(tp, dp,
                                               xfs_dir2_db_to_da(mp, fbno),
                                               &fbp);
@@ -1887,12 +1850,12 @@ xfs_dir2_node_addname_int(
                        if (error)
                                return error;
 
-                       if (unlikely(xfs_dir2_db_to_fdb(mp, dbno) != fbno)) {
+                       if (unlikely(dp->d_ops->db_to_fdb(mp, dbno) != fbno)) {
                                xfs_alert(mp,
                        "%s: dir ino %llu needed freesp block %lld for\n"
                        "  data block %lld, got %lld ifbno %llu lastfbno %d",
                                        __func__, (unsigned long long)dp->i_ino,
-                                       (long long)xfs_dir2_db_to_fdb(mp, dbno),
+                                       (long long)dp->d_ops->db_to_fdb(mp, dbno),
                                        (long long)dbno, (long long)fbno,
                                        (unsigned long long)ifbno, lastfbno);
                                if (fblk) {
@@ -1917,30 +1880,30 @@ xfs_dir2_node_addname_int(
                        if (error)
                                return error;
                        free = fbp->b_addr;
-                       bests = xfs_dir3_free_bests_p(mp, free);
-                       xfs_dir3_free_hdr_from_disk(&freehdr, free);
+                       bests = dp->d_ops->free_bests_p(free);
+                       dp->d_ops->free_hdr_from_disk(&freehdr, free);
 
                        /*
                         * Remember the first slot as our empty slot.
                         */
                        freehdr.firstdb = (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) *
-                                       xfs_dir3_free_max_bests(mp);
+                                       dp->d_ops->free_max_bests(mp);
                } else {
                        free = fbp->b_addr;
-                       bests = xfs_dir3_free_bests_p(mp, free);
-                       xfs_dir3_free_hdr_from_disk(&freehdr, free);
+                       bests = dp->d_ops->free_bests_p(free);
+                       dp->d_ops->free_hdr_from_disk(&freehdr, free);
                }
 
                /*
                 * Set the freespace block index from the data block number.
                 */
-               findex = xfs_dir2_db_to_fdindex(mp, dbno);
+               findex = dp->d_ops->db_to_fdindex(mp, dbno);
                /*
                 * If it's after the end of the current entries in the
                 * freespace block, extend that table.
                 */
                if (findex >= freehdr.nvalid) {
-                       ASSERT(findex < xfs_dir3_free_max_bests(mp));
+                       ASSERT(findex < dp->d_ops->free_max_bests(mp));
                        freehdr.nvalid = findex + 1;
                        /*
                         * Tag new entry so nused will go up.
@@ -1953,8 +1916,8 @@ xfs_dir2_node_addname_int(
                 */
                if (bests[findex] == cpu_to_be16(NULLDATAOFF)) {
                        freehdr.nused++;
-                       xfs_dir3_free_hdr_to_disk(fbp->b_addr, &freehdr);
-                       xfs_dir2_free_log_header(tp, fbp);
+                       dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
+                       xfs_dir2_free_log_header(tp, dp, fbp);
                }
                /*
                 * Update the real value in the table.
@@ -2024,7 +1987,7 @@ xfs_dir2_node_addname_int(
        /*
         * If the freespace entry is now wrong, update it.
         */
-       bests = xfs_dir3_free_bests_p(mp, free); /* gcc is so stupid */
+       bests = dp->d_ops->free_bests_p(free); /* gcc is so stupid */
        if (be16_to_cpu(bests[findex]) != be16_to_cpu(bf[0].length)) {
                bests[findex] = bf[0].length;
                logfree = 1;
@@ -2033,7 +1996,7 @@ xfs_dir2_node_addname_int(
         * Log the freespace entry if needed.
         */
        if (logfree)
-               xfs_dir2_free_log_bests(tp, fbp, findex, findex);
+               xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex);
        /*
         * Return the data block and offset in args, then drop the data block.
         */
@@ -2211,7 +2174,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);
                /*
@@ -2285,7 +2248,7 @@ xfs_dir2_node_trim_free(
        if (!bp)
                return 0;
        free = bp->b_addr;
-       xfs_dir3_free_hdr_from_disk(&freehdr, free);
+       dp->d_ops->free_hdr_from_disk(&freehdr, free);
 
        /*
         * If there are used entries, there's nothing to do.