aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-06 01:08:18 -0400
committerDave Chinner <david@fromorbit.com>2014-06-06 01:08:18 -0400
commit30028030b14d083123c88e3ab45990a8c375abf1 (patch)
treec6787bd71e8b29f7acf675500a899e4154e0b951 /fs
parent2998ab1d450a526a9a3a6292f91239b4fc209db0 (diff)
xfs: convert directory db conversion to xfs_da_geometry
Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_da_format.c4
-rw-r--r--fs/xfs/xfs_dir2.c13
-rw-r--r--fs/xfs/xfs_dir2_block.c15
-rw-r--r--fs/xfs/xfs_dir2_data.c3
-rw-r--r--fs/xfs/xfs_dir2_leaf.c30
-rw-r--r--fs/xfs/xfs_dir2_node.c27
-rw-r--r--fs/xfs/xfs_dir2_priv.h22
-rw-r--r--fs/xfs/xfs_dir2_readdir.c45
-rw-r--r--fs/xfs/xfs_dir2_sf.c4
9 files changed, 93 insertions, 70 deletions
diff --git a/fs/xfs/xfs_da_format.c b/fs/xfs/xfs_da_format.c
index a2d0682fa309..ac8474e22e2b 100644
--- a/fs/xfs/xfs_da_format.c
+++ b/fs/xfs/xfs_da_format.c
@@ -611,7 +611,7 @@ xfs_dir2_free_bests_p(struct xfs_dir2_free *free)
611static xfs_dir2_db_t 611static xfs_dir2_db_t
612xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db) 612xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
613{ 613{
614 return xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET) + 614 return xfs_dir2_byte_to_db(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET) +
615 (db / xfs_dir2_free_max_bests(mp)); 615 (db / xfs_dir2_free_max_bests(mp));
616} 616}
617 617
@@ -643,7 +643,7 @@ xfs_dir3_free_bests_p(struct xfs_dir2_free *free)
643static xfs_dir2_db_t 643static xfs_dir2_db_t
644xfs_dir3_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db) 644xfs_dir3_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
645{ 645{
646 return xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET) + 646 return xfs_dir2_byte_to_db(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET) +
647 (db / xfs_dir3_free_max_bests(mp)); 647 (db / xfs_dir3_free_max_bests(mp));
648} 648}
649 649
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 9a2f5532fd9f..886a67d92f63 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -117,9 +117,14 @@ xfs_da_mount(
117 dageo->fsblog = mp->m_sb.sb_blocklog; 117 dageo->fsblog = mp->m_sb.sb_blocklog;
118 dageo->blksize = 1 << dageo->blklog; 118 dageo->blksize = 1 << dageo->blklog;
119 dageo->fsbcount = 1 << mp->m_sb.sb_dirblklog; 119 dageo->fsbcount = 1 << mp->m_sb.sb_dirblklog;
120 dageo->datablk = xfs_dir2_byte_to_da(mp, XFS_DIR2_DATA_OFFSET); 120
121 dageo->leafblk = xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET); 121 /*
122 dageo->freeblk = xfs_dir2_byte_to_da(mp, XFS_DIR2_FREE_OFFSET); 122 * Now we've set up the block conversion variables, we can calculate the
123 * segment block constants using the geometry structure.
124 */
125 dageo->datablk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_DATA_OFFSET);
126 dageo->leafblk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_LEAF_OFFSET);
127 dageo->freeblk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_FREE_OFFSET);
123 dageo->node_ents = (dageo->blksize - nodehdr_size) / 128 dageo->node_ents = (dageo->blksize - nodehdr_size) /
124 (uint)sizeof(xfs_da_node_entry_t); 129 (uint)sizeof(xfs_da_node_entry_t);
125 dageo->magicpct = (dageo->blksize * 37) / 100; 130 dageo->magicpct = (dageo->blksize * 37) / 100;
@@ -744,7 +749,7 @@ xfs_dir2_shrink_inode(
744 /* 749 /*
745 * If it's not a data block, we're done. 750 * If it's not a data block, we're done.
746 */ 751 */
747 if (db >= xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET)) 752 if (db >= xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET))
748 return 0; 753 return 0;
749 /* 754 /*
750 * If the block isn't the last one in the directory, we're done. 755 * If the block isn't the last one in the directory, we're done.
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index dd9d00515582..bc08216089d8 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -639,7 +639,8 @@ xfs_dir2_block_lookup(
639 * Get the offset from the leaf entry, to point to the data. 639 * Get the offset from the leaf entry, to point to the data.
640 */ 640 */
641 dep = (xfs_dir2_data_entry_t *)((char *)hdr + 641 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
642 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); 642 xfs_dir2_dataptr_to_off(args->geo,
643 be32_to_cpu(blp[ent].address)));
643 /* 644 /*
644 * Fill in inode number, CI name if appropriate, release the block. 645 * Fill in inode number, CI name if appropriate, release the block.
645 */ 646 */
@@ -723,7 +724,7 @@ xfs_dir2_block_lookup_int(
723 * Get pointer to the entry from the leaf. 724 * Get pointer to the entry from the leaf.
724 */ 725 */
725 dep = (xfs_dir2_data_entry_t *) 726 dep = (xfs_dir2_data_entry_t *)
726 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, addr)); 727 ((char *)hdr + xfs_dir2_dataptr_to_off(args->geo, addr));
727 /* 728 /*
728 * Compare name and if it's an exact match, return the index 729 * Compare name and if it's an exact match, return the index
729 * and buffer. If it's the first case-insensitive match, store 730 * and buffer. If it's the first case-insensitive match, store
@@ -795,8 +796,9 @@ xfs_dir2_block_removename(
795 /* 796 /*
796 * Point to the data entry using the leaf entry. 797 * Point to the data entry using the leaf entry.
797 */ 798 */
798 dep = (xfs_dir2_data_entry_t *) 799 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
799 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); 800 xfs_dir2_dataptr_to_off(args->geo,
801 be32_to_cpu(blp[ent].address)));
800 /* 802 /*
801 * Mark the data entry's space free. 803 * Mark the data entry's space free.
802 */ 804 */
@@ -870,8 +872,9 @@ xfs_dir2_block_replace(
870 /* 872 /*
871 * Point to the data entry we need to change. 873 * Point to the data entry we need to change.
872 */ 874 */
873 dep = (xfs_dir2_data_entry_t *) 875 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
874 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); 876 xfs_dir2_dataptr_to_off(args->geo,
877 be32_to_cpu(blp[ent].address)));
875 ASSERT(be64_to_cpu(dep->inumber) != args->inumber); 878 ASSERT(be64_to_cpu(dep->inumber) != args->inumber);
876 /* 879 /*
877 * Change the inode number to the new value. 880 * Change the inode number to the new value.
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index 890c94033c3f..d355ec7d35cd 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -172,7 +172,8 @@ __xfs_dir3_data_check(
172 lastfree = 0; 172 lastfree = 0;
173 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || 173 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
174 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) { 174 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
175 addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 175 addr = xfs_dir2_db_off_to_dataptr(mp->m_dir_geo,
176 mp->m_dirdatablk,
176 (xfs_dir2_data_aoff_t) 177 (xfs_dir2_data_aoff_t)
177 ((char *)dep - (char *)hdr)); 178 ((char *)dep - (char *)hdr));
178 name.name = dep->name; 179 name.name = dep->name;
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 046ba4a09eaa..2b3ddd061d0e 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -347,8 +347,8 @@ xfs_dir3_leaf_get_buf(
347 int error; 347 int error;
348 348
349 ASSERT(magic == XFS_DIR2_LEAF1_MAGIC || magic == XFS_DIR2_LEAFN_MAGIC); 349 ASSERT(magic == XFS_DIR2_LEAF1_MAGIC || magic == XFS_DIR2_LEAFN_MAGIC);
350 ASSERT(bno >= xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET) && 350 ASSERT(bno >= xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET) &&
351 bno < xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET)); 351 bno < xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET));
352 352
353 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, bno), 353 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, bno),
354 -1, &bp, XFS_DATA_FORK); 354 -1, &bp, XFS_DATA_FORK);
@@ -404,7 +404,7 @@ xfs_dir2_block_to_leaf(
404 return error; 404 return error;
405 } 405 }
406 ldb = xfs_dir2_da_to_db(args->geo, blkno); 406 ldb = xfs_dir2_da_to_db(args->geo, blkno);
407 ASSERT(ldb == xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET)); 407 ASSERT(ldb == xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET));
408 /* 408 /*
409 * Initialize the leaf block, get a buffer for it. 409 * Initialize the leaf block, get a buffer for it.
410 */ 410 */
@@ -670,7 +670,7 @@ xfs_dir2_leaf_addname(
670 index++, lep++) { 670 index++, lep++) {
671 if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) 671 if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
672 continue; 672 continue;
673 i = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 673 i = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
674 ASSERT(i < be32_to_cpu(ltp->bestcount)); 674 ASSERT(i < be32_to_cpu(ltp->bestcount));
675 ASSERT(bestsp[i] != cpu_to_be16(NULLDATAOFF)); 675 ASSERT(bestsp[i] != cpu_to_be16(NULLDATAOFF));
676 if (be16_to_cpu(bestsp[i]) >= length) { 676 if (be16_to_cpu(bestsp[i]) >= length) {
@@ -889,7 +889,8 @@ xfs_dir2_leaf_addname(
889 * Fill in the new leaf entry. 889 * Fill in the new leaf entry.
890 */ 890 */
891 lep->hashval = cpu_to_be32(args->hashval); 891 lep->hashval = cpu_to_be32(args->hashval);
892 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, use_block, 892 lep->address = cpu_to_be32(
893 xfs_dir2_db_off_to_dataptr(args->geo, use_block,
893 be16_to_cpu(*tagp))); 894 be16_to_cpu(*tagp)));
894 /* 895 /*
895 * Log the leaf fields and give up the buffers. 896 * Log the leaf fields and give up the buffers.
@@ -1185,7 +1186,7 @@ xfs_dir2_leaf_lookup(
1185 */ 1186 */
1186 dep = (xfs_dir2_data_entry_t *) 1187 dep = (xfs_dir2_data_entry_t *)
1187 ((char *)dbp->b_addr + 1188 ((char *)dbp->b_addr +
1188 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address))); 1189 xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
1189 /* 1190 /*
1190 * Return the found inode number & CI name if appropriate 1191 * Return the found inode number & CI name if appropriate
1191 */ 1192 */
@@ -1260,7 +1261,8 @@ xfs_dir2_leaf_lookup_int(
1260 /* 1261 /*
1261 * Get the new data block number. 1262 * Get the new data block number.
1262 */ 1263 */
1263 newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 1264 newdb = xfs_dir2_dataptr_to_db(args->geo,
1265 be32_to_cpu(lep->address));
1264 /* 1266 /*
1265 * If it's not the same as the old data block number, 1267 * If it's not the same as the old data block number,
1266 * need to pitch the old one and read the new one. 1268 * need to pitch the old one and read the new one.
@@ -1281,7 +1283,8 @@ xfs_dir2_leaf_lookup_int(
1281 * Point to the data entry. 1283 * Point to the data entry.
1282 */ 1284 */
1283 dep = (xfs_dir2_data_entry_t *)((char *)dbp->b_addr + 1285 dep = (xfs_dir2_data_entry_t *)((char *)dbp->b_addr +
1284 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 1286 xfs_dir2_dataptr_to_off(args->geo,
1287 be32_to_cpu(lep->address)));
1285 /* 1288 /*
1286 * Compare name and if it's an exact match, return the index 1289 * Compare name and if it's an exact match, return the index
1287 * and buffer. If it's the first case-insensitive match, store 1290 * and buffer. If it's the first case-insensitive match, store
@@ -1380,9 +1383,9 @@ xfs_dir2_leaf_removename(
1380 * Point to the leaf entry, use that to point to the data entry. 1383 * Point to the leaf entry, use that to point to the data entry.
1381 */ 1384 */
1382 lep = &ents[index]; 1385 lep = &ents[index];
1383 db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 1386 db = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
1384 dep = (xfs_dir2_data_entry_t *) 1387 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
1385 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 1388 xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
1386 needscan = needlog = 0; 1389 needscan = needlog = 0;
1387 oldbest = be16_to_cpu(bf[0].length); 1390 oldbest = be16_to_cpu(bf[0].length);
1388 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1391 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
@@ -1515,7 +1518,7 @@ xfs_dir2_leaf_replace(
1515 */ 1518 */
1516 dep = (xfs_dir2_data_entry_t *) 1519 dep = (xfs_dir2_data_entry_t *)
1517 ((char *)dbp->b_addr + 1520 ((char *)dbp->b_addr +
1518 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address))); 1521 xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
1519 ASSERT(args->inumber != be64_to_cpu(dep->inumber)); 1522 ASSERT(args->inumber != be64_to_cpu(dep->inumber));
1520 /* 1523 /*
1521 * Put the new inode number in, log it. 1524 * Put the new inode number in, log it.
@@ -1800,7 +1803,8 @@ xfs_dir2_node_to_leaf(
1800 * Get rid of the freespace block. 1803 * Get rid of the freespace block.
1801 */ 1804 */
1802 error = xfs_dir2_shrink_inode(args, 1805 error = xfs_dir2_shrink_inode(args,
1803 xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET), fbp); 1806 xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET),
1807 fbp);
1804 if (error) { 1808 if (error) {
1805 /* 1809 /*
1806 * This can't fail here because it can only happen when 1810 * This can't fail here because it can only happen when
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 3b70d56f4e58..89777bf63551 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -316,7 +316,7 @@ xfs_dir2_leaf_to_node(
316 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_FREE_SPACE, &fdb))) { 316 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_FREE_SPACE, &fdb))) {
317 return error; 317 return error;
318 } 318 }
319 ASSERT(fdb == xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET)); 319 ASSERT(fdb == xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET));
320 /* 320 /*
321 * Get the buffer for the new freespace block. 321 * Get the buffer for the new freespace block.
322 */ 322 */
@@ -451,7 +451,7 @@ xfs_dir2_leafn_add(
451 highstale, &lfloglow, &lfloghigh); 451 highstale, &lfloglow, &lfloghigh);
452 452
453 lep->hashval = cpu_to_be32(args->hashval); 453 lep->hashval = cpu_to_be32(args->hashval);
454 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, 454 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(args->geo,
455 args->blkno, args->index)); 455 args->blkno, args->index));
456 456
457 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 457 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
@@ -577,7 +577,8 @@ xfs_dir2_leafn_lookup_for_addname(
577 /* 577 /*
578 * Pull the data block number from the entry. 578 * Pull the data block number from the entry.
579 */ 579 */
580 newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 580 newdb = xfs_dir2_dataptr_to_db(args->geo,
581 be32_to_cpu(lep->address));
581 /* 582 /*
582 * For addname, we're looking for a place to put the new entry. 583 * For addname, we're looking for a place to put the new entry.
583 * We want to use a data block with an entry of equal 584 * We want to use a data block with an entry of equal
@@ -723,7 +724,8 @@ xfs_dir2_leafn_lookup_for_entry(
723 /* 724 /*
724 * Pull the data block number from the entry. 725 * Pull the data block number from the entry.
725 */ 726 */
726 newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 727 newdb = xfs_dir2_dataptr_to_db(args->geo,
728 be32_to_cpu(lep->address));
727 /* 729 /*
728 * Not adding a new entry, so we really want to find 730 * Not adding a new entry, so we really want to find
729 * the name given to us. 731 * the name given to us.
@@ -761,7 +763,8 @@ xfs_dir2_leafn_lookup_for_entry(
761 * Point to the data entry. 763 * Point to the data entry.
762 */ 764 */
763 dep = (xfs_dir2_data_entry_t *)((char *)curbp->b_addr + 765 dep = (xfs_dir2_data_entry_t *)((char *)curbp->b_addr +
764 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 766 xfs_dir2_dataptr_to_off(args->geo,
767 be32_to_cpu(lep->address)));
765 /* 768 /*
766 * Compare the entry and if it's an exact match, return 769 * Compare the entry and if it's an exact match, return
767 * EEXIST immediately. If it's the first case-insensitive 770 * EEXIST immediately. If it's the first case-insensitive
@@ -1196,9 +1199,9 @@ xfs_dir2_leafn_remove(
1196 /* 1199 /*
1197 * Extract the data block and offset from the entry. 1200 * Extract the data block and offset from the entry.
1198 */ 1201 */
1199 db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 1202 db = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
1200 ASSERT(dblk->blkno == db); 1203 ASSERT(dblk->blkno == db);
1201 off = xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)); 1204 off = xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address));
1202 ASSERT(dblk->index == off); 1205 ASSERT(dblk->index == off);
1203 1206
1204 /* 1207 /*
@@ -1260,7 +1263,8 @@ xfs_dir2_leafn_remove(
1260 struct xfs_dir3_icfree_hdr freehdr; 1263 struct xfs_dir3_icfree_hdr freehdr;
1261 dp->d_ops->free_hdr_from_disk(&freehdr, free); 1264 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1262 ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(mp) * 1265 ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(mp) *
1263 (fdb - xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET))); 1266 (fdb - xfs_dir2_byte_to_db(args->geo,
1267 XFS_DIR2_FREE_OFFSET)));
1264 } 1268 }
1265#endif 1269#endif
1266 /* 1270 /*
@@ -1751,7 +1755,7 @@ xfs_dir2_node_addname_int(
1751 * us a freespace block to start with. 1755 * us a freespace block to start with.
1752 */ 1756 */
1753 if (++fbno == 0) 1757 if (++fbno == 0)
1754 fbno = xfs_dir2_byte_to_db(mp, 1758 fbno = xfs_dir2_byte_to_db(args->geo,
1755 XFS_DIR2_FREE_OFFSET); 1759 XFS_DIR2_FREE_OFFSET);
1756 /* 1760 /*
1757 * If it's ifbno we already looked at it. 1761 * If it's ifbno we already looked at it.
@@ -1893,7 +1897,7 @@ xfs_dir2_node_addname_int(
1893 * Remember the first slot as our empty slot. 1897 * Remember the first slot as our empty slot.
1894 */ 1898 */
1895 freehdr.firstdb = 1899 freehdr.firstdb =
1896 (fbno - xfs_dir2_byte_to_db(mp, 1900 (fbno - xfs_dir2_byte_to_db(args->geo,
1897 XFS_DIR2_FREE_OFFSET)) * 1901 XFS_DIR2_FREE_OFFSET)) *
1898 dp->d_ops->free_max_bests(mp); 1902 dp->d_ops->free_max_bests(mp);
1899 } else { 1903 } else {
@@ -2194,7 +2198,8 @@ xfs_dir2_node_replace(
2194 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)); 2198 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC));
2195 dep = (xfs_dir2_data_entry_t *) 2199 dep = (xfs_dir2_data_entry_t *)
2196 ((char *)hdr + 2200 ((char *)hdr +
2197 xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address))); 2201 xfs_dir2_dataptr_to_off(args->geo,
2202 be32_to_cpu(lep->address)));
2198 ASSERT(inum != be64_to_cpu(dep->inumber)); 2203 ASSERT(inum != be64_to_cpu(dep->inumber));
2199 /* 2204 /*
2200 * Fill in the new inode number and log the entry. 2205 * Fill in the new inode number and log the entry.
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 18e3086bf933..071b685abcbb 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -48,19 +48,18 @@ xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by)
48 * Convert byte in space to (DB) block 48 * Convert byte in space to (DB) block
49 */ 49 */
50static inline xfs_dir2_db_t 50static inline xfs_dir2_db_t
51xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by) 51xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
52{ 52{
53 return (xfs_dir2_db_t) 53 return (xfs_dir2_db_t)(by >> geo->blklog);
54 (by >> (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog));
55} 54}
56 55
57/* 56/*
58 * Convert dataptr to a block number 57 * Convert dataptr to a block number
59 */ 58 */
60static inline xfs_dir2_db_t 59static inline xfs_dir2_db_t
61xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) 60xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
62{ 61{
63 return xfs_dir2_byte_to_db(mp, xfs_dir2_dataptr_to_byte(dp)); 62 return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp));
64} 63}
65 64
66/* 65/*
@@ -76,9 +75,9 @@ xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
76 * Convert dataptr to a byte offset in a block 75 * Convert dataptr to a byte offset in a block
77 */ 76 */
78static inline xfs_dir2_data_aoff_t 77static inline xfs_dir2_data_aoff_t
79xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) 78xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
80{ 79{
81 return xfs_dir2_byte_to_off(mp->m_dir_geo, xfs_dir2_dataptr_to_byte(dp)); 80 return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp));
82} 81}
83 82
84/* 83/*
@@ -104,20 +103,19 @@ xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
104 * Convert byte in space to (DA) block 103 * Convert byte in space to (DA) block
105 */ 104 */
106static inline xfs_dablk_t 105static inline xfs_dablk_t
107xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by) 106xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
108{ 107{
109 return xfs_dir2_db_to_da(mp->m_dir_geo, xfs_dir2_byte_to_db(mp, by)); 108 return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by));
110} 109}
111 110
112/* 111/*
113 * Convert block and offset to dataptr 112 * Convert block and offset to dataptr
114 */ 113 */
115static inline xfs_dir2_dataptr_t 114static inline xfs_dir2_dataptr_t
116xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db, 115xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
117 xfs_dir2_data_aoff_t o) 116 xfs_dir2_data_aoff_t o)
118{ 117{
119 return xfs_dir2_byte_to_dataptr( 118 return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o));
120 xfs_dir2_db_off_to_byte(mp->m_dir_geo, db, o));
121} 119}
122 120
123/* 121/*
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
index 57e92475cb86..c2a63878d27c 100644
--- a/fs/xfs/xfs_dir2_readdir.c
+++ b/fs/xfs/xfs_dir2_readdir.c
@@ -87,8 +87,10 @@ xfs_dir2_sf_getdents(
87 xfs_dir2_dataptr_t dot_offset; 87 xfs_dir2_dataptr_t dot_offset;
88 xfs_dir2_dataptr_t dotdot_offset; 88 xfs_dir2_dataptr_t dotdot_offset;
89 xfs_ino_t ino; 89 xfs_ino_t ino;
90 struct xfs_da_geometry *geo;
90 91
91 mp = dp->i_mount; 92 mp = dp->i_mount;
93 geo = mp->m_dir_geo;
92 94
93 ASSERT(dp->i_df.if_flags & XFS_IFINLINE); 95 ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
94 /* 96 /*
@@ -109,7 +111,7 @@ xfs_dir2_sf_getdents(
109 /* 111 /*
110 * If the block number in the offset is out of range, we're done. 112 * If the block number in the offset is out of range, we're done.
111 */ 113 */
112 if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk) 114 if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > mp->m_dirdatablk)
113 return 0; 115 return 0;
114 116
115 /* 117 /*
@@ -118,9 +120,9 @@ xfs_dir2_sf_getdents(
118 * XXX(hch): the second argument is sometimes 0 and sometimes 120 * XXX(hch): the second argument is sometimes 0 and sometimes
119 * mp->m_dirdatablk. 121 * mp->m_dirdatablk.
120 */ 122 */
121 dot_offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 123 dot_offset = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk,
122 dp->d_ops->data_dot_offset); 124 dp->d_ops->data_dot_offset);
123 dotdot_offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 125 dotdot_offset = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk,
124 dp->d_ops->data_dotdot_offset); 126 dp->d_ops->data_dotdot_offset);
125 127
126 /* 128 /*
@@ -149,7 +151,7 @@ xfs_dir2_sf_getdents(
149 for (i = 0; i < sfp->count; i++) { 151 for (i = 0; i < sfp->count; i++) {
150 __uint8_t filetype; 152 __uint8_t filetype;
151 153
152 off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 154 off = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk,
153 xfs_dir2_sf_get_offset(sfep)); 155 xfs_dir2_sf_get_offset(sfep));
154 156
155 if (ctx->pos > off) { 157 if (ctx->pos > off) {
@@ -166,7 +168,7 @@ xfs_dir2_sf_getdents(
166 sfep = dp->d_ops->sf_nextentry(sfp, sfep); 168 sfep = dp->d_ops->sf_nextentry(sfp, sfep);
167 } 169 }
168 170
169 ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & 171 ctx->pos = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk + 1, 0) &
170 0x7fffffff; 172 0x7fffffff;
171 return 0; 173 return 0;
172} 174}
@@ -190,12 +192,14 @@ xfs_dir2_block_getdents(
190 char *ptr; /* current data entry */ 192 char *ptr; /* current data entry */
191 int wantoff; /* starting block offset */ 193 int wantoff; /* starting block offset */
192 xfs_off_t cook; 194 xfs_off_t cook;
195 struct xfs_da_geometry *geo;
193 196
194 mp = dp->i_mount; 197 mp = dp->i_mount;
198 geo = mp->m_dir_geo;
195 /* 199 /*
196 * If the block number in the offset is out of range, we're done. 200 * If the block number in the offset is out of range, we're done.
197 */ 201 */
198 if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk) 202 if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > mp->m_dirdatablk)
199 return 0; 203 return 0;
200 204
201 error = xfs_dir3_block_read(NULL, dp, &bp); 205 error = xfs_dir3_block_read(NULL, dp, &bp);
@@ -206,7 +210,7 @@ xfs_dir2_block_getdents(
206 * Extract the byte offset we start at from the seek pointer. 210 * Extract the byte offset we start at from the seek pointer.
207 * We'll skip entries before this. 211 * We'll skip entries before this.
208 */ 212 */
209 wantoff = xfs_dir2_dataptr_to_off(mp, ctx->pos); 213 wantoff = xfs_dir2_dataptr_to_off(geo, ctx->pos);
210 hdr = bp->b_addr; 214 hdr = bp->b_addr;
211 xfs_dir3_data_check(dp, bp); 215 xfs_dir3_data_check(dp, bp);
212 /* 216 /*
@@ -244,7 +248,7 @@ xfs_dir2_block_getdents(
244 if ((char *)dep - (char *)hdr < wantoff) 248 if ((char *)dep - (char *)hdr < wantoff)
245 continue; 249 continue;
246 250
247 cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 251 cook = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk,
248 (char *)dep - (char *)hdr); 252 (char *)dep - (char *)hdr);
249 253
250 ctx->pos = cook & 0x7fffffff; 254 ctx->pos = cook & 0x7fffffff;
@@ -264,7 +268,7 @@ xfs_dir2_block_getdents(
264 * Reached the end of the block. 268 * Reached the end of the block.
265 * Set the offset to a non-existent block 1 and return. 269 * Set the offset to a non-existent block 1 and return.
266 */ 270 */
267 ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & 271 ctx->pos = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk + 1, 0) &
268 0x7fffffff; 272 0x7fffffff;
269 xfs_trans_brelse(NULL, bp); 273 xfs_trans_brelse(NULL, bp);
270 return 0; 274 return 0;
@@ -300,6 +304,7 @@ xfs_dir2_leaf_readbuf(
300 int length; 304 int length;
301 int i; 305 int i;
302 int j; 306 int j;
307 struct xfs_da_geometry *geo = mp->m_dir_geo;
303 308
304 /* 309 /*
305 * If we have a buffer, we need to release it and 310 * If we have a buffer, we need to release it and
@@ -342,14 +347,14 @@ xfs_dir2_leaf_readbuf(
342 * run out of data blocks, get some more mappings. 347 * run out of data blocks, get some more mappings.
343 */ 348 */
344 if (1 + mip->ra_want > mip->map_blocks && 349 if (1 + mip->ra_want > mip->map_blocks &&
345 mip->map_off < xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET)) { 350 mip->map_off < xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET)) {
346 /* 351 /*
347 * Get more bmaps, fill in after the ones 352 * Get more bmaps, fill in after the ones
348 * we already have in the table. 353 * we already have in the table.
349 */ 354 */
350 mip->nmap = mip->map_size - mip->map_valid; 355 mip->nmap = mip->map_size - mip->map_valid;
351 error = xfs_bmapi_read(dp, mip->map_off, 356 error = xfs_bmapi_read(dp, mip->map_off,
352 xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET) - 357 xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET) -
353 mip->map_off, 358 mip->map_off,
354 &map[mip->map_valid], &mip->nmap, 0); 359 &map[mip->map_valid], &mip->nmap, 0);
355 360
@@ -370,7 +375,7 @@ xfs_dir2_leaf_readbuf(
370 i = mip->map_valid + mip->nmap - 1; 375 i = mip->map_valid + mip->nmap - 1;
371 mip->map_off = map[i].br_startoff + map[i].br_blockcount; 376 mip->map_off = map[i].br_startoff + map[i].br_blockcount;
372 } else 377 } else
373 mip->map_off = xfs_dir2_byte_to_da(mp, 378 mip->map_off = xfs_dir2_byte_to_da(geo,
374 XFS_DIR2_LEAF_OFFSET); 379 XFS_DIR2_LEAF_OFFSET);
375 380
376 /* 381 /*
@@ -396,14 +401,14 @@ xfs_dir2_leaf_readbuf(
396 * No valid mappings, so no more data blocks. 401 * No valid mappings, so no more data blocks.
397 */ 402 */
398 if (!mip->map_valid) { 403 if (!mip->map_valid) {
399 *curoff = xfs_dir2_da_to_byte(mp->m_dir_geo, mip->map_off); 404 *curoff = xfs_dir2_da_to_byte(geo, mip->map_off);
400 goto out; 405 goto out;
401 } 406 }
402 407
403 /* 408 /*
404 * Read the directory block starting at the first mapping. 409 * Read the directory block starting at the first mapping.
405 */ 410 */
406 mip->curdb = xfs_dir2_da_to_db(mp->m_dir_geo, map->br_startoff); 411 mip->curdb = xfs_dir2_da_to_db(geo, map->br_startoff);
407 error = xfs_dir3_data_read(NULL, dp, map->br_startoff, 412 error = xfs_dir3_data_read(NULL, dp, map->br_startoff,
408 map->br_blockcount >= mp->m_dirblkfsbs ? 413 map->br_blockcount >= mp->m_dirblkfsbs ?
409 XFS_FSB_TO_DADDR(mp, map->br_startblock) : -1, &bp); 414 XFS_FSB_TO_DADDR(mp, map->br_startblock) : -1, &bp);
@@ -504,6 +509,7 @@ xfs_dir2_leaf_getdents(
504 xfs_dir2_off_t newoff; /* new curoff after new blk */ 509 xfs_dir2_off_t newoff; /* new curoff after new blk */
505 char *ptr = NULL; /* pointer to current data */ 510 char *ptr = NULL; /* pointer to current data */
506 struct xfs_dir2_leaf_map_info *map_info; 511 struct xfs_dir2_leaf_map_info *map_info;
512 struct xfs_da_geometry *geo;
507 513
508 /* 514 /*
509 * If the offset is at or past the largest allowed value, 515 * If the offset is at or past the largest allowed value,
@@ -513,6 +519,7 @@ xfs_dir2_leaf_getdents(
513 return 0; 519 return 0;
514 520
515 mp = dp->i_mount; 521 mp = dp->i_mount;
522 geo = mp->m_dir_geo;
516 523
517 /* 524 /*
518 * Set up to bmap a number of blocks based on the caller's 525 * Set up to bmap a number of blocks based on the caller's
@@ -536,8 +543,8 @@ xfs_dir2_leaf_getdents(
536 * Force this conversion through db so we truncate the offset 543 * Force this conversion through db so we truncate the offset
537 * down to get the start of the data block. 544 * down to get the start of the data block.
538 */ 545 */
539 map_info->map_off = xfs_dir2_db_to_da(mp->m_dir_geo, 546 map_info->map_off = xfs_dir2_db_to_da(geo,
540 xfs_dir2_byte_to_db(mp, curoff)); 547 xfs_dir2_byte_to_db(geo, curoff));
541 548
542 /* 549 /*
543 * Loop over directory entries until we reach the end offset. 550 * Loop over directory entries until we reach the end offset.
@@ -571,7 +578,7 @@ xfs_dir2_leaf_getdents(
571 * Make sure we're in the right block. 578 * Make sure we're in the right block.
572 */ 579 */
573 else if (curoff > newoff) 580 else if (curoff > newoff)
574 ASSERT(xfs_dir2_byte_to_db(mp, curoff) == 581 ASSERT(xfs_dir2_byte_to_db(geo, curoff) ==
575 map_info->curdb); 582 map_info->curdb);
576 hdr = bp->b_addr; 583 hdr = bp->b_addr;
577 xfs_dir3_data_check(dp, bp); 584 xfs_dir3_data_check(dp, bp);
@@ -608,8 +615,8 @@ xfs_dir2_leaf_getdents(
608 * Now set our real offset. 615 * Now set our real offset.
609 */ 616 */
610 curoff = 617 curoff =
611 xfs_dir2_db_off_to_byte(mp->m_dir_geo, 618 xfs_dir2_db_off_to_byte(geo,
612 xfs_dir2_byte_to_db(mp, curoff), 619 xfs_dir2_byte_to_db(geo, curoff),
613 (char *)ptr - (char *)hdr); 620 (char *)ptr - (char *)hdr);
614 if (ptr >= (char *)hdr + mp->m_dirblksize) { 621 if (ptr >= (char *)hdr + mp->m_dirblksize) {
615 continue; 622 continue;
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 7aab8ec117ad..4dc4193bdf1e 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -104,8 +104,8 @@ xfs_dir2_block_sfsize(
104 /* 104 /*
105 * Calculate the pointer to the entry at hand. 105 * Calculate the pointer to the entry at hand.
106 */ 106 */
107 dep = (xfs_dir2_data_entry_t *) 107 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
108 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, addr)); 108 xfs_dir2_dataptr_to_off(mp->m_dir_geo, addr));
109 /* 109 /*
110 * Detect . and .., so we can special-case them. 110 * Detect . and .., so we can special-case them.
111 * . is not included in sf directories. 111 * . is not included in sf directories.