xfs: convert m_dirblkfsbs to xfs_da_geometry
[deliverable/linux.git] / fs / xfs / xfs_dir2_leaf.c
index d36e97df1187ebc866e9c3885d6f848ca3373c5a..a1f13103a16eaebe0a61d0f1be3dc00362f99537 100644 (file)
@@ -347,11 +347,11 @@ xfs_dir3_leaf_get_buf(
        int                     error;
 
        ASSERT(magic == XFS_DIR2_LEAF1_MAGIC || magic == XFS_DIR2_LEAFN_MAGIC);
-       ASSERT(bno >= XFS_DIR2_LEAF_FIRSTDB(mp) &&
-              bno < XFS_DIR2_FREE_FIRSTDB(mp));
+       ASSERT(bno >= xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET) &&
+              bno < xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET));
 
-       error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, bno), -1, &bp,
-                              XFS_DATA_FORK);
+       error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, bno),
+                              -1, &bp, XFS_DATA_FORK);
        if (error)
                return error;
 
@@ -403,8 +403,8 @@ xfs_dir2_block_to_leaf(
        if ((error = xfs_da_grow_inode(args, &blkno))) {
                return error;
        }
-       ldb = xfs_dir2_da_to_db(mp, blkno);
-       ASSERT(ldb == XFS_DIR2_LEAF_FIRSTDB(mp));
+       ldb = xfs_dir2_da_to_db(args->geo, blkno);
+       ASSERT(ldb == xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET));
        /*
         * Initialize the leaf block, get a buffer for it.
         */
@@ -641,7 +641,7 @@ xfs_dir2_leaf_addname(
        tp = args->trans;
        mp = dp->i_mount;
 
-       error = xfs_dir3_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp);
+       error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp);
        if (error)
                return error;
 
@@ -670,7 +670,7 @@ xfs_dir2_leaf_addname(
             index++, lep++) {
                if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
                        continue;
-               i = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
+               i = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
                ASSERT(i < be32_to_cpu(ltp->bestcount));
                ASSERT(bestsp[i] != cpu_to_be16(NULLDATAOFF));
                if (be16_to_cpu(bestsp[i]) >= length) {
@@ -828,8 +828,8 @@ xfs_dir2_leaf_addname(
                 * Just read that one in.
                 */
                error = xfs_dir3_data_read(tp, dp,
-                                          xfs_dir2_db_to_da(mp, use_block),
-                                          -1, &dbp);
+                                  xfs_dir2_db_to_da(args->geo, use_block),
+                                  -1, &dbp);
                if (error) {
                        xfs_trans_brelse(tp, lbp);
                        return error;
@@ -889,7 +889,8 @@ xfs_dir2_leaf_addname(
         * Fill in the new leaf entry.
         */
        lep->hashval = cpu_to_be32(args->hashval);
-       lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, use_block,
+       lep->address = cpu_to_be32(
+                               xfs_dir2_db_off_to_dataptr(args->geo, use_block,
                                be16_to_cpu(*tagp)));
        /*
         * Log the leaf fields and give up the buffers.
@@ -1185,7 +1186,7 @@ xfs_dir2_leaf_lookup(
         */
        dep = (xfs_dir2_data_entry_t *)
              ((char *)dbp->b_addr +
-              xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
+              xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
        /*
         * Return the found inode number & CI name if appropriate
         */
@@ -1231,7 +1232,7 @@ xfs_dir2_leaf_lookup_int(
        tp = args->trans;
        mp = dp->i_mount;
 
-       error = xfs_dir3_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp);
+       error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp);
        if (error)
                return error;
 
@@ -1260,7 +1261,8 @@ xfs_dir2_leaf_lookup_int(
                /*
                 * Get the new data block number.
                 */
-               newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
+               newdb = xfs_dir2_dataptr_to_db(args->geo,
+                                              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.
@@ -1269,8 +1271,8 @@ xfs_dir2_leaf_lookup_int(
                        if (dbp)
                                xfs_trans_brelse(tp, dbp);
                        error = xfs_dir3_data_read(tp, dp,
-                                                  xfs_dir2_db_to_da(mp, newdb),
-                                                  -1, &dbp);
+                                          xfs_dir2_db_to_da(args->geo, newdb),
+                                          -1, &dbp);
                        if (error) {
                                xfs_trans_brelse(tp, lbp);
                                return error;
@@ -1281,7 +1283,8 @@ xfs_dir2_leaf_lookup_int(
                 * Point to the data entry.
                 */
                dep = (xfs_dir2_data_entry_t *)((char *)dbp->b_addr +
-                       xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
+                       xfs_dir2_dataptr_to_off(args->geo,
+                                               be32_to_cpu(lep->address)));
                /*
                 * Compare name and if it's an exact match, return the index
                 * and buffer. If it's the first case-insensitive match, store
@@ -1310,8 +1313,8 @@ xfs_dir2_leaf_lookup_int(
                if (cidb != curdb) {
                        xfs_trans_brelse(tp, dbp);
                        error = xfs_dir3_data_read(tp, dp,
-                                                  xfs_dir2_db_to_da(mp, cidb),
-                                                  -1, &dbp);
+                                          xfs_dir2_db_to_da(args->geo, cidb),
+                                          -1, &dbp);
                        if (error) {
                                xfs_trans_brelse(tp, lbp);
                                return error;
@@ -1380,9 +1383,9 @@ xfs_dir2_leaf_removename(
         * Point to the leaf entry, use that to point to the data entry.
         */
        lep = &ents[index];
-       db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
-       dep = (xfs_dir2_data_entry_t *)
-             ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
+       db = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
+       dep = (xfs_dir2_data_entry_t *)((char *)hdr +
+               xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
        needscan = needlog = 0;
        oldbest = be16_to_cpu(bf[0].length);
        ltp = xfs_dir2_leaf_tail_p(mp, leaf);
@@ -1426,7 +1429,7 @@ xfs_dir2_leaf_removename(
         */
        if (be16_to_cpu(bf[0].length) ==
                        mp->m_dirblksize - dp->d_ops->data_entry_offset) {
-               ASSERT(db != mp->m_dirdatablk);
+               ASSERT(db != args->geo->datablk);
                if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
                        /*
                         * Nope, can't get rid of it because it caused
@@ -1467,7 +1470,7 @@ xfs_dir2_leaf_removename(
        /*
         * If the data block was not the first one, drop it.
         */
-       else if (db != mp->m_dirdatablk)
+       else if (db != args->geo->datablk)
                dbp = NULL;
 
        xfs_dir3_leaf_check(dp, lbp);
@@ -1515,7 +1518,7 @@ xfs_dir2_leaf_replace(
         */
        dep = (xfs_dir2_data_entry_t *)
              ((char *)dbp->b_addr +
-              xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
+              xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
        ASSERT(args->inumber != be64_to_cpu(dep->inumber));
        /*
         * Put the new inode number in, log it.
@@ -1609,7 +1612,8 @@ xfs_dir2_leaf_trim_data(
        /*
         * Read the offending data block.  We need its buffer.
         */
-       error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(mp, db), -1, &dbp);
+       error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(args->geo, db),
+                                  -1, &dbp);
        if (error)
                return error;
 
@@ -1708,22 +1712,22 @@ xfs_dir2_node_to_leaf(
        /*
         * Get the last offset in the file.
         */
-       if ((error = xfs_bmap_last_offset(tp, dp, &fo, XFS_DATA_FORK))) {
+       if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK))) {
                return error;
        }
-       fo -= mp->m_dirblkfsbs;
+       fo -= args->geo->fsbcount;
        /*
         * If there are freespace blocks other than the first one,
         * take this opportunity to remove trailing empty freespace blocks
         * that may have been left behind during no-space-reservation
         * operations.
         */
-       while (fo > mp->m_dirfreeblk) {
+       while (fo > args->geo->freeblk) {
                if ((error = xfs_dir2_node_trim_free(args, fo, &rval))) {
                        return error;
                }
                if (rval)
-                       fo -= mp->m_dirblkfsbs;
+                       fo -= args->geo->fsbcount;
                else
                        return 0;
        }
@@ -1748,7 +1752,7 @@ xfs_dir2_node_to_leaf(
        /*
         * Read the freespace block.
         */
-       error = xfs_dir2_free_read(tp, dp,  mp->m_dirfreeblk, &fbp);
+       error = xfs_dir2_free_read(tp, dp,  args->geo->freeblk, &fbp);
        if (error)
                return error;
        free = fbp->b_addr;
@@ -1798,7 +1802,9 @@ xfs_dir2_node_to_leaf(
        /*
         * Get rid of the freespace block.
         */
-       error = xfs_dir2_shrink_inode(args, XFS_DIR2_FREE_FIRSTDB(mp), fbp);
+       error = xfs_dir2_shrink_inode(args,
+                       xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET),
+                       fbp);
        if (error) {
                /*
                 * This can't fail here because it can only happen when
This page took 0.048938 seconds and 5 git commands to generate.