sysctl fs: Remove dead binary sysctl support
[safe/jmp/linux-2.6] / fs / xfs / xfs_dir2_data.c
index 48b4906..498f8d6 100644 (file)
 #include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
-#include "xfs_dir.h"
+#include "xfs_ag.h"
 #include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
 #include "xfs_da_btree.h"
 #include "xfs_bmap_btree.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
 #include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
 #include "xfs_inode.h"
-#include "xfs_dir_leaf.h"
 #include "xfs_dir2_data.h"
 #include "xfs_dir2_leaf.h"
 #include "xfs_dir2_block.h"
@@ -67,6 +65,7 @@ xfs_dir2_data_check(
        xfs_mount_t             *mp;            /* filesystem mount point */
        char                    *p;             /* current data position */
        int                     stale;          /* count of stale leaves */
+       struct xfs_name         name;
 
        mp = dp->i_mount;
        d = bp->data;
@@ -75,8 +74,8 @@ xfs_dir2_data_check(
        bf = d->hdr.bestfree;
        p = (char *)d->u;
        if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
-               btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d);
-               lep = XFS_DIR2_BLOCK_LEAF_P(btp);
+               btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d);
+               lep = xfs_dir2_block_leaf_p(btp);
                endp = (char *)lep;
        } else
                endp = (char *)d + mp->m_dirblksize;
@@ -110,7 +109,7 @@ xfs_dir2_data_check(
                 */
                if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
                        ASSERT(lastfree == 0);
-                       ASSERT(INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT) ==
+                       ASSERT(be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) ==
                               (char *)dup - (char *)d);
                        dfp = xfs_dir2_data_freefind(d, dup);
                        if (dfp) {
@@ -133,38 +132,40 @@ xfs_dir2_data_check(
                 */
                dep = (xfs_dir2_data_entry_t *)p;
                ASSERT(dep->namelen != 0);
-               ASSERT(xfs_dir_ino_validate(mp, INT_GET(dep->inumber, ARCH_CONVERT)) == 0);
-               ASSERT(INT_GET(*XFS_DIR2_DATA_ENTRY_TAG_P(dep), ARCH_CONVERT) ==
+               ASSERT(xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber)) == 0);
+               ASSERT(be16_to_cpu(*xfs_dir2_data_entry_tag_p(dep)) ==
                       (char *)dep - (char *)d);
                count++;
                lastfree = 0;
                if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
-                       addr = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk,
+                       addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
                                (xfs_dir2_data_aoff_t)
                                ((char *)dep - (char *)d));
-                       hash = xfs_da_hashname((char *)dep->name, dep->namelen);
-                       for (i = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) {
-                               if (INT_GET(lep[i].address, ARCH_CONVERT) == addr &&
-                                   INT_GET(lep[i].hashval, ARCH_CONVERT) == hash)
+                       name.name = dep->name;
+                       name.len = dep->namelen;
+                       hash = mp->m_dirnameops->hashname(&name);
+                       for (i = 0; i < be32_to_cpu(btp->count); i++) {
+                               if (be32_to_cpu(lep[i].address) == addr &&
+                                   be32_to_cpu(lep[i].hashval) == hash)
                                        break;
                        }
-                       ASSERT(i < INT_GET(btp->count, ARCH_CONVERT));
+                       ASSERT(i < be32_to_cpu(btp->count));
                }
-               p += XFS_DIR2_DATA_ENTSIZE(dep->namelen);
+               p += xfs_dir2_data_entsize(dep->namelen);
        }
        /*
         * Need to have seen all the entries and all the bestfree slots.
         */
        ASSERT(freeseen == 7);
        if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
