]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/xfs_dir2_leaf.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
[linux-2.6-omap-h63xx.git] / fs / xfs / xfs_dir2_leaf.c
index 9abecd207c4e6af2a6494726664dbaf520c98bf1..0f5e2f2ce6ec468afb5e545456b9915908ac482c 100644 (file)
@@ -111,14 +111,14 @@ xfs_dir2_block_to_leaf(
        /*
         * Set the counts in the leaf header.
         */
-       INT_COPY(leaf->hdr.count, btp->count, ARCH_CONVERT); /* INT_: type change */
-       INT_COPY(leaf->hdr.stale, btp->stale, ARCH_CONVERT); /* INT_: type change */
+       leaf->hdr.count = cpu_to_be16(be32_to_cpu(btp->count));
+       leaf->hdr.stale = cpu_to_be16(be32_to_cpu(btp->stale));
        /*
         * Could compact these but I think we always do the conversion
         * after squeezing out stale entries.
         */
-       memcpy(leaf->ents, blp, INT_GET(btp->count, ARCH_CONVERT) * sizeof(xfs_dir2_leaf_entry_t));
-       xfs_dir2_leaf_log_ents(tp, lbp, 0, INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1);
+       memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t));
+       xfs_dir2_leaf_log_ents(tp, lbp, 0, be16_to_cpu(leaf->hdr.count) - 1);
        needscan = 0;
        needlog = 1;
        /*
@@ -187,7 +187,7 @@ xfs_dir2_leaf_addname(
        int                     needbytes;      /* leaf block bytes needed */
        int                     needlog;        /* need to log data header */
        int                     needscan;       /* need to rescan data free */
-       xfs_dir2_data_off_t     *tagp;          /* end of data entry */
+       __be16                  *tagp;          /* end of data entry */
        xfs_trans_t             *tp;            /* transaction pointer */
        xfs_dir2_db_t           use_block;      /* data block number */
 
@@ -222,11 +222,11 @@ xfs_dir2_leaf_addname(
         * in a data block, improving the lookup of those entries.
         */
        for (use_block = -1, lep = &leaf->ents[index];
-            index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
+            index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval;
             index++, lep++) {
-               if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+               if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
                        continue;
-               i = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT));
+               i = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address));
                ASSERT(i < be32_to_cpu(ltp->bestcount));
                ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF);
                if (be16_to_cpu(bestsp[i]) >= length) {
@@ -266,15 +266,15 @@ xfs_dir2_leaf_addname(
         * If we don't have enough free bytes but we can make enough
         * by compacting out stale entries, we'll do that.
         */
-       if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < needbytes &&
-           INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1) {
+       if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < needbytes &&
+           be16_to_cpu(leaf->hdr.stale) > 1) {
                compact = 1;
        }
        /*
         * Otherwise if we don't have enough free bytes we need to
         * convert to node form.
         */
-       else if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] <
+       else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <
                 needbytes) {
                /*
                 * Just checking or no space reservation, give up.
@@ -330,8 +330,8 @@ xfs_dir2_leaf_addname(
         * There are stale entries, so we'll need log-low and log-high
         * impossibly bad values later.
         */
-       else if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) {
-               lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+       else if (be16_to_cpu(leaf->hdr.stale)) {
+               lfloglow = be16_to_cpu(leaf->hdr.count);
                lfloghigh = -1;
        }
        /*
@@ -395,7 +395,7 @@ xfs_dir2_leaf_addname(
         */
        dup = (xfs_dir2_data_unused_t *)
              ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
-       ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length);
+       ASSERT(be16_to_cpu(dup->length) >= length);
        needscan = needlog = 0;
        /*
         * Mark the initial part of our freespace in use for the new entry.
@@ -411,7 +411,7 @@ xfs_dir2_leaf_addname(
        dep->namelen = args->namelen;
        memcpy(dep->name, args->name, dep->namelen);
        tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
-       INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)data));
+       *tagp = cpu_to_be16((char *)dep - (char *)data);
        /*
         * Need to scan fix up the bestfree table.
         */
@@ -440,15 +440,15 @@ xfs_dir2_leaf_addname(
                /*
                 * lep is still good as the index leaf entry.
                 */
-               if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT))
+               if (index < be16_to_cpu(leaf->hdr.count))
                        memmove(lep + 1, lep,
-                               (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep));
+                               (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
                /*
                 * Record low and high logging indices for the leaf.
                 */
                lfloglow = index;
-               lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT);
-               INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1);
+               lfloghigh = be16_to_cpu(leaf->hdr.count);
+               be16_add(&leaf->hdr.count, 1);
        }
        /*
         * There are stale entries.
@@ -468,7 +468,7 @@ xfs_dir2_leaf_addname(
                         */
                        for (lowstale = index - 1;
                             lowstale >= 0 &&
-                               INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) !=
+                               be32_to_cpu(leaf->ents[lowstale].address) !=
                                XFS_DIR2_NULL_DATAPTR;
                             lowstale--)
                                continue;
