Skip to content

Commit 792ef27

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: simplify sector number calculation in xfs_zero_extent
xfs_zero_extent does some really odd gymnstics to calculate the block layer sectors numbers passed to blkdev_issue_zeroout. This is because it used to call sb_issue_zeroout and the calculations in that helper got open coded here in the rather misleadingly named commit 3dc2916 ("dax: use sb_issue_zerout instead of calling dax_clear_sectors"). Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 8b9b261 commit 792ef27

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

fs/xfs/xfs_bmap_util.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,17 @@ xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
4747

4848
/*
4949
* Routine to zero an extent on disk allocated to the specific inode.
50-
*
51-
* The VFS functions take a linearised filesystem block offset, so we have to
52-
* convert the sparse xfs fsb to the right format first.
53-
* VFS types are real funky, too.
5450
*/
5551
int
5652
xfs_zero_extent(
5753
struct xfs_inode *ip,
5854
xfs_fsblock_t start_fsb,
5955
xfs_off_t count_fsb)
6056
{
61-
struct xfs_mount *mp = ip->i_mount;
62-
struct xfs_buftarg *target = xfs_inode_buftarg(ip);
63-
xfs_daddr_t sector = xfs_fsb_to_db(ip, start_fsb);
64-
sector_t block = XFS_BB_TO_FSBT(mp, sector);
65-
66-
return blkdev_issue_zeroout(target->bt_bdev,
67-
block << (mp->m_super->s_blocksize_bits - 9),
68-
count_fsb << (mp->m_super->s_blocksize_bits - 9),
69-
GFP_KERNEL, 0);
57+
return blkdev_issue_zeroout(xfs_inode_buftarg(ip)->bt_bdev,
58+
xfs_fsb_to_db(ip, start_fsb),
59+
XFS_FSB_TO_BB(ip->i_mount, count_fsb),
60+
GFP_KERNEL, 0);
7061
}
7162

7263
/*

0 commit comments

Comments
 (0)