-               for (i = stale = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) {
-                       if (INT_GET(lep[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+               for (i = stale = 0; i < be32_to_cpu(btp->count); i++) {
+                       if (be32_to_cpu(lep[i].address) == XFS_DIR2_NULL_DATAPTR)
                                stale++;
                        if (i > 0)
-                               ASSERT(INT_GET(lep[i].hashval, ARCH_CONVERT) >= INT_GET(lep[i - 1].hashval, ARCH_CONVERT));
+                               ASSERT(be32_to_cpu(lep[i].hashval) >= be32_to_cpu(lep[i - 1].hashval));
                }
-               ASSERT(count == INT_GET(btp->count, ARCH_CONVERT) - INT_GET(btp->stale, ARCH_CONVERT));
-               ASSERT(stale == INT_GET(btp->stale, ARCH_CONVERT));
+               ASSERT(count == be32_to_cpu(btp->count) - be32_to_cpu(btp->stale));
+               ASSERT(stale == be32_to_cpu(btp->stale));
        }
 }
 #endif
@@ -327,8 +328,7 @@ void
 xfs_dir2_data_freescan(
        xfs_mount_t             *mp,            /* filesystem mount point */
        xfs_dir2_data_t         *d,             /* data block pointer */
-       int                     *loghead,       /* out: log data header */
-       char                    *aendp)         /* in: caller's endp */
+       int                     *loghead)       /* out: log data header */
 {
        xfs_dir2_block_tail_t   *btp;           /* block tail */
        xfs_dir2_data_entry_t   *dep;           /* active data entry */
@@ -349,11 +349,9 @@ xfs_dir2_data_freescan(
         * Set up pointers.
         */
        p = (char *)d->u;
-       if (aendp)
-               endp = aendp;
-       else if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
-               btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d);
-               endp = (char *)XFS_DIR2_BLOCK_LEAF_P(btp);
+       if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
+               btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d);
+               endp = (char *)xfs_dir2_block_leaf_p(btp);
        } else
                endp = (char *)d + mp->m_dirblksize;
        /*
@@ -366,7 +364,7 @@ xfs_dir2_data_freescan(
                 */
                if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
                        ASSERT((char *)dup - (char *)d ==
-                              INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT));
+                              be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)));
                        xfs_dir2_data_freeinsert(d, dup, loghead);
                        p += be16_to_cpu(dup->length);
                }
@@ -376,8 +374,8 @@ xfs_dir2_data_freescan(
                else {
                        dep = (xfs_dir2_data_entry_t *)p;
                        ASSERT((char *)dep - (char *)d ==
-                              INT_GET(*XFS_DIR2_DATA_ENTRY_TAG_P(dep), ARCH_CONVERT));
-                       p += XFS_DIR2_DATA_ENTSIZE(dep->namelen);
+                              be16_to_cpu(*xfs_dir2_data_entry_tag_p(dep)));
+                       p += xfs_dir2_data_entsize(dep->namelen);
                }
        }
 }
@@ -408,7 +406,7 @@ xfs_dir2_data_init(
        /*
         * Get the buffer set up for the block.
         */
-       error = xfs_da_get_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, blkno), -1, &bp,
+       error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, blkno), -1, &bp,
                XFS_DATA_FORK);
        if (error) {
                return error;
@@ -433,8 +431,7 @@ xfs_dir2_data_init(
        t=mp->m_dirblksize - (uint)sizeof(d->hdr);
        d->hdr.bestfree[0].length = cpu_to_be16(t);
        dup->length = cpu_to_be16(t);
-       INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT,
-               (xfs_dir2_data_off_t)((char *)dup - (char *)d));
+       *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)d);
        /*
         * Log it and return it.
         */
@@ -459,7 +456,7 @@ xfs_dir2_data_log_entry(
        ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
               be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
        xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d),
-               (uint)((char *)(XFS_DIR2_DATA_ENTRY_TAG_P(dep) + 1) -
+               (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) -
                       (char *)d - 1));
 }
 
@@ -504,8 +501,8 @@ xfs_dir2_data_log_unused(
         * Log the end (tag) of the unused entry.
         */
        xfs_da_log_buf(tp, bp,
-               (uint)((char *)XFS_DIR2_DATA_UNUSED_TAG_P(dup) - (char *)d),
-               (uint)((char *)XFS_DIR2_DATA_UNUSED_TAG_P(dup) - (char *)d +
+               (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)d),
+               (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)d +
                       sizeof(xfs_dir2_data_off_t) - 1));
 }
 
@@ -542,18 +539,18 @@ xfs_dir2_data_make_free(
                xfs_dir2_block_tail_t   *btp;   /* block tail */
 
                ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
-               btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d);
-               endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp);
+               btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d);
+               endptr = (char *)xfs_dir2_block_leaf_p(btp);
        }
        /*
         * If this isn't the start of the block, then back up to
         * the previous entry and see if it's free.
         */
        if (offset > sizeof(d->hdr)) {
-               xfs_dir2_data_off_t     *tagp;  /* tag just before us */
+               __be16                  *tagp;  /* tag just before us */
 
-               tagp = (xfs_dir2_data_off_t *)((char *)d + offset) - 1;
-               prevdup = (xfs_dir2_data_unused_t *)((char *)d + INT_GET(*tagp, ARCH_CONVERT));
+               tagp = (__be16 *)((char *)d + offset) - 1;
+               prevdup = (xfs_dir2_data_unused_t *)((char *)d + be16_to_cpu(*tagp));
                if (be16_to_cpu(prevdup->freetag) != XFS_DIR2_DATA_FREE_TAG)
                        prevdup = NULL;
        } else
