diff options
author | Christoph Hellwig <hch@lst.de> | 2016-11-29 22:33:25 -0500 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2016-11-29 22:33:25 -0500 |
commit | 6552321831dce87ff5c466a55b58d472732caadc (patch) | |
tree | 84f3de7b89690c84fd13e2efa7a85d4918d342e3 /fs/xfs/xfs_reflink.c | |
parent | f8319483f57f1ca22370f4150bb990aca7728a67 (diff) |
xfs: remove i_iolock and use i_rwsem in the VFS inode instead
This patch drops the XFS-own i_iolock and uses the VFS i_rwsem which
recently replaced i_mutex instead. This means we only have to take
one lock instead of two in many fast path operations, and we can
also shrink the xfs_inode structure. Thanks to the xfs_ilock family
there is very little churn, the only thing of note is that we need
to switch to use the lock_two_directory helper for taking the i_rwsem
on two inodes in a few places to make sure our lock order matches
the one used in the VFS.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Jens Axboe <axboe@fb.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_reflink.c')
-rw-r--r-- | fs/xfs/xfs_reflink.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index becf2465dd23..88fd03c66e99 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c | |||
@@ -1251,13 +1251,11 @@ xfs_reflink_remap_range( | |||
1251 | return -EIO; | 1251 | return -EIO; |
1252 | 1252 | ||
1253 | /* Lock both files against IO */ | 1253 | /* Lock both files against IO */ |
1254 | if (same_inode) { | 1254 | lock_two_nondirectories(inode_in, inode_out); |
1255 | xfs_ilock(src, XFS_IOLOCK_EXCL); | 1255 | if (same_inode) |
1256 | xfs_ilock(src, XFS_MMAPLOCK_EXCL); | 1256 | xfs_ilock(src, XFS_MMAPLOCK_EXCL); |
1257 | } else { | 1257 | else |
1258 | xfs_lock_two_inodes(src, dest, XFS_IOLOCK_EXCL); | ||
1259 | xfs_lock_two_inodes(src, dest, XFS_MMAPLOCK_EXCL); | 1258 | xfs_lock_two_inodes(src, dest, XFS_MMAPLOCK_EXCL); |
1260 | } | ||
1261 | 1259 | ||
1262 | /* Don't touch certain kinds of inodes */ | 1260 | /* Don't touch certain kinds of inodes */ |
1263 | ret = -EPERM; | 1261 | ret = -EPERM; |
@@ -1402,11 +1400,9 @@ xfs_reflink_remap_range( | |||
1402 | 1400 | ||
1403 | out_unlock: | 1401 | out_unlock: |
1404 | xfs_iunlock(src, XFS_MMAPLOCK_EXCL); | 1402 | xfs_iunlock(src, XFS_MMAPLOCK_EXCL); |
1405 | xfs_iunlock(src, XFS_IOLOCK_EXCL); | 1403 | if (!same_inode) |
1406 | if (src->i_ino != dest->i_ino) { | ||
1407 | xfs_iunlock(dest, XFS_MMAPLOCK_EXCL); | 1404 | xfs_iunlock(dest, XFS_MMAPLOCK_EXCL); |
1408 | xfs_iunlock(dest, XFS_IOLOCK_EXCL); | 1405 | unlock_two_nondirectories(inode_in, inode_out); |
1409 | } | ||
1410 | if (ret) | 1406 | if (ret) |
1411 | trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_); | 1407 | trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_); |
1412 | return ret; | 1408 | return ret; |