]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/xfs/xfs_dir2_data.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec
[karo-tx-linux.git] / fs / xfs / xfs_dir2_data.c
index afa4ad523f3f0278cf7de73a93a25c3b8b191e1d..8c2f6422648ea76788a32b0a3accf755db14f000 100644 (file)
@@ -63,8 +63,10 @@ __xfs_dir3_data_check(
        int                     stale;          /* count of stale leaves */
        struct xfs_name         name;
        const struct xfs_dir_ops *ops;
+       struct xfs_da_geometry  *geo;
 
        mp = bp->b_target->bt_mount;
+       geo = mp->m_dir_geo;
 
        /*
         * We can be passed a null dp here from a verifier, so we need to go the
@@ -78,7 +80,7 @@ __xfs_dir3_data_check(
        switch (hdr->magic) {
        case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC):
        case cpu_to_be32(XFS_DIR2_BLOCK_MAGIC):
-               btp = xfs_dir2_block_tail_p(mp, hdr);
+               btp = xfs_dir2_block_tail_p(geo, hdr);
                lep = xfs_dir2_block_leaf_p(btp);
                endp = (char *)lep;
 
@@ -94,7 +96,7 @@ __xfs_dir3_data_check(
                break;
        case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
        case cpu_to_be32(XFS_DIR2_DATA_MAGIC):
-               endp = (char *)hdr + mp->m_dirblksize;
+               endp = (char *)hdr + geo->blksize;
                break;
        default:
                XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp);
@@ -172,9 +174,9 @@ __xfs_dir3_data_check(
                lastfree = 0;
                if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
                    hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
-                       addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
-                               (xfs_dir2_data_aoff_t)
-                               ((char *)dep - (char *)hdr));
+                       addr = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
+                                               (xfs_dir2_data_aoff_t)
+                                               ((char *)dep - (char *)hdr));
                        name.name = dep->name;
                        name.len = dep->namelen;
                        hash = mp->m_dirnameops->hashname(&name);
@@ -329,12 +331,11 @@ xfs_dir3_data_read(
 
 int
 xfs_dir3_data_readahead(
-       struct xfs_trans        *tp,
        struct xfs_inode        *dp,
        xfs_dablk_t             bno,
        xfs_daddr_t             mapped_bno)
 {
-       return xfs_da_reada_buf(tp, dp, bno, mapped_bno,
+       return xfs_da_reada_buf(dp, bno, mapped_bno,
                                XFS_DATA_FORK, &xfs_dir3_data_reada_buf_ops);
 }
 
@@ -510,6 +511,7 @@ xfs_dir2_data_freescan(
        struct xfs_dir2_data_free *bf;
        char                    *endp;          /* end of block's data */
        char                    *p;             /* current entry pointer */
+       struct xfs_da_geometry  *geo = dp->i_mount->m_dir_geo;
 
        ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
               hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
@@ -528,10 +530,10 @@ xfs_dir2_data_freescan(
        p = (char *)dp->d_ops->data_entry_p(hdr);
        if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
            hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
-               btp = xfs_dir2_block_tail_p(dp->i_mount, hdr);
+               btp = xfs_dir2_block_tail_p(geo, hdr);
                endp = (char *)xfs_dir2_block_leaf_p(btp);
        } else
-               endp = (char *)hdr + dp->i_mount->m_dirblksize;
+               endp = (char *)hdr + geo->blksize;
        /*
         * Loop over the block's entries.
         */
@@ -585,8 +587,8 @@ xfs_dir3_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,
-               XFS_DATA_FORK);
+       error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, blkno),
+                              -1, &bp, XFS_DATA_FORK);
        if (error)
                return error;
        bp->b_ops = &xfs_dir3_data_buf_ops;
@@ -621,15 +623,15 @@ xfs_dir3_data_init(
        dup = dp->d_ops->data_unused_p(hdr);
        dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
 
-       t = mp->m_dirblksize - (uint)dp->d_ops->data_entry_offset;
+       t = args->geo->blksize - (uint)dp->d_ops->data_entry_offset;
        bf[0].length = cpu_to_be16(t);
        dup->length = cpu_to_be16(t);
        *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)hdr);
        /*
         * Log it and return it.
         */
-       xfs_dir2_data_log_header(tp, dp, bp);
-       xfs_dir2_data_log_unused(tp, bp, dup);
+       xfs_dir2_data_log_header(args, bp);
+       xfs_dir2_data_log_unused(args, bp, dup);
        *bpp = bp;
        return 0;
 }
