Commit 7348b322 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: xfs_bmap_punch_delalloc_range() should take a byte range

All the callers of xfs_bmap_punch_delalloc_range() jump through
hoops to convert a byte range to filesystem blocks before calling
xfs_bmap_punch_delalloc_range(). Instead, pass the byte range to
xfs_bmap_punch_delalloc_range() and have it do the conversion to
filesystem blocks internally.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent f43dc4dc
...@@ -114,9 +114,8 @@ xfs_end_ioend( ...@@ -114,9 +114,8 @@ xfs_end_ioend(
if (unlikely(error)) { if (unlikely(error)) {
if (ioend->io_flags & IOMAP_F_SHARED) { if (ioend->io_flags & IOMAP_F_SHARED) {
xfs_reflink_cancel_cow_range(ip, offset, size, true); xfs_reflink_cancel_cow_range(ip, offset, size, true);
xfs_bmap_punch_delalloc_range(ip, xfs_bmap_punch_delalloc_range(ip, offset,
XFS_B_TO_FSBT(mp, offset), offset + size);
XFS_B_TO_FSB(mp, size));
} }
goto done; goto done;
} }
...@@ -455,12 +454,8 @@ xfs_discard_folio( ...@@ -455,12 +454,8 @@ xfs_discard_folio(
struct folio *folio, struct folio *folio,
loff_t pos) loff_t pos)
{ {
struct inode *inode = folio->mapping->host; struct xfs_inode *ip = XFS_I(folio->mapping->host);
struct xfs_inode *ip = XFS_I(inode);
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
size_t offset = offset_in_folio(folio, pos);
xfs_fileoff_t start_fsb = XFS_B_TO_FSBT(mp, pos);
xfs_fileoff_t pageoff_fsb = XFS_B_TO_FSBT(mp, offset);
int error; int error;
if (xfs_is_shutdown(mp)) if (xfs_is_shutdown(mp))
...@@ -470,8 +465,9 @@ xfs_discard_folio( ...@@ -470,8 +465,9 @@ xfs_discard_folio(
"page discard on page "PTR_FMT", inode 0x%llx, pos %llu.", "page discard on page "PTR_FMT", inode 0x%llx, pos %llu.",
folio, ip->i_ino, pos); folio, ip->i_ino, pos);
error = xfs_bmap_punch_delalloc_range(ip, start_fsb, error = xfs_bmap_punch_delalloc_range(ip, pos,
i_blocks_per_folio(inode, folio) - pageoff_fsb); round_up(pos, folio_size(folio)));
if (error && !xfs_is_shutdown(mp)) if (error && !xfs_is_shutdown(mp))
xfs_alert(mp, "page discard unable to remove delalloc mapping."); xfs_alert(mp, "page discard unable to remove delalloc mapping.");
} }
......
...@@ -590,11 +590,13 @@ xfs_getbmap( ...@@ -590,11 +590,13 @@ xfs_getbmap(
int int
xfs_bmap_punch_delalloc_range( xfs_bmap_punch_delalloc_range(
struct xfs_inode *ip, struct xfs_inode *ip,
xfs_fileoff_t start_fsb, xfs_off_t start_byte,
xfs_fileoff_t length) xfs_off_t end_byte)
{ {
struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = &ip->i_df; struct xfs_ifork *ifp = &ip->i_df;
xfs_fileoff_t end_fsb = start_fsb + length; xfs_fileoff_t start_fsb = XFS_B_TO_FSBT(mp, start_byte);
xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, end_byte);
struct xfs_bmbt_irec got, del; struct xfs_bmbt_irec got, del;
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
int error = 0; int error = 0;
...@@ -607,7 +609,7 @@ xfs_bmap_punch_delalloc_range( ...@@ -607,7 +609,7 @@ xfs_bmap_punch_delalloc_range(
while (got.br_startoff + got.br_blockcount > start_fsb) { while (got.br_startoff + got.br_blockcount > start_fsb) {
del = got; del = got;
xfs_trim_extent(&del, start_fsb, length); xfs_trim_extent(&del, start_fsb, end_fsb - start_fsb);
/* /*
* A delete can push the cursor forward. Step back to the * A delete can push the cursor forward. Step back to the
......
...@@ -31,7 +31,7 @@ xfs_bmap_rtalloc(struct xfs_bmalloca *ap) ...@@ -31,7 +31,7 @@ xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
#endif /* CONFIG_XFS_RT */ #endif /* CONFIG_XFS_RT */
int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip, int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
xfs_fileoff_t start_fsb, xfs_fileoff_t length); xfs_off_t start_byte, xfs_off_t end_byte);
struct kgetbmap { struct kgetbmap {
__s64 bmv_offset; /* file offset of segment in blocks */ __s64 bmv_offset; /* file offset of segment in blocks */
......
...@@ -1126,12 +1126,8 @@ xfs_buffered_write_delalloc_punch( ...@@ -1126,12 +1126,8 @@ xfs_buffered_write_delalloc_punch(
loff_t offset, loff_t offset,
loff_t length) loff_t length)
{ {
struct xfs_mount *mp = XFS_M(inode->i_sb); return xfs_bmap_punch_delalloc_range(XFS_I(inode), offset,
xfs_fileoff_t start_fsb = XFS_B_TO_FSBT(mp, offset); offset + length);
xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, offset + length);
return xfs_bmap_punch_delalloc_range(XFS_I(inode), start_fsb,
end_fsb - start_fsb);
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment