Commit 4977b7a1 authored by Christoph Hellwig's avatar Christoph Hellwig

[XFS] Fix use of AIO wait_on_sync_kiocb and a deadlock in O_SYNC

inode semaphore handling.
parent 25fcf560
...@@ -164,8 +164,6 @@ __linvfs_readv( ...@@ -164,8 +164,6 @@ __linvfs_readv(
if (unlikely(file->f_flags & O_DIRECT)) if (unlikely(file->f_flags & O_DIRECT))
ioflags |= IO_ISDIRECT; ioflags |= IO_ISDIRECT;
VOP_READ(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval); VOP_READ(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval);
if (rval == -EIOCBQUEUED)
rval = wait_on_sync_kiocb(&kiocb);
*ppos = kiocb.ki_pos; *ppos = kiocb.ki_pos;
return rval; return rval;
...@@ -211,8 +209,6 @@ __linvfs_writev( ...@@ -211,8 +209,6 @@ __linvfs_writev(
ioflags |= IO_ISDIRECT; ioflags |= IO_ISDIRECT;
VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval); VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval);
if (rval == -EIOCBQUEUED)
rval = wait_on_sync_kiocb(&kiocb);
*ppos = kiocb.ki_pos; *ppos = kiocb.ki_pos;
return rval; return rval;
......
...@@ -319,6 +319,8 @@ xfs_read( ...@@ -319,6 +319,8 @@ xfs_read(
xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore, xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
(void *)iovp, segs, *offset, ioflags); (void *)iovp, segs, *offset, ioflags);
ret = __generic_file_aio_read(iocb, iovp, segs, offset); ret = __generic_file_aio_read(iocb, iovp, segs, offset);
if (ret == -EIOCBQUEUED)
ret = wait_on_sync_kiocb(iocb);
xfs_iunlock(ip, XFS_IOLOCK_SHARED); xfs_iunlock(ip, XFS_IOLOCK_SHARED);
if (ret > 0) if (ret > 0)
...@@ -846,6 +848,9 @@ xfs_write( ...@@ -846,6 +848,9 @@ xfs_write(
current->backing_dev_info = NULL; current->backing_dev_info = NULL;
if (ret == -EIOCBQUEUED)
ret = wait_on_sync_kiocb(iocb);
if ((ret == -ENOSPC) && if ((ret == -ENOSPC) &&
DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_NOSPACE) && DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_NOSPACE) &&
!(ioflags & IO_INVIS)) { !(ioflags & IO_INVIS)) {
...@@ -955,11 +960,13 @@ xfs_write( ...@@ -955,11 +960,13 @@ xfs_write(
} }
xfs_rwunlock(bdp, locktype); xfs_rwunlock(bdp, locktype);
if (need_isem)
up(&inode->i_sem);
error = sync_page_range(inode, mapping, pos, ret); error = sync_page_range(inode, mapping, pos, ret);
if (!error) if (!error)
error = -ret; error = ret;
goto out_unlock_isem; return error;
} }
out_unlock_internal: out_unlock_internal:
......
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