mirror of https://gitee.com/openkylin/linux.git
xfs: convert dir byte/off 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>
This commit is contained in:
parent
8c44a28561
commit
9b3b5522d3
|
@ -749,7 +749,7 @@ xfs_dir2_shrink_inode(
|
|||
/*
|
||||
* 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;
|
||||
bno = da;
|
||||
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)
|
|||
* Convert byte in space to offset in a block
|
||||
*/
|
||||
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 &
|
||||
((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) - 1));
|
||||
return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
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
|
||||
*/
|
||||
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)
|
||||
{
|
||||
return ((xfs_dir2_off_t)db <<
|
||||
(mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) + o;
|
||||
return ((xfs_dir2_off_t)db << geo->blklog) + o;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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_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)
|
|||
static inline xfs_dir2_off_t
|
||||
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(
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
@ -578,7 +579,7 @@ xfs_dir2_leaf_getdents(
|
|||
* Find our position in the block.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -607,7 +608,7 @@ xfs_dir2_leaf_getdents(
|
|||
* Now set our real offset.
|
||||
*/
|
||||
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),
|
||||
(char *)ptr - (char *)hdr);
|
||||
if (ptr >= (char *)hdr + mp->m_dirblksize) {
|
||||
|
|
Loading…
Reference in New Issue