mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 22:21:21 +00:00
xfs: provide helper for counting extents from if_bytes
The open-coded pattern: ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t) is all over the xfs code; provide a new helper xfs_iext_count(ifp) to count the number of inline extents in an inode fork. [dchinner: pick up several missed conversions] Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
parent
4dfce57db6
commit
5d829300be
8 changed files with 64 additions and 67 deletions
|
@ -359,9 +359,7 @@ xfs_bmap_count_blocks(
|
|||
mp = ip->i_mount;
|
||||
ifp = XFS_IFORK_PTR(ip, whichfork);
|
||||
if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) {
|
||||
xfs_bmap_count_leaves(ifp, 0,
|
||||
ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t),
|
||||
count);
|
||||
xfs_bmap_count_leaves(ifp, 0, xfs_iext_count(ifp), count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -426,7 +424,7 @@ xfs_getbmapx_fix_eof_hole(
|
|||
ifp = XFS_IFORK_PTR(ip, whichfork);
|
||||
if (!moretocome &&
|
||||
xfs_iext_bno_to_ext(ifp, fileblock, &lastx) &&
|
||||
(lastx == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))-1))
|
||||
(lastx == xfs_iext_count(ifp) - 1))
|
||||
out->bmv_oflags |= BMV_OF_LAST;
|
||||
}
|
||||
|
||||
|
@ -1878,15 +1876,13 @@ xfs_swap_extent_forks(
|
|||
|
||||
switch (ip->i_d.di_format) {
|
||||
case XFS_DINODE_FMT_EXTENTS:
|
||||
/* If the extents fit in the inode, fix the
|
||||
* pointer. Otherwise it's already NULL or
|
||||
* pointing to the extent.
|
||||
/*
|
||||
* If the extents fit in the inode, fix the pointer. Otherwise
|
||||
* it's already NULL or pointing to the extent.
|
||||
*/
|
||||
nextents = ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
||||
if (nextents <= XFS_INLINE_EXTS) {
|
||||
ifp->if_u1.if_extents =
|
||||
ifp->if_u2.if_inline_ext;
|
||||
}
|
||||
nextents = xfs_iext_count(&ip->i_df);
|
||||
if (nextents <= XFS_INLINE_EXTS)
|
||||
ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext;
|
||||
(*src_log_flags) |= XFS_ILOG_DEXT;
|
||||
break;
|
||||
case XFS_DINODE_FMT_BTREE:
|
||||
|
@ -1898,15 +1894,13 @@ xfs_swap_extent_forks(
|
|||
|
||||
switch (tip->i_d.di_format) {
|
||||
case XFS_DINODE_FMT_EXTENTS:
|
||||
/* If the extents fit in the inode, fix the
|
||||
* pointer. Otherwise it's already NULL or
|
||||
* pointing to the extent.
|
||||
/*
|
||||
* If the extents fit in the inode, fix the pointer. Otherwise
|
||||
* it's already NULL or pointing to the extent.
|
||||
*/
|
||||
nextents = tip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
||||
if (nextents <= XFS_INLINE_EXTS) {
|
||||
tifp->if_u1.if_extents =
|
||||
tifp->if_u2.if_inline_ext;
|
||||
}
|
||||
nextents = xfs_iext_count(&tip->i_df);
|
||||
if (nextents <= XFS_INLINE_EXTS)
|
||||
tifp->if_u1.if_extents = tifp->if_u2.if_inline_ext;
|
||||
(*target_log_flags) |= XFS_ILOG_DEXT;
|
||||
break;
|
||||
case XFS_DINODE_FMT_BTREE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue