]> err.no Git - linux-2.6/blobdiff - fs/xfs/xfs_dir2_block.c
Merge branch 'upstream' of git://electric-eye.fr.zoreil.com/home/romieu/linux-2.6...
[linux-2.6] / fs / xfs / xfs_dir2_block.c
index fa372b2b433d2a4ef6718230d8f9b04517632735..9d7438bba30d73b0c16ddb8686db9fd0fd6d5f70 100644 (file)
 #include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
-#include "xfs_dir.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_inode_item.h"
-#include "xfs_dir_leaf.h"
 #include "xfs_dir2_data.h"
 #include "xfs_dir2_leaf.h"
 #include "xfs_dir2_block.h"
@@ -51,6 +48,18 @@ static int xfs_dir2_block_lookup_int(xfs_da_args_t *args, xfs_dabuf_t **bpp,
                                     int *entno);
 static int xfs_dir2_block_sort(const void *a, const void *b);
 
+static xfs_dahash_t xfs_dir_hash_dot, xfs_dir_hash_dotdot;
+
+/*
+ * One-time startup routine called from xfs_init().
+ */
+void
+xfs_dir_startup(void)
+{
+       xfs_dir_hash_dot = xfs_da_hashname(".", 1);
+       xfs_dir_hash_dotdot = xfs_da_hashname("..", 2);
+}
+
 /*
  * Add an entry to a block directory.
  */
@@ -81,7 +90,7 @@ xfs_dir2_block_addname(
        xfs_mount_t             *mp;            /* filesystem mount point */
        int                     needlog;        /* need to log header */
        int                     needscan;       /* need to rescan freespace */
-       xfs_dir2_data_off_t     *tagp;          /* pointer to tag value */
+       __be16                  *tagp;          /* pointer to tag value */
        xfs_trans_t             *tp;            /* transaction structure */
 
        xfs_dir2_trace_args("block_addname", args);
@@ -120,11 +129,11 @@ xfs_dir2_block_addname(
                /*
                 * Tag just before the first leaf entry.
                 */
-               tagp = (xfs_dir2_data_off_t *)blp - 1;
+               tagp = (__be16 *)blp - 1;
                /*
                 * Data object just before the first leaf entry.
                 */
-               enddup = (xfs_dir2_data_unused_t *)((char *)block + INT_GET(*tagp, ARCH_CONVERT));
+               enddup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp));
                /*
                 * If it's not free then can't do this add without cleaning up:
                 * the space before the first leaf entry needs to be free so it
@@ -183,11 +192,11 @@ xfs_dir2_block_addname(
                /*
                 * Tag just before the first leaf entry.
                 */
-               tagp = (xfs_dir2_data_off_t *)blp - 1;
+               tagp = (__be16 *)blp - 1;
                /*
                 * Data object just before the first leaf entry.
                 */
-               dup = (xfs_dir2_data_unused_t *)((char *)block + INT_GET(*tagp, ARCH_CONVERT));
+               dup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp));
                /*
                 * If it's not free then the data will go where the
                 * leaf data starts now, if it works at all.
@@ -400,11 +409,11 @@ xfs_dir2_block_addname(
        /*
         * Create the new data entry.
         */
-       INT_SET(dep->inumber, ARCH_CONVERT, args->inumber);
+       dep->inumber = cpu_to_be64(args->inumber);
        dep->namelen = args->namelen;
        memcpy(dep->name, args->name, args->namelen);
        tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
-       INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block));
+       *tagp = cpu_to_be16((char *)dep - (char *)block);
        /*
         * Clean up the bestfree array and log the header, tail, and entry.
         */
@@ -508,7 +517,7 @@ xfs_dir2_block_getdents(
 
                p.cook = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk,
                                                    ptr - (char *)block);
-               p.ino = INT_GET(dep->inumber, ARCH_CONVERT);
+               p.ino = be64_to_cpu(dep->inumber);
 #if XFS_BIG_INUMS
                p.ino += mp->m_inoadd;
 #endif
@@ -533,7 +542,7 @@ xfs_dir2_block_getdents(
 
        /*
         * Reached the end of the block.
-        * Set the offset to a nonexistent block 1 and return.
+        * Set the offset to a non-existent block 1 and return.
         */
        *eofp = 1;
 
@@ -626,7 +635,7 @@ xfs_dir2_block_lookup(
        /*
         * Fill in inode number, release the block.
         */
-       args->inumber = INT_GET(dep->inumber, ARCH_CONVERT);
+       args->inumber = be64_to_cpu(dep->inumber);
        xfs_da_brelse(args->trans, bp);
        return XFS_ERROR(EEXIST);
 }
@@ -844,11 +853,11 @@ xfs_dir2_block_replace(
         */
        dep = (xfs_dir2_data_entry_t *)
              ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address)));
-       ASSERT(INT_GET(dep->inumber, ARCH_CONVERT) != args->inumber);
+       ASSERT(be64_to_cpu(dep->inumber) != args->inumber);
        /*
         * Change the inode number to the new value.
         */
-       INT_SET(dep->inumber, ARCH_CONVERT, args->inumber);
+       dep->inumber = cpu_to_be64(args->inumber);
        xfs_dir2_data_log_entry(args->trans, bp, dep);
        xfs_dir2_data_check(dp, bp);
        xfs_da_buf_done(bp);
