Skip to content

Commit fd7588f

Browse files
author
Darrick J. Wong
committed
xfs: create helpers to deal with rounding xfs_fileoff_t to rtx boundaries
We're about to segment xfs_rtblock_t addresses, so we must create type-specific helpers to do rt extent rounding of file block offsets because the rtb helpers soon will not do the right thing there. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent ea99122 commit fd7588f

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,22 @@ xfs_rtb_roundup_rtx(
135135
return roundup_64(rtbno, mp->m_sb.sb_rextsize);
136136
}
137137

138-
/* Round this rtblock down to the nearest rt extent size. */
138+
/* Round this file block offset up to the nearest rt extent size. */
139139
static inline xfs_rtblock_t
140-
xfs_rtb_rounddown_rtx(
140+
xfs_fileoff_roundup_rtx(
141141
struct xfs_mount *mp,
142-
xfs_rtblock_t rtbno)
142+
xfs_fileoff_t off)
143+
{
144+
return roundup_64(off, mp->m_sb.sb_rextsize);
145+
}
146+
147+
/* Round this file block offset down to the nearest rt extent size. */
148+
static inline xfs_rtblock_t
149+
xfs_fileoff_rounddown_rtx(
150+
struct xfs_mount *mp,
151+
xfs_fileoff_t off)
143152
{
144-
return rounddown_64(rtbno, mp->m_sb.sb_rextsize);
153+
return rounddown_64(off, mp->m_sb.sb_rextsize);
145154
}
146155

147156
/* Convert an rt extent number to a file block offset in the rt bitmap file. */

fs/xfs/xfs_bmap_util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ xfs_can_free_eofblocks(
541541
*/
542542
end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip));
543543
if (xfs_inode_has_bigrtalloc(ip))
544-
end_fsb = xfs_rtb_roundup_rtx(mp, end_fsb);
544+
end_fsb = xfs_fileoff_roundup_rtx(mp, end_fsb);
545545
last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
546546
if (last_fsb <= end_fsb)
547547
return false;
@@ -863,8 +863,8 @@ xfs_free_file_space(
863863

864864
/* We can only free complete realtime extents. */
865865
if (xfs_inode_has_bigrtalloc(ip)) {
866-
startoffset_fsb = xfs_rtb_roundup_rtx(mp, startoffset_fsb);
867-
endoffset_fsb = xfs_rtb_rounddown_rtx(mp, endoffset_fsb);
866+
startoffset_fsb = xfs_fileoff_roundup_rtx(mp, startoffset_fsb);
867+
endoffset_fsb = xfs_fileoff_rounddown_rtx(mp, endoffset_fsb);
868868
}
869869

870870
/*

0 commit comments

Comments
 (0)