Skip to content

Commit

Permalink
O_DIRECT: fix the splitting up of contiguous I/O
Browse files Browse the repository at this point in the history
commit c2c6ca4 (direct-io: do not merge logically non-contiguous requests)
introduced a bug whereby all O_DIRECT I/Os were submitted a page at a time
to the block layer.  The problem is that the code expected
dio->block_in_file to correspond to the current page in the dio.  In fact,
it corresponds to the previous page submitted via submit_page_section.
This was purely an oversight, as the dio->cur_page_fs_offset field was
introduced for just this purpose.  This patch simply uses the correct
variable when calculating whether there is a mismatch between contiguous
logical blocks and contiguous physical blocks (as described in the
comments).

I also switched the if conditional following this check to an else if, to
ensure that we never call dio_bio_submit twice for the same dio (in
theory, this should not happen, anyway).

I've tested this by running blktrace and verifying that a 64KB I/O was
submitted as a single I/O.  I also ran the patched kernel through
xfstests' aio tests using xfs, ext4 (with 1k and 4k block sizes) and btrfs
and verified that there were no regressions as compared to an unpatched
kernel.

Signed-off-by: Jeff Moyer <[email protected]>
Acked-by: Josef Bacik <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Chris Mason <[email protected]>
Cc: <[email protected]>		[2.6.35.x]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JeffMoyer authored and torvalds committed Sep 10, 2010
1 parent 4e70598 commit 7a801ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/direct-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ static int dio_send_cur_page(struct dio *dio)
int ret = 0;

if (dio->bio) {
loff_t cur_offset = dio->block_in_file << dio->blkbits;
loff_t cur_offset = dio->cur_page_fs_offset;
loff_t bio_next_offset = dio->logical_offset_in_bio +
dio->bio->bi_size;

Expand All @@ -659,7 +659,7 @@ static int dio_send_cur_page(struct dio *dio)
* Submit now if the underlying fs is about to perform a
* metadata read
*/
if (dio->boundary)
else if (dio->boundary)
dio_bio_submit(dio);
}

Expand Down

0 comments on commit 7a801ac

Please sign in to comment.