@@ -896,7 +905,7 @@ xfs_dir2_leaf_to_block(
        int                     needscan;       /* need to scan for bestfree */
        xfs_dir2_sf_hdr_t       sfh;            /* shortform header */
        int                     size;           /* bytes used */
-       xfs_dir2_data_off_t     *tagp;          /* end of entry (tag) */
+       __be16                  *tagp;          /* end of entry (tag) */
        int                     to;             /* block/leaf to index */
        xfs_trans_t             *tp;            /* transaction pointer */
 
@@ -905,7 +914,7 @@ xfs_dir2_leaf_to_block(
        tp = args->trans;
        mp = dp->i_mount;
        leaf = lbp->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);
        /*
         * If there are data blocks other than the first one, take this
@@ -944,8 +953,8 @@ xfs_dir2_leaf_to_block(
        /*
         * Look at the last data entry.
         */
-       tagp = (xfs_dir2_data_off_t *)((char *)block + mp->m_dirblksize) - 1;
-       dup = (xfs_dir2_data_unused_t *)((char *)block + INT_GET(*tagp, ARCH_CONVERT));
+       tagp = (__be16 *)((char *)block + mp->m_dirblksize) - 1;
+       dup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp));
        /*
         * If it's not free or is too short we can't do it.
         */
@@ -1044,7 +1053,7 @@ xfs_dir2_sf_to_block(
        int                     offset;         /* target block offset */
        xfs_dir2_sf_entry_t     *sfep;          /* sf entry pointer */
        xfs_dir2_sf_t           *sfp;           /* shortform structure */
-       xfs_dir2_data_off_t     *tagp;          /* end of data entry */
+       __be16                  *tagp;          /* end of data entry */
        xfs_trans_t             *tp;            /* transaction pointer */
 
        xfs_dir2_trace_args("sf_to_block", args);
@@ -1101,7 +1110,7 @@ xfs_dir2_sf_to_block(
         * Compute size of block "tail" area.
         */
        i = (uint)sizeof(*btp) +
-           (INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t);
+           (sfp->hdr.count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t);
        /*
         * The whole thing is initialized to free by the init routine.
         * Say we're using the leaf and tail area.
@@ -1115,7 +1124,7 @@ xfs_dir2_sf_to_block(
         * Fill in the tail.
         */
        btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
-       btp->count = cpu_to_be32(INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2);    /* ., .. */
+       btp->count = cpu_to_be32(sfp->hdr.count + 2);   /* ., .. */
        btp->stale = 0;
        blp = XFS_DIR2_BLOCK_LEAF_P(btp);
        endoffset = (uint)((char *)blp - (char *)block);
@@ -1130,11 +1139,11 @@ xfs_dir2_sf_to_block(
         */
        dep = (xfs_dir2_data_entry_t *)
              ((char *)block + XFS_DIR2_DATA_DOT_OFFSET);
-       INT_SET(dep->inumber, ARCH_CONVERT, dp->i_ino);
+       dep->inumber = cpu_to_be64(dp->i_ino);
        dep->namelen = 1;
        dep->name[0] = '.';
        tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
-       INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block));
+       *tagp = cpu_to_be16((char *)dep - (char *)block);
        xfs_dir2_data_log_entry(tp, bp, dep);
        blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot);
        blp[0].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp,
@@ -1144,11 +1153,11 @@ xfs_dir2_sf_to_block(
         */
        dep = (xfs_dir2_data_entry_t *)
                ((char *)block + XFS_DIR2_DATA_DOTDOT_OFFSET);
-       INT_SET(dep->inumber, ARCH_CONVERT, XFS_DIR2_SF_GET_INUMBER(sfp, &sfp->hdr.parent));
+       dep->inumber = cpu_to_be64(XFS_DIR2_SF_GET_INUMBER(sfp, &sfp->hdr.parent));
        dep->namelen = 2;
        dep->name[0] = dep->name[1] = '.';
        tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
-       INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block));
+       *tagp = cpu_to_be16((char *)dep - (char *)block);
        xfs_dir2_data_log_entry(tp, bp, dep);
        blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot);
        blp[1].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp,
@@ -1157,7 +1166,7 @@ xfs_dir2_sf_to_block(
        /*
         * Loop over existing entries, stuff them in.
         */
-       if ((i = 0) == INT_GET(sfp->hdr.count, ARCH_CONVERT))
+       if ((i = 0) == sfp->hdr.count)
                sfep = NULL;
        else
                sfep = XFS_DIR2_SF_FIRSTENTRY(sfp);
@@ -1193,19 +1202,19 @@ xfs_dir2_sf_to_block(
                 * Copy a real entry.
                 */
                dep = (xfs_dir2_data_entry_t *)((char *)block + newoffset);
-               INT_SET(dep->inumber, ARCH_CONVERT, XFS_DIR2_SF_GET_INUMBER(sfp,
+               dep->inumber = cpu_to_be64(XFS_DIR2_SF_GET_INUMBER(sfp,
                                XFS_DIR2_SF_INUMBERP(sfep)));
                dep->namelen = sfep->namelen;
                memcpy(dep->name, sfep->name, dep->namelen);
                tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
-               INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block));
+               *tagp = cpu_to_be16((char *)dep - (char *)block);
                xfs_dir2_data_log_entry(tp, bp, dep);
                blp[2 + i].hashval = cpu_to_be32(xfs_da_hashname(
                                        (char *)sfep->name, sfep->namelen));
                blp[2 + i].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp,
                                                 (char *)dep - (char *)block));
                offset = (int)((char *)(tagp + 1) - (char *)block);
-               if (++i == INT_GET(sfp->hdr.count, ARCH_CONVERT))
+               if (++i == sfp->hdr.count)
                        sfep = NULL;
                else
                        sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep);