Commit 9f04aaff authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Dave Chinner

xfs: clean up xfs_reflink_remap_blocks call site

Move the offset <-> blocks unit conversions into
xfs_reflink_remap_blocks to make the call site less ugly.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 4918ef4e
...@@ -1119,16 +1119,23 @@ xfs_reflink_remap_extent( ...@@ -1119,16 +1119,23 @@ xfs_reflink_remap_extent(
STATIC int STATIC int
xfs_reflink_remap_blocks( xfs_reflink_remap_blocks(
struct xfs_inode *src, struct xfs_inode *src,
xfs_fileoff_t srcoff, loff_t pos_in,
struct xfs_inode *dest, struct xfs_inode *dest,
xfs_fileoff_t destoff, loff_t pos_out,
xfs_filblks_t len, loff_t remap_len)
xfs_off_t new_isize)
{ {
struct xfs_bmbt_irec imap; 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 nimaps;
int error = 0; 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) */ /* drange = (destoff, destoff + len); srange = (srcoff, srcoff + len) */
while (len) { while (len) {
...@@ -1143,7 +1150,7 @@ xfs_reflink_remap_blocks( ...@@ -1143,7 +1150,7 @@ xfs_reflink_remap_blocks(
error = xfs_bmapi_read(src, srcoff, len, &imap, &nimaps, 0); error = xfs_bmapi_read(src, srcoff, len, &imap, &nimaps, 0);
xfs_iunlock(src, lock_mode); xfs_iunlock(src, lock_mode);
if (error) if (error)
goto err; break;
ASSERT(nimaps == 1); ASSERT(nimaps == 1);
trace_xfs_reflink_remap_imap(src, srcoff, len, XFS_IO_OVERWRITE, trace_xfs_reflink_remap_imap(src, srcoff, len, XFS_IO_OVERWRITE,
...@@ -1157,11 +1164,11 @@ xfs_reflink_remap_blocks( ...@@ -1157,11 +1164,11 @@ xfs_reflink_remap_blocks(
error = xfs_reflink_remap_extent(dest, &imap, destoff, error = xfs_reflink_remap_extent(dest, &imap, destoff,
new_isize); new_isize);
if (error) if (error)
goto err; break;
if (fatal_signal_pending(current)) { if (fatal_signal_pending(current)) {
error = -EINTR; error = -EINTR;
goto err; break;
} }
/* Advance drange/srange */ /* Advance drange/srange */
...@@ -1170,9 +1177,7 @@ xfs_reflink_remap_blocks( ...@@ -1170,9 +1177,7 @@ xfs_reflink_remap_blocks(
len -= range_len; len -= range_len;
} }
return 0; if (error)
err:
trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_); trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_);
return error; return error;
} }
...@@ -1396,8 +1401,6 @@ xfs_reflink_remap_range( ...@@ -1396,8 +1401,6 @@ xfs_reflink_remap_range(
struct inode *inode_out = file_inode(file_out); struct inode *inode_out = file_inode(file_out);
struct xfs_inode *dest = XFS_I(inode_out); struct xfs_inode *dest = XFS_I(inode_out);
struct xfs_mount *mp = src->i_mount; struct xfs_mount *mp = src->i_mount;
xfs_fileoff_t sfsbno, dfsbno;
xfs_filblks_t fsblen;
xfs_extlen_t cowextsize; xfs_extlen_t cowextsize;
ssize_t ret; ssize_t ret;
...@@ -1415,11 +1418,7 @@ xfs_reflink_remap_range( ...@@ -1415,11 +1418,7 @@ xfs_reflink_remap_range(
trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out);
dfsbno = XFS_B_TO_FSBT(mp, pos_out); ret = xfs_reflink_remap_blocks(src, pos_in, dest, pos_out, len);
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);
if (ret) if (ret)
goto out_unlock; goto out_unlock;
......
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