@@ -478,8 +478,8 @@ xfs_dir2_leaf_addname(
                         * lowstale entry would be better.
                         */
                        for (highstale = index;
-                            highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) &&
-                               INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) !=
+                            highstale < be16_to_cpu(leaf->hdr.count) &&
+                               be32_to_cpu(leaf->ents[highstale].address) !=
                                XFS_DIR2_NULL_DATAPTR &&
                                (lowstale < 0 ||
                                 index - lowstale - 1 >= highstale - index);
@@ -490,10 +490,10 @@ xfs_dir2_leaf_addname(
                 * If the low one is better, use it.
                 */
                if (lowstale >= 0 &&
-                   (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) ||
+                   (highstale == be16_to_cpu(leaf->hdr.count) ||
                     index - lowstale - 1 < highstale - index)) {
                        ASSERT(index - lowstale - 1 >= 0);
-                       ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) ==
+                       ASSERT(be32_to_cpu(leaf->ents[lowstale].address) ==
                               XFS_DIR2_NULL_DATAPTR);
                        /*
                         * Copy entries up to cover the stale entry
@@ -512,10 +512,10 @@ xfs_dir2_leaf_addname(
                 */
                else {
                        ASSERT(highstale - index >= 0);
-                       ASSERT(INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) ==
+                       ASSERT(be32_to_cpu(leaf->ents[highstale].address) ==
                               XFS_DIR2_NULL_DATAPTR);
                        /*
-                        * Copy entries down to copver the stale entry
+                        * Copy entries down to cover the stale entry
                         * and make room for the new entry.
                         */
                        if (highstale - index > 0)
@@ -526,13 +526,14 @@ xfs_dir2_leaf_addname(
                        lfloglow = MIN(index, lfloglow);
                        lfloghigh = MAX(highstale, lfloghigh);
                }
-               INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1);
+               be16_add(&leaf->hdr.stale, -1);
        }
        /*
         * Fill in the new leaf entry.
         */
-       INT_SET(lep->hashval, ARCH_CONVERT, args->hashval);
-       INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block, INT_GET(*tagp, ARCH_CONVERT)));
+       lep->hashval = cpu_to_be32(args->hashval);
+       lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block,
+                               be16_to_cpu(*tagp)));
        /*
         * Log the leaf fields and give up the buffers.
         */
@@ -563,30 +564,30 @@ xfs_dir2_leaf_check(
 
        leaf = bp->data;
        mp = dp->i_mount;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
        /*
         * 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.
         */
-       ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
+       ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
        ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
        /*
         * Leaves and bests don't overlap.
         */
-       ASSERT((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] <=
+       ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <=
               (char *)XFS_DIR2_LEAF_BESTS_P(ltp));
        /*
         * Check hash value order, count stale entries.
         */
-       for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) {
-               if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT))
-                       ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <=
-                              INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT));
-               if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+       for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
+               if (i + 1 < be16_to_cpu(leaf->hdr.count))
+                       ASSERT(be32_to_cpu(leaf->ents[i].hashval) <=
+                              be32_to_cpu(leaf->ents[i + 1].hashval));
+               if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR)
                        stale++;
        }
-       ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale);
+       ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
 }
 #endif /* DEBUG */
 
@@ -611,8 +612,8 @@ xfs_dir2_leaf_compact(
        /*
         * Compress out the stale entries in place.
         */
-       for (from = to = 0, loglow = -1; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) {
-               if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+       for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) {
+               if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR)
                        continue;
                /*
                 * Only actually copy the entries that are different.
@@ -627,8 +628,8 @@ xfs_dir2_leaf_compact(
        /*
         * Update and log the header, log the leaf entries.
         */
-       ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == from - to);
-       INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(INT_GET(leaf->hdr.stale, ARCH_CONVERT)));
+       ASSERT(be16_to_cpu(leaf->hdr.stale) == from - to);
+       be16_add(&leaf->hdr.count, -(be16_to_cpu(leaf->hdr.stale)));
        leaf->hdr.stale = 0;
        xfs_dir2_leaf_log_header(args->trans, bp);
        if (loglow != -1)
