Skip to content

Commit

Permalink
Merge tag 'unit-conversion-cleanups-5.14_2021-06-03' of https://git.k…
Browse files Browse the repository at this point in the history
…ernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-5.14-merge2

xfs: various unit conversions

Crafting the realtime file extent size hint fixes revealed various
opportunities to clean up unit conversions, so now that gets its own
series.

* tag 'unit-conversion-cleanups-5.14_2021-06-03' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
  xfs: remove unnecessary shifts
  xfs: clean up open-coded fs block unit conversions
  • Loading branch information
Darrick J. Wong committed Jun 8, 2021
2 parents 9ba0889 + 20bd8e6 commit f52edf6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_inode_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ xfs_inode_validate_extsize(
*/

if (rt_flag)
blocksize_bytes = mp->m_sb.sb_rextsize << mp->m_sb.sb_blocklog;
blocksize_bytes = XFS_FSB_TO_B(mp, mp->m_sb.sb_rextsize);
else
blocksize_bytes = mp->m_sb.sb_blocksize;

Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/xfs_bmap_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ xfs_flush_unmap_range(
xfs_off_t rounding, start, end;
int error;

rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_SIZE);
rounding = max_t(xfs_off_t, mp->m_sb.sb_blocksize, PAGE_SIZE);
start = round_down(offset, rounding);
end = round_up(offset + len, rounding) - 1;

Expand Down Expand Up @@ -1053,9 +1053,9 @@ xfs_prepare_shift(
* extent (after split) during the shift and corrupt the file. Start
* with the block just prior to the start to stabilize the boundary.
*/
offset = round_down(offset, 1 << mp->m_sb.sb_blocklog);
offset = round_down(offset, mp->m_sb.sb_blocksize);
if (offset)
offset -= (1 << mp->m_sb.sb_blocklog);
offset -= mp->m_sb.sb_blocksize;

/*
* Writeback and invalidate cache for the remainder of the file as we're
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/xfs_iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ xfs_stat_blksize(
* always return the realtime extent size.
*/
if (XFS_IS_REALTIME_INODE(ip))
return xfs_get_extsz_hint(ip) << mp->m_sb.sb_blocklog;
return XFS_FSB_TO_B(mp, xfs_get_extsz_hint(ip));

/*
* Allow large block sizes to be reported to userspace programs if the
Expand All @@ -560,7 +560,7 @@ xfs_stat_blksize(
*/
if (mp->m_flags & XFS_MOUNT_LARGEIO) {
if (mp->m_swidth)
return mp->m_swidth << mp->m_sb.sb_blocklog;
return XFS_FSB_TO_B(mp, mp->m_swidth);
if (mp->m_flags & XFS_MOUNT_ALLOCSIZE)
return 1U << mp->m_allocsize_log;
}
Expand Down

0 comments on commit f52edf6

Please sign in to comment.