xfs: move inode locking from xfs_reflink_remap_range to xfs_file_share_range

We need the iolock protection to stabilizie the IS_SWAPFILE and
IS_IMMUTABLE values, as well as preventing new buffered writers
re-dirtying the file data that we just wrote out.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Christoph Hellwig
2016-10-20 15:49:19 +11:00
committed by Dave Chinner
parent a62e82b35b
commit 576177818e
2 changed files with 42 additions and 37 deletions

View File

@@ -1341,15 +1341,6 @@ xfs_reflink_remap_range(
trace_xfs_reflink_remap_range(src, srcoff, len, dest, destoff);
/* Lock both files against IO */
if (src->i_ino == dest->i_ino) {
xfs_ilock(src, XFS_IOLOCK_EXCL);
xfs_ilock(src, XFS_MMAPLOCK_EXCL);
} else {
xfs_lock_two_inodes(src, dest, XFS_IOLOCK_EXCL);
xfs_lock_two_inodes(src, dest, XFS_MMAPLOCK_EXCL);
}
/*
* Check that the extents are the same.
*/
@@ -1401,12 +1392,6 @@ xfs_reflink_remap_range(
goto out_error;
out_error:
xfs_iunlock(src, XFS_MMAPLOCK_EXCL);
xfs_iunlock(src, XFS_IOLOCK_EXCL);
if (src->i_ino != dest->i_ino) {
xfs_iunlock(dest, XFS_MMAPLOCK_EXCL);
xfs_iunlock(dest, XFS_IOLOCK_EXCL);
}
if (error)
trace_xfs_reflink_remap_range_error(dest, error, _RET_IP_);
return error;