@@ -662,14 +663,14 @@ xfs_dir2_leaf_compact_x1(
        int             to;             /* destination copy index */
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1);
+       ASSERT(be16_to_cpu(leaf->hdr.stale) > 1);
        index = *indexp;
        /*
         * Find the first stale entry before our index, if any.
         */
        for (lowstale = index - 1;
             lowstale >= 0 &&
-               INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR;
+               be32_to_cpu(leaf->ents[lowstale].address) != XFS_DIR2_NULL_DATAPTR;
             lowstale--)
                continue;
        /*
@@ -677,8 +678,8 @@ xfs_dir2_leaf_compact_x1(
         * Stop if the answer would be worse than lowstale.
         */
        for (highstale = index;
-            highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) &&
-               INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR &&
+            highstale < be16_to_cpu(leaf->hdr.count) &&
+               be32_to_cpu(leaf->ents[highstale].address) != XFS_DIR2_NULL_DATAPTR &&
                (lowstale < 0 || index - lowstale > highstale - index);
             highstale++)
                continue;
@@ -686,7 +687,7 @@ xfs_dir2_leaf_compact_x1(
         * Pick the better of lowstale and highstale.
         */
        if (lowstale >= 0 &&
-           (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) ||
+           (highstale == be16_to_cpu(leaf->hdr.count) ||
             index - lowstale <= highstale - index))
                keepstale = lowstale;
        else
@@ -695,14 +696,14 @@ xfs_dir2_leaf_compact_x1(
         * Copy the entries in place, removing all the stale entries
         * except keepstale.
         */
-       for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) {
+       for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) {
                /*
                 * Notice the new value of index.
                 */
                if (index == from)
                        newindex = to;
                if (from != keepstale &&
-                   INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) {
+                   be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) {
                        if (from == to)
                                *lowlogp = to;
                        continue;
@@ -730,8 +731,8 @@ xfs_dir2_leaf_compact_x1(
        /*
         * Adjust the leaf header values.
         */
-       INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(from - to));
-       INT_SET(leaf->hdr.stale, ARCH_CONVERT, 1);
+       be16_add(&leaf->hdr.count, -(from - to));
+       leaf->hdr.stale = cpu_to_be16(1);
        /*
         * Remember the low/high stale value only in the "right"
         * direction.
@@ -739,8 +740,8 @@ xfs_dir2_leaf_compact_x1(
        if (lowstale >= newindex)
                lowstale = -1;
        else
-               highstale = INT_GET(leaf->hdr.count, ARCH_CONVERT);
-       *highlogp = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1;
+               highstale = be16_to_cpu(leaf->hdr.count);
+       *highlogp = be16_to_cpu(leaf->hdr.count) - 1;
        *lowstalep = lowstale;
        *highstalep = highstale;
 }
@@ -1047,11 +1048,10 @@ xfs_dir2_leaf_getdents(
                                while ((char *)ptr - (char *)data < byteoff) {
                                        dup = (xfs_dir2_data_unused_t *)ptr;
 
-                                       if (INT_GET(dup->freetag, ARCH_CONVERT)
+                                       if (be16_to_cpu(dup->freetag)
                                                  == XFS_DIR2_DATA_FREE_TAG) {
 
-                                               length = INT_GET(dup->length,
-                                                                ARCH_CONVERT);
+                                               length = be16_to_cpu(dup->length);
                                                ptr += length;
                                                continue;
                                        }
@@ -1080,9 +1080,8 @@ xfs_dir2_leaf_getdents(
                /*
                 * No, it's unused, skip over it.
                 */
-               if (INT_GET(dup->freetag, ARCH_CONVERT)
-                                               == XFS_DIR2_DATA_FREE_TAG) {
-                       length = INT_GET(dup->length, ARCH_CONVERT);
+               if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+                       length = be16_to_cpu(dup->length);
                        ptr += length;
                        curoff += length;
                        continue;
@@ -1173,7 +1172,7 @@ xfs_dir2_leaf_init(
        /*
         * Initialize the header.
         */
-       INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, magic);
+       leaf->hdr.info.magic = cpu_to_be16(magic);
        leaf->hdr.info.forw = 0;
        leaf->hdr.info.back = 0;
        leaf->hdr.count = 0;
@@ -1209,7 +1208,7 @@ xfs_dir2_leaf_log_bests(
        xfs_dir2_leaf_tail_t    *ltp;           /* leaf tail structure */
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
        ltp = XFS_DIR2_LEAF_TAIL_P(tp->t_mountp, leaf);
        firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first;
        lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last;
@@ -1232,8 +1231,8 @@ xfs_dir2_leaf_log_ents(
        xfs_dir2_leaf_t         *leaf;          /* leaf structure */
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC ||
-              INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
+              be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
        firstlep = &leaf->ents[first];
        lastlep = &leaf->ents[last];
        xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf),
@@ -1251,8 +1250,8 @@ xfs_dir2_leaf_log_header(
        xfs_dir2_leaf_t         *leaf;          /* leaf structure */
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC ||
-              INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
+              be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
        xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf),
                (uint)(sizeof(leaf->hdr) - 1));
 }
@@ -1271,7 +1270,7 @@ xfs_dir2_leaf_log_tail(
 
        mp = tp->t_mountp;
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
        ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
        xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
                (uint)(mp->m_dirblksize - 1));
@@ -1316,7 +1315,7 @@ xfs_dir2_leaf_lookup(
         */
        dep = (xfs_dir2_data_entry_t *)
              ((char *)dbp->data +
-              XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT)));
+              XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address)));
        /*
         * Return the found inode number.
         */