@@ -639,8 +641,7 @@ xfs_dir3_data_init(
  */
 void
 xfs_dir2_data_log_entry(
-       struct xfs_trans        *tp,
-       struct xfs_inode        *dp,
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp,
        xfs_dir2_data_entry_t   *dep)           /* data entry pointer */
 {
@@ -651,8 +652,8 @@ xfs_dir2_data_log_entry(
               hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
               hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
 
-       xfs_trans_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr),
-               (uint)((char *)(dp->d_ops->data_entry_tag_p(dep) + 1) -
+       xfs_trans_log_buf(args->trans, bp, (uint)((char *)dep - (char *)hdr),
+               (uint)((char *)(args->dp->d_ops->data_entry_tag_p(dep) + 1) -
                       (char *)hdr - 1));
 }
 
@@ -661,8 +662,7 @@ xfs_dir2_data_log_entry(
  */
 void
 xfs_dir2_data_log_header(
-       struct xfs_trans        *tp,
-       struct xfs_inode        *dp,
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp)
 {
 #ifdef DEBUG
@@ -674,7 +674,8 @@ xfs_dir2_data_log_header(
               hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
 #endif
 
-       xfs_trans_log_buf(tp, bp, 0, dp->d_ops->data_entry_offset - 1);
+       xfs_trans_log_buf(args->trans, bp, 0,
+                         args->dp->d_ops->data_entry_offset - 1);
 }
 
 /*
@@ -682,7 +683,7 @@ xfs_dir2_data_log_header(
  */
 void
 xfs_dir2_data_log_unused(
-       struct xfs_trans        *tp,
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp,
        xfs_dir2_data_unused_t  *dup)           /* data unused pointer */
 {
@@ -696,13 +697,13 @@ xfs_dir2_data_log_unused(
        /*
         * Log the first part of the unused entry.
         */
-       xfs_trans_log_buf(tp, bp, (uint)((char *)dup - (char *)hdr),
+       xfs_trans_log_buf(args->trans, bp, (uint)((char *)dup - (char *)hdr),
                (uint)((char *)&dup->length + sizeof(dup->length) -
                       1 - (char *)hdr));
        /*
         * Log the end (tag) of the unused entry.
         */
-       xfs_trans_log_buf(tp, bp,
+       xfs_trans_log_buf(args->trans, bp,
                (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr),
                (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr +
                       sizeof(xfs_dir2_data_off_t) - 1));
@@ -714,8 +715,7 @@ xfs_dir2_data_log_unused(
  */
 void
 xfs_dir2_data_make_free(
-       struct xfs_trans        *tp,
-       struct xfs_inode        *dp,
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp,
        xfs_dir2_data_aoff_t    offset,         /* starting byte offset */
        xfs_dir2_data_aoff_t    len,            /* length in bytes */
@@ -725,14 +725,12 @@ xfs_dir2_data_make_free(
        xfs_dir2_data_hdr_t     *hdr;           /* data block pointer */
        xfs_dir2_data_free_t    *dfp;           /* bestfree pointer */
        char                    *endptr;        /* end of data area */
-       xfs_mount_t             *mp;            /* filesystem mount point */
        int                     needscan;       /* need to regen bestfree */
        xfs_dir2_data_unused_t  *newdup;        /* new unused entry */
        xfs_dir2_data_unused_t  *postdup;       /* unused entry after us */
        xfs_dir2_data_unused_t  *prevdup;       /* unused entry before us */
        struct xfs_dir2_data_free *bf;
 
-       mp = tp->t_mountp;
        hdr = bp->b_addr;
 
        /*
@@ -740,20 +738,20 @@ xfs_dir2_data_make_free(
         */
        if (hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
            hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC))
-               endptr = (char *)hdr + mp->m_dirblksize;
+               endptr = (char *)hdr + args->geo->blksize;
        else {
                xfs_dir2_block_tail_t   *btp;   /* block tail */
 
                ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
                        hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
-               btp = xfs_dir2_block_tail_p(mp, hdr);
+               btp = xfs_dir2_block_tail_p(args->geo, hdr);
                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 > dp->d_ops->data_entry_offset) {
+       if (offset > args->dp->d_ops->data_entry_offset) {
                __be16                  *tagp;  /* tag just before us */
 
                tagp = (__be16 *)((char *)hdr + offset) - 1;
@@ -779,7 +777,7 @@ xfs_dir2_data_make_free(
         * Previous and following entries are both free,
         * merge everything into a single free entry.
         */
-       bf = dp->d_ops->data_bestfree_p(hdr);
+       bf = args->dp->d_ops->data_bestfree_p(hdr);
        if (prevdup && postdup) {
                xfs_dir2_data_free_t    *dfp2;  /* another bestfree pointer */
 
@@ -801,7 +799,7 @@ xfs_dir2_data_make_free(
                be16_add_cpu(&prevdup->length, len + be16_to_cpu(postdup->length));
                *xfs_dir2_data_unused_tag_p(prevdup) =
                        cpu_to_be16((char *)prevdup - (char *)hdr);
-               xfs_dir2_data_log_unused(tp, bp, prevdup);
+               xfs_dir2_data_log_unused(args, bp, prevdup);
                if (!needscan) {
                        /*
                         * Has to be the case that entries 0 and 1 are
@@ -836,7 +834,7 @@ xfs_dir2_data_make_free(
                be16_add_cpu(&prevdup->length, len);
                *xfs_dir2_data_unused_tag_p(prevdup) =
                        cpu_to_be16((char *)prevdup - (char *)hdr);
-               xfs_dir2_data_log_unused(tp, bp, prevdup);
+               xfs_dir2_data_log_unused(args, bp, prevdup);
                /*
                 * If the previous entry was in the table, the new entry
                 * is longer, so it will be in the table too.  Remove
@@ -864,7 +862,7 @@ xfs_dir2_data_make_free(
                newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length));
                *xfs_dir2_data_unused_tag_p(newdup) =
                        cpu_to_be16((char *)newdup - (char *)hdr);
-               xfs_dir2_data_log_unused(tp, bp, newdup);
+               xfs_dir2_data_log_unused(args, bp, newdup);
                /*
                 * If the following entry was in the table, the new entry
                 * is longer, so it will be in the table too.  Remove
@@ -891,7 +889,7 @@ xfs_dir2_data_make_free(
                newdup->length = cpu_to_be16(len);
                *xfs_dir2_data_unused_tag_p(newdup) =
                        cpu_to_be16((char *)newdup - (char *)hdr);
-               xfs_dir2_data_log_unused(tp, bp, newdup);
+               xfs_dir2_data_log_unused(args, bp, newdup);
                xfs_dir2_data_freeinsert(hdr, bf, newdup, needlogp);
        }
        *needscanp = needscan;
@@ -902,8 +900,7 @@ xfs_dir2_data_make_free(
  */
 void
 xfs_dir2_data_use_free(
-       struct xfs_trans        *tp,
-       struct xfs_inode        *dp,
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp,
        xfs_dir2_data_unused_t  *dup,           /* unused entry */
        xfs_dir2_data_aoff_t    offset,         /* starting offset to use */
@@ -934,7 +931,7 @@ xfs_dir2_data_use_free(
         * Look up the entry in the bestfree table.
         */
        oldlen = be16_to_cpu(dup->length);
-       bf = dp->d_ops->data_bestfree_p(hdr);
+       bf = args->dp->d_ops->data_bestfree_p(hdr);
        dfp = xfs_dir2_data_freefind(hdr, bf, dup);
        ASSERT(dfp || oldlen <= be16_to_cpu(bf[2].length));
        /*
@@ -966,7 +963,7 @@ xfs_dir2_data_use_free(
                newdup->length = cpu_to_be16(oldlen - len);
                *xfs_dir2_data_unused_tag_p(newdup) =
                        cpu_to_be16((char *)newdup - (char *)hdr);
-               xfs_dir2_data_log_unused(tp, bp, newdup);
+               xfs_dir2_data_log_unused(args, bp, newdup);
                /*
                 * If it was in the table, remove it and add the new one.
                 */
@@ -994,7 +991,7 @@ xfs_dir2_data_use_free(
                newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup);
                *xfs_dir2_data_unused_tag_p(newdup) =
                        cpu_to_be16((char *)newdup - (char *)hdr);
-               xfs_dir2_data_log_unused(tp, bp, newdup);
+               xfs_dir2_data_log_unused(args, bp, newdup);
                /*
                 * If it was in the table, remove it and add the new one.
                 */
@@ -1022,13 +1019,13 @@ xfs_dir2_data_use_free(
                newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup);
                *xfs_dir2_data_unused_tag_p(newdup) =
                        cpu_to_be16((char *)newdup - (char *)hdr);
-               xfs_dir2_data_log_unused(tp, bp, newdup);
+               xfs_dir2_data_log_unused(args, bp, newdup);
                newdup2 = (xfs_dir2_data_unused_t *)((char *)hdr + offset + len);
                newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
                newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length));
                *xfs_dir2_data_unused_tag_p(newdup2) =
                        cpu_to_be16((char *)newdup2 - (char *)hdr);
-               xfs_dir2_data_log_unused(tp, bp, newdup2);
+               xfs_dir2_data_log_unused(args, bp, newdup2);
                /*
                 * If the old entry was in the table, we need to scan
                 * if the 3rd entry was valid, since these entries