xfs: make xfs_file_aio_write_checks IOCB_NOWAIT-aware
Ensure we don't block on the iolock, or waiting for I/O in
xfs_file_aio_write_checks if the caller asked to avoid that.
Fixes: 29a5d29ec1 ("xfs: nowait aio support")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
This commit is contained in:
committed by
Darrick J. Wong
parent
f50b8f475a
commit
354be7e3b2
@@ -334,7 +334,14 @@ restart:
|
|||||||
if (error <= 0)
|
if (error <= 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
error = xfs_break_layouts(inode, iolock, BREAK_WRITE);
|
if (iocb->ki_flags & IOCB_NOWAIT) {
|
||||||
|
error = break_layout(inode, false);
|
||||||
|
if (error == -EWOULDBLOCK)
|
||||||
|
error = -EAGAIN;
|
||||||
|
} else {
|
||||||
|
error = xfs_break_layouts(inode, iolock, BREAK_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -345,7 +352,11 @@ restart:
|
|||||||
if (*iolock == XFS_IOLOCK_SHARED && !IS_NOSEC(inode)) {
|
if (*iolock == XFS_IOLOCK_SHARED && !IS_NOSEC(inode)) {
|
||||||
xfs_iunlock(ip, *iolock);
|
xfs_iunlock(ip, *iolock);
|
||||||
*iolock = XFS_IOLOCK_EXCL;
|
*iolock = XFS_IOLOCK_EXCL;
|
||||||
xfs_ilock(ip, *iolock);
|
error = xfs_ilock_iocb(iocb, *iolock);
|
||||||
|
if (error) {
|
||||||
|
*iolock = 0;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -367,6 +378,10 @@ restart:
|
|||||||
isize = i_size_read(inode);
|
isize = i_size_read(inode);
|
||||||
if (iocb->ki_pos > isize) {
|
if (iocb->ki_pos > isize) {
|
||||||
spin_unlock(&ip->i_flags_lock);
|
spin_unlock(&ip->i_flags_lock);
|
||||||
|
|
||||||
|
if (iocb->ki_flags & IOCB_NOWAIT)
|
||||||
|
return -EAGAIN;
|
||||||
|
|
||||||
if (!drained_dio) {
|
if (!drained_dio) {
|
||||||
if (*iolock == XFS_IOLOCK_SHARED) {
|
if (*iolock == XFS_IOLOCK_SHARED) {
|
||||||
xfs_iunlock(ip, *iolock);
|
xfs_iunlock(ip, *iolock);
|
||||||
@@ -592,7 +607,8 @@ xfs_file_dio_aio_write(
|
|||||||
&xfs_dio_write_ops,
|
&xfs_dio_write_ops,
|
||||||
unaligned_io ? IOMAP_DIO_FORCE_WAIT : 0);
|
unaligned_io ? IOMAP_DIO_FORCE_WAIT : 0);
|
||||||
out:
|
out:
|
||||||
xfs_iunlock(ip, iolock);
|
if (iolock)
|
||||||
|
xfs_iunlock(ip, iolock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No fallback to buffered IO after short writes for XFS, direct I/O
|
* No fallback to buffered IO after short writes for XFS, direct I/O
|
||||||
@@ -631,7 +647,8 @@ xfs_file_dax_write(
|
|||||||
error = xfs_setfilesize(ip, pos, ret);
|
error = xfs_setfilesize(ip, pos, ret);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
xfs_iunlock(ip, iolock);
|
if (iolock)
|
||||||
|
xfs_iunlock(ip, iolock);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user