@@ -1375,17 +1374,17 @@ xfs_dir2_leaf_lookup_int(
         * looking to match the name.
         */
        for (lep = &leaf->ents[index], dbp = NULL, curdb = -1;
-            index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
+            index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval;
             lep++, index++) {
                /*
                 * Skip over stale leaf entries.
                 */
-               if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+               if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
                        continue;
                /*
                 * Get the new data block number.
                 */
-               newdb = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT));
+               newdb = XFS_DIR2_DATAPTR_TO_DB(mp, 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.
@@ -1408,7 +1407,7 @@ xfs_dir2_leaf_lookup_int(
                 */
                dep = (xfs_dir2_data_entry_t *)
                      ((char *)dbp->data +
-                      XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)));
+                      XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address)));
                /*
                 * If it matches then return it.
                 */
@@ -1473,9 +1472,9 @@ xfs_dir2_leaf_removename(
         * Point to the leaf entry, use that to point to the data entry.
         */
        lep = &leaf->ents[index];
-       db = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT));
+       db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address));
        dep = (xfs_dir2_data_entry_t *)
-             ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)));
+             ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address)));
        needscan = needlog = 0;
        oldbest = be16_to_cpu(data->hdr.bestfree[0].length);
        ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
@@ -1490,9 +1489,9 @@ xfs_dir2_leaf_removename(
        /*
         * We just mark the leaf entry stale by putting a null in it.
         */
-       INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1);
+       be16_add(&leaf->hdr.stale, 1);
        xfs_dir2_leaf_log_header(tp, lbp);
-       INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR);
+       lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
        xfs_dir2_leaf_log_ents(tp, lbp, index, index);
        /*
         * Scan the freespace in the data block again if necessary,
@@ -1606,7 +1605,7 @@ xfs_dir2_leaf_replace(
         */
        dep = (xfs_dir2_data_entry_t *)
              ((char *)dbp->data +
-              XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT)));
+              XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address)));
        ASSERT(args->inumber != INT_GET(dep->inumber, ARCH_CONVERT));
        /*
         * Put the new inode number in, log it.
@@ -1647,11 +1646,11 @@ xfs_dir2_leaf_search_hash(
         * Note, the table cannot be empty, so we have to go through the loop.
         * Binary search the leaf entries looking for our hash value.
         */
-       for (lep = leaf->ents, low = 0, high = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1,
+       for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1,
                hashwant = args->hashval;
             low <= high; ) {
                mid = (low + high) >> 1;
-               if ((hash = INT_GET(lep[mid].hashval, ARCH_CONVERT)) == hashwant)
+               if ((hash = be32_to_cpu(lep[mid].hashval)) == hashwant)
                        break;
                if (hash < hashwant)
                        low = mid + 1;
@@ -1662,7 +1661,7 @@ xfs_dir2_leaf_search_hash(
         * Found one, back up through all the equal hash values.
         */
        if (hash == hashwant) {
-               while (mid > 0 && INT_GET(lep[mid - 1].hashval, ARCH_CONVERT) == hashwant) {
+               while (mid > 0 && be32_to_cpu(lep[mid - 1].hashval) == hashwant) {
                        mid--;
                }
        }
@@ -1807,7 +1806,7 @@ xfs_dir2_node_to_leaf(
                return 0;
        lbp = state->path.blk[0].bp;
        leaf = lbp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
        /*
         * Read the freespace block.
         */
@@ -1823,7 +1822,7 @@ xfs_dir2_node_to_leaf(
         * If not, release the buffer and give up.
         */
        if ((uint)sizeof(leaf->hdr) +
-           (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)) * (uint)sizeof(leaf->ents[0]) +
+           (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)) * (uint)sizeof(leaf->ents[0]) +
            be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) +
            (uint)sizeof(leaf->tail) >
            mp->m_dirblksize) {
@@ -1834,11 +1833,11 @@ xfs_dir2_node_to_leaf(
         * If the leaf has any stale entries in it, compress them out.
         * The compact routine will log the header.
         */
-       if (INT_GET(leaf->hdr.stale, ARCH_CONVERT))
+       if (be16_to_cpu(leaf->hdr.stale))
                xfs_dir2_leaf_compact(args, lbp);
        else
                xfs_dir2_leaf_log_header(tp, lbp);
-       INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAF1_MAGIC);
+       leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAF1_MAGIC);
        /*
         * Set up the leaf tail from the freespace block.
         */