mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
xfs: don't bounce the iolock between free_{eof,cow}blocks
Since xfs_inode_free_eofblocks and xfs_inode_free_cowblocks are now internal static functions, we can save ourselves a cycling of the iolock by passing the lock state out to xfs_blockgc_scan_inode and letting it do all the unlocking. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
47bd6d3457
commit
0fa4a10a2f
1 changed files with 21 additions and 22 deletions
|
@ -1283,11 +1283,11 @@ xfs_reclaim_worker(
|
||||||
STATIC int
|
STATIC int
|
||||||
xfs_inode_free_eofblocks(
|
xfs_inode_free_eofblocks(
|
||||||
struct xfs_inode *ip,
|
struct xfs_inode *ip,
|
||||||
void *args)
|
void *args,
|
||||||
|
unsigned int *lockflags)
|
||||||
{
|
{
|
||||||
struct xfs_eofblocks *eofb = args;
|
struct xfs_eofblocks *eofb = args;
|
||||||
bool wait;
|
bool wait;
|
||||||
int ret;
|
|
||||||
|
|
||||||
wait = eofb && (eofb->eof_flags & XFS_EOF_FLAGS_SYNC);
|
wait = eofb && (eofb->eof_flags & XFS_EOF_FLAGS_SYNC);
|
||||||
|
|
||||||
|
@ -1320,11 +1320,9 @@ xfs_inode_free_eofblocks(
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*lockflags |= XFS_IOLOCK_EXCL;
|
||||||
|
|
||||||
ret = xfs_free_eofblocks(ip);
|
return xfs_free_eofblocks(ip);
|
||||||
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1493,7 +1491,8 @@ xfs_prep_free_cowblocks(
|
||||||
STATIC int
|
STATIC int
|
||||||
xfs_inode_free_cowblocks(
|
xfs_inode_free_cowblocks(
|
||||||
struct xfs_inode *ip,
|
struct xfs_inode *ip,
|
||||||
void *args)
|
void *args,
|
||||||
|
unsigned int *lockflags)
|
||||||
{
|
{
|
||||||
struct xfs_eofblocks *eofb = args;
|
struct xfs_eofblocks *eofb = args;
|
||||||
bool wait;
|
bool wait;
|
||||||
|
@ -1514,16 +1513,20 @@ xfs_inode_free_cowblocks(
|
||||||
* If the caller is waiting, return -EAGAIN to keep the background
|
* If the caller is waiting, return -EAGAIN to keep the background
|
||||||
* scanner moving and revisit the inode in a subsequent pass.
|
* scanner moving and revisit the inode in a subsequent pass.
|
||||||
*/
|
*/
|
||||||
if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
|
if (!(*lockflags & XFS_IOLOCK_EXCL) &&
|
||||||
|
!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
|
||||||
if (wait)
|
if (wait)
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*lockflags |= XFS_IOLOCK_EXCL;
|
||||||
|
|
||||||
if (!xfs_ilock_nowait(ip, XFS_MMAPLOCK_EXCL)) {
|
if (!xfs_ilock_nowait(ip, XFS_MMAPLOCK_EXCL)) {
|
||||||
if (wait)
|
if (wait)
|
||||||
ret = -EAGAIN;
|
return -EAGAIN;
|
||||||
goto out_iolock;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*lockflags |= XFS_MMAPLOCK_EXCL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check again, nobody else should be able to dirty blocks or change
|
* Check again, nobody else should be able to dirty blocks or change
|
||||||
|
@ -1531,11 +1534,6 @@ xfs_inode_free_cowblocks(
|
||||||
*/
|
*/
|
||||||
if (xfs_prep_free_cowblocks(ip))
|
if (xfs_prep_free_cowblocks(ip))
|
||||||
ret = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, false);
|
ret = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, false);
|
||||||
|
|
||||||
xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
|
|
||||||
out_iolock:
|
|
||||||
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1593,17 +1591,18 @@ xfs_blockgc_scan_inode(
|
||||||
struct xfs_inode *ip,
|
struct xfs_inode *ip,
|
||||||
void *args)
|
void *args)
|
||||||
{
|
{
|
||||||
|
unsigned int lockflags = 0;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = xfs_inode_free_eofblocks(ip, args);
|
error = xfs_inode_free_eofblocks(ip, args, &lockflags);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
goto unlock;
|
||||||
|
|
||||||
error = xfs_inode_free_cowblocks(ip, args);
|
error = xfs_inode_free_cowblocks(ip, args, &lockflags);
|
||||||
if (error)
|
unlock:
|
||||||
return error;
|
if (lockflags)
|
||||||
|
xfs_iunlock(ip, lockflags);
|
||||||
return 0;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Background worker that trims preallocated space. */
|
/* Background worker that trims preallocated space. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue