Skip to content

Commit

Permalink
xfs: clean up xfs_reflink_remap_blocks call site
Browse files Browse the repository at this point in the history
Move the offset <-> blocks unit conversions into
xfs_reflink_remap_blocks to make the call site less ugly.

Signed-off-by: Darrick J. Wong <[email protected]>
Reviewed-by: Dave Chinner <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
  • Loading branch information
djwong authored and dchinner committed Oct 29, 2018
1 parent 4918ef4 commit 9f04aaf
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions fs/xfs/xfs_reflink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,16 +1119,23 @@ xfs_reflink_remap_extent(
STATIC int
xfs_reflink_remap_blocks(
struct xfs_inode *src,
xfs_fileoff_t srcoff,
loff_t pos_in,
struct xfs_inode *dest,
xfs_fileoff_t destoff,
xfs_filblks_t len,
xfs_off_t new_isize)
loff_t pos_out,
loff_t remap_len)
{
struct xfs_bmbt_irec imap;
xfs_fileoff_t srcoff;
xfs_fileoff_t destoff;
xfs_filblks_t len;
xfs_filblks_t range_len;
xfs_off_t new_isize = pos_out + remap_len;
int nimaps;
int error = 0;
xfs_filblks_t range_len;

destoff = XFS_B_TO_FSBT(src->i_mount, pos_out);
srcoff = XFS_B_TO_FSBT(src->i_mount, pos_in);
len = XFS_B_TO_FSB(src->i_mount, remap_len);

/* drange = (destoff, destoff + len); srange = (srcoff, srcoff + len) */
while (len) {
Expand All @@ -1143,7 +1150,7 @@ xfs_reflink_remap_blocks(
error = xfs_bmapi_read(src, srcoff, len, &imap, &nimaps, 0);
xfs_iunlock(src, lock_mode);
if (error)
goto err;
break;
ASSERT(nimaps == 1);

trace_xfs_reflink_remap_imap(src, srcoff, len, XFS_IO_OVERWRITE,
Expand All @@ -1157,11 +1164,11 @@ xfs_reflink_remap_blocks(
error = xfs_reflink_remap_extent(dest, &imap, destoff,
new_isize);
if (error)
goto err;
break;

if (fatal_signal_pending(current)) {
error = -EINTR;
goto err;
break;
}

/* Advance drange/srange */
Expand All @@ -1170,10 +1177,8 @@ xfs_reflink_remap_blocks(
len -= range_len;
}

return 0;

err:
trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_);
if (error)
trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_);
return error;
}

Expand Down Expand Up @@ -1396,8 +1401,6 @@ xfs_reflink_remap_range(
struct inode *inode_out = file_inode(file_out);
struct xfs_inode *dest = XFS_I(inode_out);
struct xfs_mount *mp = src->i_mount;
xfs_fileoff_t sfsbno, dfsbno;
xfs_filblks_t fsblen;
xfs_extlen_t cowextsize;
ssize_t ret;

Expand All @@ -1415,11 +1418,7 @@ xfs_reflink_remap_range(

trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out);

dfsbno = XFS_B_TO_FSBT(mp, pos_out);
sfsbno = XFS_B_TO_FSBT(mp, pos_in);
fsblen = XFS_B_TO_FSB(mp, len);
ret = xfs_reflink_remap_blocks(src, sfsbno, dest, dfsbno, fsblen,
pos_out + len);
ret = xfs_reflink_remap_blocks(src, pos_in, dest, pos_out, len);
if (ret)
goto out_unlock;

Expand Down

0 comments on commit 9f04aaf

Please sign in to comment.