Commit 9b3b5522 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: convert dir byte/off conversion to xfs_da_geometry

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 8c44a285
...@@ -749,7 +749,7 @@ xfs_dir2_shrink_inode( ...@@ -749,7 +749,7 @@ xfs_dir2_shrink_inode(
/* /*
* If the block isn't the last one in the directory, we're done. * If the block isn't the last one in the directory, we're done.
*/ */
if (dp->i_d.di_size > xfs_dir2_db_off_to_byte(mp, db + 1, 0)) if (dp->i_d.di_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
return 0; return 0;
bno = da; bno = da;
if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) { if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) {
......
...@@ -67,10 +67,9 @@ xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) ...@@ -67,10 +67,9 @@ xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
* Convert byte in space to offset in a block * Convert byte in space to offset in a block
*/ */
static inline xfs_dir2_data_aoff_t static inline xfs_dir2_data_aoff_t
xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by) xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{ {
return (xfs_dir2_data_aoff_t)(by & return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1));
((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) - 1));
} }
/* /*
...@@ -79,18 +78,17 @@ xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by) ...@@ -79,18 +78,17 @@ xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by)
static inline xfs_dir2_data_aoff_t static inline xfs_dir2_data_aoff_t
xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
{ {
return xfs_dir2_byte_to_off(mp, xfs_dir2_dataptr_to_byte(dp)); return xfs_dir2_byte_to_off(mp->m_dir_geo, xfs_dir2_dataptr_to_byte(dp));
} }
/* /*
* Convert block and offset to byte in space * Convert block and offset to byte in space
*/ */
static inline xfs_dir2_off_t static inline xfs_dir2_off_t
xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db, xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
xfs_dir2_data_aoff_t o) xfs_dir2_data_aoff_t o)
{ {
return ((xfs_dir2_off_t)db << return ((xfs_dir2_off_t)db << geo->blklog) + o;
(mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) + o;
} }
/* /*
...@@ -118,7 +116,8 @@ static inline xfs_dir2_dataptr_t ...@@ -118,7 +116,8 @@ static inline xfs_dir2_dataptr_t
xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db, xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db,
xfs_dir2_data_aoff_t o) xfs_dir2_data_aoff_t o)
{ {
return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(mp, db, o)); return xfs_dir2_byte_to_dataptr(
xfs_dir2_db_off_to_byte(mp->m_dir_geo, db, o));
} }
/* /*
...@@ -136,7 +135,8 @@ xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da) ...@@ -136,7 +135,8 @@ xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da)
static inline xfs_dir2_off_t static inline xfs_dir2_off_t
xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da) xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da)
{ {
return xfs_dir2_db_off_to_byte(mp, xfs_dir2_da_to_db(mp, da), 0); return xfs_dir2_db_off_to_byte(mp->m_dir_geo,
xfs_dir2_da_to_db(mp, da), 0);
} }
/* /*
......
...@@ -560,7 +560,8 @@ xfs_dir2_leaf_getdents( ...@@ -560,7 +560,8 @@ xfs_dir2_leaf_getdents(
/* /*
* Having done a read, we need to set a new offset. * Having done a read, we need to set a new offset.
*/ */
newoff = xfs_dir2_db_off_to_byte(mp, map_info->curdb, 0); newoff = xfs_dir2_db_off_to_byte(mp->m_dir_geo,
map_info->curdb, 0);
/* /*
* Start of the current block. * Start of the current block.
*/ */
...@@ -578,7 +579,7 @@ xfs_dir2_leaf_getdents( ...@@ -578,7 +579,7 @@ xfs_dir2_leaf_getdents(
* Find our position in the block. * Find our position in the block.
*/ */
ptr = (char *)dp->d_ops->data_entry_p(hdr); ptr = (char *)dp->d_ops->data_entry_p(hdr);
byteoff = xfs_dir2_byte_to_off(mp, curoff); byteoff = xfs_dir2_byte_to_off(mp->m_dir_geo, curoff);
/* /*
* Skip past the header. * Skip past the header.
*/ */
...@@ -607,7 +608,7 @@ xfs_dir2_leaf_getdents( ...@@ -607,7 +608,7 @@ xfs_dir2_leaf_getdents(
* Now set our real offset. * Now set our real offset.
*/ */
curoff = curoff =
xfs_dir2_db_off_to_byte(mp, xfs_dir2_db_off_to_byte(mp->m_dir_geo,
xfs_dir2_byte_to_db(mp, curoff), xfs_dir2_byte_to_db(mp, curoff),
(char *)ptr - (char *)hdr); (char *)ptr - (char *)hdr);
if (ptr >= (char *)hdr + mp->m_dirblksize) { if (ptr >= (char *)hdr + mp->m_dirblksize) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment