Commit 5a15322d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Ben Myers

xfs: avoid the iolock in xfs_free_eofblocks for evicted inodes

Same rational as the last patch - these inodes are not reachable, so
don't bother with locking.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarRich Johnston <rjohnston@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 0b56185b
...@@ -145,11 +145,6 @@ xfs_readlink( ...@@ -145,11 +145,6 @@ xfs_readlink(
return error; return error;
} }
/*
* Flags for xfs_free_eofblocks
*/
#define XFS_FREE_EOF_TRYLOCK (1<<0)
/* /*
* This is called by xfs_inactive to free any blocks beyond eof * This is called by xfs_inactive to free any blocks beyond eof
* when the link count isn't zero and by xfs_dm_punch_hole() when * when the link count isn't zero and by xfs_dm_punch_hole() when
...@@ -159,7 +154,7 @@ STATIC int ...@@ -159,7 +154,7 @@ STATIC int
xfs_free_eofblocks( xfs_free_eofblocks(
xfs_mount_t *mp, xfs_mount_t *mp,
xfs_inode_t *ip, xfs_inode_t *ip,
int flags) bool need_iolock)
{ {
xfs_trans_t *tp; xfs_trans_t *tp;
int error; int error;
...@@ -201,13 +196,11 @@ xfs_free_eofblocks( ...@@ -201,13 +196,11 @@ xfs_free_eofblocks(
*/ */
tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
if (flags & XFS_FREE_EOF_TRYLOCK) { if (need_iolock) {
if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) { if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
return 0; return 0;
} }
} else {
xfs_ilock(ip, XFS_IOLOCK_EXCL);
} }
error = xfs_trans_reserve(tp, 0, error = xfs_trans_reserve(tp, 0,
...@@ -217,7 +210,8 @@ xfs_free_eofblocks( ...@@ -217,7 +210,8 @@ xfs_free_eofblocks(
if (error) { if (error) {
ASSERT(XFS_FORCED_SHUTDOWN(mp)); ASSERT(XFS_FORCED_SHUTDOWN(mp));
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
xfs_iunlock(ip, XFS_IOLOCK_EXCL); if (need_iolock)
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
return error; return error;
} }
...@@ -244,7 +238,10 @@ xfs_free_eofblocks( ...@@ -244,7 +238,10 @@ xfs_free_eofblocks(
error = xfs_trans_commit(tp, error = xfs_trans_commit(tp,
XFS_TRANS_RELEASE_LOG_RES); XFS_TRANS_RELEASE_LOG_RES);
} }
xfs_iunlock(ip, XFS_IOLOCK_EXCL|XFS_ILOCK_EXCL);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (need_iolock)
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
} }
return error; return error;
} }
...@@ -466,8 +463,7 @@ xfs_release( ...@@ -466,8 +463,7 @@ xfs_release(
if (xfs_iflags_test(ip, XFS_IDIRTY_RELEASE)) if (xfs_iflags_test(ip, XFS_IDIRTY_RELEASE))
return 0; return 0;
error = xfs_free_eofblocks(mp, ip, error = xfs_free_eofblocks(mp, ip, true);
XFS_FREE_EOF_TRYLOCK);
if (error) if (error)
return error; return error;
...@@ -524,7 +520,7 @@ xfs_inactive( ...@@ -524,7 +520,7 @@ xfs_inactive(
(!(ip->i_d.di_flags & (!(ip->i_d.di_flags &
(XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) || (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) ||
ip->i_delayed_blks != 0))) { ip->i_delayed_blks != 0))) {
error = xfs_free_eofblocks(mp, ip, 0); error = xfs_free_eofblocks(mp, ip, false);
if (error) if (error)
return VN_INACTIVE_CACHE; return VN_INACTIVE_CACHE;
} }
......
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