aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-06 01:07:53 -0400
committerDave Chinner <david@fromorbit.com>2014-06-06 01:07:53 -0400
commit2998ab1d450a526a9a3a6292f91239b4fc209db0 (patch)
tree93a2760e30b8801445d624ae776f2c0fb246ae72
parent9b3b5522d3f55215ce51c87b0467926c57a6f182 (diff)
xfs: convert directory dablk 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>
-rw-r--r--fs/xfs/xfs_dir2.c4
-rw-r--r--fs/xfs/xfs_dir2_data.c4
-rw-r--r--fs/xfs/xfs_dir2_leaf.c21
-rw-r--r--fs/xfs/xfs_dir2_node.c41
-rw-r--r--fs/xfs/xfs_dir2_priv.h15
-rw-r--r--fs/xfs/xfs_dir2_readdir.c6
6 files changed, 48 insertions, 43 deletions
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 2047ef1ce8d2..9a2f5532fd9f 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -632,7 +632,7 @@ xfs_dir2_grow_inode(
632 if (error) 632 if (error)
633 return error; 633 return error;
634 634
635 *dbp = xfs_dir2_da_to_db(mp, (xfs_dablk_t)bno); 635 *dbp = xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)bno);
636 636
637 /* 637 /*
638 * Update file's size if this is the data space and it grew. 638 * Update file's size if this is the data space and it grew.
@@ -713,7 +713,7 @@ xfs_dir2_shrink_inode(
713 dp = args->dp; 713 dp = args->dp;
714 mp = dp->i_mount; 714 mp = dp->i_mount;
715 tp = args->trans; 715 tp = args->trans;
716 da = xfs_dir2_db_to_da(mp, db); 716 da = xfs_dir2_db_to_da(args->geo, db);
717 /* 717 /*
718 * Unmap the fsblock(s). 718 * Unmap the fsblock(s).
719 */ 719 */
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index bae8b5b8d1c2..890c94033c3f 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -584,8 +584,8 @@ xfs_dir3_data_init(
584 /* 584 /*
585 * Get the buffer set up for the block. 585 * Get the buffer set up for the block.
586 */ 586 */
587 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, blkno), -1, &bp, 587 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, blkno),
588 XFS_DATA_FORK); 588 -1, &bp, XFS_DATA_FORK);
589 if (error) 589 if (error)
590 return error; 590 return error;
591 bp->b_ops = &xfs_dir3_data_buf_ops; 591 bp->b_ops = &xfs_dir3_data_buf_ops;
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index dc4ef19365b8..046ba4a09eaa 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -350,8 +350,8 @@ xfs_dir3_leaf_get_buf(
350 ASSERT(bno >= xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET) && 350 ASSERT(bno >= xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET) &&
351 bno < xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET)); 351 bno < xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET));
352 352
353 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, bno), -1, &bp, 353 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, bno),
354 XFS_DATA_FORK); 354 -1, &bp, XFS_DATA_FORK);
355 if (error) 355 if (error)
356 return error; 356 return error;
357 357
@@ -403,7 +403,7 @@ xfs_dir2_block_to_leaf(
403 if ((error = xfs_da_grow_inode(args, &blkno))) { 403 if ((error = xfs_da_grow_inode(args, &blkno))) {
404 return error; 404 return error;
405 } 405 }
406 ldb = xfs_dir2_da_to_db(mp, 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(mp, 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.
@@ -828,8 +828,8 @@ xfs_dir2_leaf_addname(
828 * Just read that one in. 828 * Just read that one in.
829 */ 829 */
830 error = xfs_dir3_data_read(tp, dp, 830 error = xfs_dir3_data_read(tp, dp,
831 xfs_dir2_db_to_da(mp, use_block), 831 xfs_dir2_db_to_da(args->geo, use_block),
832 -1, &dbp); 832 -1, &dbp);
833 if (error) { 833 if (error) {
834 xfs_trans_brelse(tp, lbp); 834 xfs_trans_brelse(tp, lbp);
835 return error; 835 return error;
@@ -1269,8 +1269,8 @@ xfs_dir2_leaf_lookup_int(
1269 if (dbp) 1269 if (dbp)
1270 xfs_trans_brelse(tp, dbp); 1270 xfs_trans_brelse(tp, dbp);
1271 error = xfs_dir3_data_read(tp, dp, 1271 error = xfs_dir3_data_read(tp, dp,
1272 xfs_dir2_db_to_da(mp, newdb), 1272 xfs_dir2_db_to_da(args->geo, newdb),
1273 -1, &dbp); 1273 -1, &dbp);
1274 if (error) { 1274 if (error) {
1275 xfs_trans_brelse(tp, lbp); 1275 xfs_trans_brelse(tp, lbp);
1276 return error; 1276 return error;
@@ -1310,8 +1310,8 @@ xfs_dir2_leaf_lookup_int(
1310 if (cidb != curdb) { 1310 if (cidb != curdb) {
1311 xfs_trans_brelse(tp, dbp); 1311 xfs_trans_brelse(tp, dbp);
1312 error = xfs_dir3_data_read(tp, dp, 1312 error = xfs_dir3_data_read(tp, dp,
1313 xfs_dir2_db_to_da(mp, cidb), 1313 xfs_dir2_db_to_da(args->geo, cidb),
1314 -1, &dbp); 1314 -1, &dbp);
1315 if (error) { 1315 if (error) {
1316 xfs_trans_brelse(tp, lbp); 1316 xfs_trans_brelse(tp, lbp);
1317 return error; 1317 return error;
@@ -1609,7 +1609,8 @@ xfs_dir2_leaf_trim_data(
1609 /* 1609 /*
1610 * Read the offending data block. We need its buffer. 1610 * Read the offending data block. We need its buffer.
1611 */ 1611 */
1612 error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(mp, db), -1, &dbp); 1612 error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(args->geo, db),
1613 -1, &dbp);
1613 if (error) 1614 if (error)
1614 return error; 1615 return error;
1615 1616
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 1bcaaa0ffdbd..3b70d56f4e58 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -195,17 +195,18 @@ xfs_dir2_free_try_read(
195 195
196static int 196static int
197xfs_dir3_free_get_buf( 197xfs_dir3_free_get_buf(
198 struct xfs_trans *tp, 198 xfs_da_args_t *args,
199 struct xfs_inode *dp,
200 xfs_dir2_db_t fbno, 199 xfs_dir2_db_t fbno,
201 struct xfs_buf **bpp) 200 struct xfs_buf **bpp)
202{ 201{
202 struct xfs_trans *tp = args->trans;
203 struct xfs_inode *dp = args->dp;
203 struct xfs_mount *mp = dp->i_mount; 204 struct xfs_mount *mp = dp->i_mount;
204 struct xfs_buf *bp; 205 struct xfs_buf *bp;
205 int error; 206 int error;
206 struct xfs_dir3_icfree_hdr hdr; 207 struct xfs_dir3_icfree_hdr hdr;
207 208
208 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, fbno), 209 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, fbno),
209 -1, &bp, XFS_DATA_FORK); 210 -1, &bp, XFS_DATA_FORK);
210 if (error) 211 if (error)
211 return error; 212 return error;
@@ -319,7 +320,7 @@ xfs_dir2_leaf_to_node(
319 /* 320 /*
320 * Get the buffer for the new freespace block. 321 * Get the buffer for the new freespace block.
321 */ 322 */
322 error = xfs_dir3_free_get_buf(tp, dp, fdb, &fbp); 323 error = xfs_dir3_free_get_buf(args, fdb, &fbp);
323 if (error) 324 if (error)
324 return error; 325 return error;
325 326
@@ -605,7 +606,8 @@ xfs_dir2_leafn_lookup_for_addname(
605 xfs_trans_brelse(tp, curbp); 606 xfs_trans_brelse(tp, curbp);
606 607
607 error = xfs_dir2_free_read(tp, dp, 608 error = xfs_dir2_free_read(tp, dp,
608 xfs_dir2_db_to_da(mp, newfdb), 609 xfs_dir2_db_to_da(args->geo,
610 newfdb),
609 &curbp); 611 &curbp);
610 if (error) 612 if (error)
611 return error; 613 return error;
@@ -746,7 +748,8 @@ xfs_dir2_leafn_lookup_for_entry(
746 curbp = state->extrablk.bp; 748 curbp = state->extrablk.bp;
747 } else { 749 } else {
748 error = xfs_dir3_data_read(tp, dp, 750 error = xfs_dir3_data_read(tp, dp,
749 xfs_dir2_db_to_da(mp, newdb), 751 xfs_dir2_db_to_da(args->geo,
752 newdb),
750 -1, &curbp); 753 -1, &curbp);
751 if (error) 754 if (error)
752 return error; 755 return error;
@@ -1246,7 +1249,8 @@ xfs_dir2_leafn_remove(
1246 * read in the free block. 1249 * read in the free block.
1247 */ 1250 */
1248 fdb = dp->d_ops->db_to_fdb(mp, db); 1251 fdb = dp->d_ops->db_to_fdb(mp, db);
1249 error = xfs_dir2_free_read(tp, dp, xfs_dir2_db_to_da(mp, fdb), 1252 error = xfs_dir2_free_read(tp, dp,
1253 xfs_dir2_db_to_da(args->geo, fdb),
1250 &fbp); 1254 &fbp);
1251 if (error) 1255 if (error)
1252 return error; 1256 return error;
@@ -1336,7 +1340,7 @@ xfs_dir2_leafn_split(
1336 /* 1340 /*
1337 * Initialize the new leaf block. 1341 * Initialize the new leaf block.
1338 */ 1342 */
1339 error = xfs_dir3_leaf_get_buf(args, xfs_dir2_da_to_db(mp, blkno), 1343 error = xfs_dir3_leaf_get_buf(args, xfs_dir2_da_to_db(args->geo, blkno),
1340 &newblk->bp, XFS_DIR2_LEAFN_MAGIC); 1344 &newblk->bp, XFS_DIR2_LEAFN_MAGIC);
1341 if (error) 1345 if (error)
1342 return error; 1346 return error;
@@ -1729,7 +1733,7 @@ xfs_dir2_node_addname_int(
1729 1733
1730 if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK))) 1734 if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK)))
1731 return error; 1735 return error;
1732 lastfbno = xfs_dir2_da_to_db(mp, (xfs_dablk_t)fo); 1736 lastfbno = xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)fo);
1733 fbno = ifbno; 1737 fbno = ifbno;
1734 } 1738 }
1735 /* 1739 /*
@@ -1766,8 +1770,8 @@ xfs_dir2_node_addname_int(
1766 * to avoid it. 1770 * to avoid it.
1767 */ 1771 */
1768 error = xfs_dir2_free_try_read(tp, dp, 1772 error = xfs_dir2_free_try_read(tp, dp,
1769 xfs_dir2_db_to_da(mp, fbno), 1773 xfs_dir2_db_to_da(args->geo, fbno),
1770 &fbp); 1774 &fbp);
1771 if (error) 1775 if (error)
1772 return error; 1776 return error;
1773 if (!fbp) 1777 if (!fbp)
@@ -1837,8 +1841,8 @@ xfs_dir2_node_addname_int(
1837 */ 1841 */
1838 fbno = dp->d_ops->db_to_fdb(mp, dbno); 1842 fbno = dp->d_ops->db_to_fdb(mp, dbno);
1839 error = xfs_dir2_free_try_read(tp, dp, 1843 error = xfs_dir2_free_try_read(tp, dp,
1840 xfs_dir2_db_to_da(mp, fbno), 1844 xfs_dir2_db_to_da(args->geo, fbno),
1841 &fbp); 1845 &fbp);
1842 if (error) 1846 if (error)
1843 return error; 1847 return error;
1844 1848
@@ -1878,7 +1882,7 @@ xfs_dir2_node_addname_int(
1878 /* 1882 /*
1879 * Get a buffer for the new block. 1883 * Get a buffer for the new block.
1880 */ 1884 */
1881 error = xfs_dir3_free_get_buf(tp, dp, fbno, &fbp); 1885 error = xfs_dir3_free_get_buf(args, fbno, &fbp);
1882 if (error) 1886 if (error)
1883 return error; 1887 return error;
1884 free = fbp->b_addr; 1888 free = fbp->b_addr;
@@ -1946,7 +1950,8 @@ xfs_dir2_node_addname_int(
1946 /* 1950 /*
1947 * Read the data block in. 1951 * Read the data block in.
1948 */ 1952 */
1949 error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(mp, dbno), 1953 error = xfs_dir3_data_read(tp, dp,
1954 xfs_dir2_db_to_da(args->geo, dbno),
1950 -1, &dbp); 1955 -1, &dbp);
1951 if (error) 1956 if (error)
1952 return error; 1957 return error;
@@ -2265,9 +2270,9 @@ xfs_dir2_node_trim_free(
2265 /* 2270 /*
2266 * Blow the block away. 2271 * Blow the block away.
2267 */ 2272 */
2268 if ((error = 2273 error = xfs_dir2_shrink_inode(args,
2269 xfs_dir2_shrink_inode(args, xfs_dir2_da_to_db(mp, (xfs_dablk_t)fo), 2274 xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)fo), bp);
2270 bp))) { 2275 if (error) {
2271 /* 2276 /*
2272 * Can't fail with ENOSPC since that only happens with no 2277 * Can't fail with ENOSPC since that only happens with no
2273 * space reservation, when breaking up an extent into two 2278 * space reservation, when breaking up an extent into two
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 683828942de1..18e3086bf933 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -95,9 +95,9 @@ xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
95 * Convert block (DB) to block (dablk) 95 * Convert block (DB) to block (dablk)
96 */ 96 */
97static inline xfs_dablk_t 97static inline xfs_dablk_t
98xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db) 98xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
99{ 99{
100 return (xfs_dablk_t)(db << mp->m_sb.sb_dirblklog); 100 return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog));
101} 101}
102 102
103/* 103/*
@@ -106,7 +106,7 @@ xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db)
106static inline xfs_dablk_t 106static inline xfs_dablk_t
107xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by) 107xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by)
108{ 108{
109 return xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, by)); 109 return xfs_dir2_db_to_da(mp->m_dir_geo, xfs_dir2_byte_to_db(mp, by));
110} 110}
111 111
112/* 112/*
@@ -124,19 +124,18 @@ xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db,
124 * Convert block (dablk) to block (DB) 124 * Convert block (dablk) to block (DB)
125 */ 125 */
126static inline xfs_dir2_db_t 126static inline xfs_dir2_db_t
127xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da) 127xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da)
128{ 128{
129 return (xfs_dir2_db_t)(da >> mp->m_sb.sb_dirblklog); 129 return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog));
130} 130}
131 131
132/* 132/*
133 * Convert block (dablk) to byte offset in space 133 * Convert block (dablk) to byte offset in space
134 */ 134 */
135static inline xfs_dir2_off_t 135static inline xfs_dir2_off_t
136xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da) 136xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da)
137{ 137{
138 return xfs_dir2_db_off_to_byte(mp->m_dir_geo, 138 return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0);
139 xfs_dir2_da_to_db(mp, da), 0);
140} 139}
141 140
142/* 141/*
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
index ec912c8f1891..57e92475cb86 100644
--- a/fs/xfs/xfs_dir2_readdir.c
+++ b/fs/xfs/xfs_dir2_readdir.c
@@ -396,14 +396,14 @@ xfs_dir2_leaf_readbuf(
396 * No valid mappings, so no more data blocks. 396 * No valid mappings, so no more data blocks.
397 */ 397 */
398 if (!mip->map_valid) { 398 if (!mip->map_valid) {
399 *curoff = xfs_dir2_da_to_byte(mp, mip->map_off); 399 *curoff = xfs_dir2_da_to_byte(mp->m_dir_geo, mip->map_off);
400 goto out; 400 goto out;
401 } 401 }
402 402
403 /* 403 /*
404 * Read the directory block starting at the first mapping. 404 * Read the directory block starting at the first mapping.
405 */ 405 */
406 mip->curdb = xfs_dir2_da_to_db(mp, map->br_startoff); 406 mip->curdb = xfs_dir2_da_to_db(mp->m_dir_geo, map->br_startoff);
407 error = xfs_dir3_data_read(NULL, dp, map->br_startoff, 407 error = xfs_dir3_data_read(NULL, dp, map->br_startoff,
408 map->br_blockcount >= mp->m_dirblkfsbs ? 408 map->br_blockcount >= mp->m_dirblkfsbs ?
409 XFS_FSB_TO_DADDR(mp, map->br_startblock) : -1, &bp); 409 XFS_FSB_TO_DADDR(mp, map->br_startblock) : -1, &bp);
@@ -536,7 +536,7 @@ xfs_dir2_leaf_getdents(
536 * Force this conversion through db so we truncate the offset 536 * Force this conversion through db so we truncate the offset
537 * down to get the start of the data block. 537 * down to get the start of the data block.
538 */ 538 */
539 map_info->map_off = xfs_dir2_db_to_da(mp, 539 map_info->map_off = xfs_dir2_db_to_da(mp->m_dir_geo,
540 xfs_dir2_byte_to_db(mp, curoff)); 540 xfs_dir2_byte_to_db(mp, curoff));
541 541
542 /* 542 /*