@@ -593,9 +590,9 @@ xfs_dir2_data_make_free(
                /*
                 * Fix up the new big freespace.
                 */
-               be16_add(&prevdup->length, len + be16_to_cpu(postdup->length));
-               INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT,
-                       (xfs_dir2_data_off_t)((char *)prevdup - (char *)d));
+               be16_add_cpu(&prevdup->length, len + be16_to_cpu(postdup->length));
+               *xfs_dir2_data_unused_tag_p(prevdup) =
+                       cpu_to_be16((char *)prevdup - (char *)d);
                xfs_dir2_data_log_unused(tp, bp, prevdup);
                if (!needscan) {
                        /*
@@ -627,9 +624,9 @@ xfs_dir2_data_make_free(
         */
        else if (prevdup) {
                dfp = xfs_dir2_data_freefind(d, prevdup);
-               be16_add(&prevdup->length, len);
-               INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT,
-                       (xfs_dir2_data_off_t)((char *)prevdup - (char *)d));
+               be16_add_cpu(&prevdup->length, len);
+               *xfs_dir2_data_unused_tag_p(prevdup) =
+                       cpu_to_be16((char *)prevdup - (char *)d);
                xfs_dir2_data_log_unused(tp, bp, prevdup);
                /*
                 * If the previous entry was in the table, the new entry
@@ -656,8 +653,8 @@ xfs_dir2_data_make_free(
                newdup = (xfs_dir2_data_unused_t *)((char *)d + offset);
                newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
                newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length));
-               INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
-                       (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+               *xfs_dir2_data_unused_tag_p(newdup) =
+                       cpu_to_be16((char *)newdup - (char *)d);
                xfs_dir2_data_log_unused(tp, bp, newdup);
                /*
                 * If the following entry was in the table, the new entry
@@ -683,8 +680,8 @@ xfs_dir2_data_make_free(
                newdup = (xfs_dir2_data_unused_t *)((char *)d + offset);
                newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
                newdup->length = cpu_to_be16(len);
-               INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
-                       (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+               *xfs_dir2_data_unused_tag_p(newdup) =
+                       cpu_to_be16((char *)newdup - (char *)d);
                xfs_dir2_data_log_unused(tp, bp, newdup);
                (void)xfs_dir2_data_freeinsert(d, newdup, needlogp);
        }
@@ -719,7 +716,7 @@ xfs_dir2_data_use_free(
        ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG);
        ASSERT(offset >= (char *)dup - (char *)d);
        ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)d);
-       ASSERT((char *)dup - (char *)d == INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT));
+       ASSERT((char *)dup - (char *)d == be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)));
        /*
         * Look up the entry in the bestfree table.
         */
@@ -752,8 +749,8 @@ xfs_dir2_data_use_free(
                newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len);
                newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
                newdup->length = cpu_to_be16(oldlen - len);
-               INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
-                       (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+               *xfs_dir2_data_unused_tag_p(newdup) =
+                       cpu_to_be16((char *)newdup - (char *)d);
                xfs_dir2_data_log_unused(tp, bp, newdup);
                /*
                 * If it was in the table, remove it and add the new one.
@@ -779,8 +776,8 @@ xfs_dir2_data_use_free(
        else if (matchback) {
                newdup = dup;
                newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup);
-               INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
-                       (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+               *xfs_dir2_data_unused_tag_p(newdup) =
+                       cpu_to_be16((char *)newdup - (char *)d);
                xfs_dir2_data_log_unused(tp, bp, newdup);
                /*
                 * If it was in the table, remove it and add the new one.
@@ -806,14 +803,14 @@ xfs_dir2_data_use_free(
        else {
                newdup = dup;
                newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup);
-               INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
-                       (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+               *xfs_dir2_data_unused_tag_p(newdup) =
+                       cpu_to_be16((char *)newdup - (char *)d);
                xfs_dir2_data_log_unused(tp, bp, newdup);
                newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len);
                newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
                newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length));
-               INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup2), ARCH_CONVERT,
-                       (xfs_dir2_data_off_t)((char *)newdup2 - (char *)d));
+               *xfs_dir2_data_unused_tag_p(newdup2) =
+                       cpu_to_be16((char *)newdup2 - (char *)d);
                xfs_dir2_data_log_unused(tp, bp, newdup2);
                /*
                 * If the old entry was in the table, we need to scan