Skip to content

Commit af43647

Browse files
Christoph HellwigAl Viro
authored andcommitted
direct-io: fix AIO regression
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]>
1 parent 6f09280 commit af43647

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fs/direct-io.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ struct dio_submit {
7171
been performed at the start of a
7272
write */
7373
int pages_in_io; /* approximate total IO pages */
74-
size_t size; /* total request size (doesn't change)*/
7574
sector_t block_in_file; /* Current offset into the underlying
7675
file in dio_block units. */
7776
unsigned blocks_available; /* At block_in_file. changes */
@@ -1104,7 +1103,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
11041103
unsigned blkbits = i_blkbits;
11051104
unsigned blocksize_mask = (1 << blkbits) - 1;
11061105
ssize_t retval = -EINVAL;
1107-
loff_t end = offset + iov_iter_count(iter);
1106+
size_t count = iov_iter_count(iter);
1107+
loff_t end = offset + count;
11081108
struct dio *dio;
11091109
struct dio_submit sdio = { 0, };
11101110
struct buffer_head map_bh = { 0, };
@@ -1287,10 +1287,9 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
12871287
*/
12881288
BUG_ON(retval == -EIOCBQUEUED);
12891289
if (dio->is_async && retval == 0 && dio->result &&
1290-
((rw == READ) || (dio->result == sdio.size)))
1290+
(rw == READ || dio->result == count))
12911291
retval = -EIOCBQUEUED;
1292-
1293-
if (retval != -EIOCBQUEUED)
1292+
else
12941293
dio_await_completion(dio);
12951294

12961295
if (drop_refcount(dio) == 0) {

0 commit comments

Comments
 (0)