Commit 1e190f8e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: improve the IOMAP_NOWAIT check for COW inodes

Only bail out once we know that a COW allocation is actually required,
similar to how we handle normal data fork allocations.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 5c5b6f75
...@@ -693,15 +693,8 @@ xfs_ilock_for_iomap( ...@@ -693,15 +693,8 @@ xfs_ilock_for_iomap(
* COW writes may allocate delalloc space or convert unwritten COW * COW writes may allocate delalloc space or convert unwritten COW
* extents, so we need to make sure to take the lock exclusively here. * extents, so we need to make sure to take the lock exclusively here.
*/ */
if (xfs_is_cow_inode(ip) && is_write) { if (xfs_is_cow_inode(ip) && is_write)
/*
* FIXME: It could still overwrite on unshared extents and not
* need allocation.
*/
if (flags & IOMAP_NOWAIT)
return -EAGAIN;
mode = XFS_ILOCK_EXCL; mode = XFS_ILOCK_EXCL;
}
/* /*
* Extents not yet cached requires exclusive access, don't block. This * Extents not yet cached requires exclusive access, don't block. This
...@@ -769,12 +762,6 @@ xfs_direct_write_iomap_begin( ...@@ -769,12 +762,6 @@ xfs_direct_write_iomap_begin(
if (offset + length > i_size_read(inode)) if (offset + length > i_size_read(inode))
iomap_flags |= IOMAP_F_DIRTY; iomap_flags |= IOMAP_F_DIRTY;
/*
* Lock the inode in the manner required for the specified operation and
* check for as many conditions that would result in blocking as
* possible. This removes most of the non-blocking checks from the
* mapping code below.
*/
error = xfs_ilock_for_iomap(ip, flags, &lockmode); error = xfs_ilock_for_iomap(ip, flags, &lockmode);
if (error) if (error)
return error; return error;
...@@ -784,11 +771,11 @@ xfs_direct_write_iomap_begin( ...@@ -784,11 +771,11 @@ xfs_direct_write_iomap_begin(
if (error) if (error)
goto out_unlock; goto out_unlock;
/*
* Break shared extents if necessary. Checks for non-blocking IO have
* been done up front, so we don't need to do them here.
*/
if (imap_needs_cow(ip, flags, &imap, nimaps)) { if (imap_needs_cow(ip, flags, &imap, nimaps)) {
error = -EAGAIN;
if (flags & IOMAP_NOWAIT)
goto out_unlock;
/* may drop and re-acquire the ilock */ /* may drop and re-acquire the ilock */
error = xfs_reflink_allocate_cow(ip, &imap, &cmap, &shared, error = xfs_reflink_allocate_cow(ip, &imap, &cmap, &shared,
&lockmode, flags & IOMAP_DIRECT); &lockmode, flags & IOMAP_DIRECT);
......
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