Skip to content

Commit

Permalink
direct-io: fix AIO regression
Browse files Browse the repository at this point in the history
The direct-io.c rewrite to use the iov_iter infrastructure stopped updating
the size field in struct dio_submit, and thus rendered the check for
allowing asynchronous completions to always return false.  Fix this by
comparing it to the count of bytes in the iov_iter instead.

Signed-off-by: Christoph Hellwig <[email protected]>
Reported-by: Tim Chen <[email protected]>
Tested-by: Tim Chen <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Aug 1, 2014
1 parent 6f09280 commit af43647
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions fs/direct-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ struct dio_submit {
been performed at the start of a
write */
int pages_in_io; /* approximate total IO pages */
size_t size; /* total request size (doesn't change)*/
sector_t block_in_file; /* Current offset into the underlying
file in dio_block units. */
unsigned blocks_available; /* At block_in_file. changes */
Expand Down Expand Up @@ -1104,7 +1103,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
unsigned blkbits = i_blkbits;
unsigned blocksize_mask = (1 << blkbits) - 1;
ssize_t retval = -EINVAL;
loff_t end = offset + iov_iter_count(iter);
size_t count = iov_iter_count(iter);
loff_t end = offset + count;
struct dio *dio;
struct dio_submit sdio = { 0, };
struct buffer_head map_bh = { 0, };
Expand Down Expand Up @@ -1287,10 +1287,9 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
*/
BUG_ON(retval == -EIOCBQUEUED);
if (dio->is_async && retval == 0 && dio->result &&
((rw == READ) || (dio->result == sdio.size)))
(rw == READ || dio->result == count))
retval = -EIOCBQUEUED;

if (retval != -EIOCBQUEUED)
else
dio_await_completion(dio);

if (drop_refcount(dio) == 0) {
Expand Down

0 comments on commit af43647

Please sign in to comment.