>From c45bc949f7b42ed25f40869ff79664a47bd0979f Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 7 Mar 2013 11:41:58 +0100 Subject: [PATCH] direct-io: Fix boundary block handling When we read/write a file sequentially, we will read/write not only the data blocks but also the indirect blocks that may not be physically adjacent to the data blocks. So filesystems sets BG_Boundary flag to submit the previous I/O before reading/writing an indirect block. However generic direct IO code mishandles buffer_boundary() flag, sets sdio->boundary before each submit_page_section() call which results in sending only one page bios as underlying code thinks this page is the last in the contiguous extent. So fix the problem by setting sdio->boundary only if the current page is really the last one in the mapped extent. Reported-by: Kazuya Mio Signed-off-by: Jan Kara --- fs/direct-io.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index f853263..e666854 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -969,7 +969,8 @@ do_holes: this_chunk_bytes = this_chunk_blocks << blkbits; BUG_ON(this_chunk_bytes == 0); - sdio->boundary = buffer_boundary(map_bh); + if (sdio->blocks_available == this_chunk_blocks) + sdio->boundary = buffer_boundary(map_bh); ret = submit_page_section(dio, sdio, page, offset_in_page, this_chunk_bytes, -- 1.7.1