Skip to content

Commit b1058b9

Browse files
jankaratorvalds
authored andcommitted
direct-io: submit bio after boundary buffer is added to it
Currently, dio_send_cur_page() submits bio before current page and cached sdio->cur_page is added to the bio if sdio->boundary is set. This is actually wrong because sdio->boundary means the current buffer is the last one before metadata needs to be read. So we should rather submit the bio after the current page is added to it. Signed-off-by: Jan Kara <[email protected]> Reported-by: Kazuya Mio <[email protected]> Tested-by: Kazuya Mio <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 092c8d4 commit b1058b9

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

fs/direct-io.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -672,12 +672,6 @@ static inline int dio_send_cur_page(struct dio *dio, struct dio_submit *sdio,
672672
if (sdio->final_block_in_bio != sdio->cur_page_block ||
673673
cur_offset != bio_next_offset)
674674
dio_bio_submit(dio, sdio);
675-
/*
676-
* Submit now if the underlying fs is about to perform a
677-
* metadata read
678-
*/
679-
else if (sdio->boundary)
680-
dio_bio_submit(dio, sdio);
681675
}
682676

683677
if (sdio->bio == NULL) {
@@ -737,16 +731,6 @@ submit_page_section(struct dio *dio, struct dio_submit *sdio, struct page *page,
737731
sdio->cur_page_block +
738732
(sdio->cur_page_len >> sdio->blkbits) == blocknr) {
739733
sdio->cur_page_len += len;
740-
741-
/*
742-
* If sdio->boundary then we want to schedule the IO now to
743-
* avoid metadata seeks.
744-
*/
745-
if (sdio->boundary) {
746-
ret = dio_send_cur_page(dio, sdio, map_bh);
747-
page_cache_release(sdio->cur_page);
748-
sdio->cur_page = NULL;
749-
}
750734
goto out;
751735
}
752736

@@ -758,7 +742,7 @@ submit_page_section(struct dio *dio, struct dio_submit *sdio, struct page *page,
758742
page_cache_release(sdio->cur_page);
759743
sdio->cur_page = NULL;
760744
if (ret)
761-
goto out;
745+
return ret;
762746
}
763747

764748
page_cache_get(page); /* It is in dio */
@@ -768,6 +752,16 @@ submit_page_section(struct dio *dio, struct dio_submit *sdio, struct page *page,
768752
sdio->cur_page_block = blocknr;
769753
sdio->cur_page_fs_offset = sdio->block_in_file << sdio->blkbits;
770754
out:
755+
/*
756+
* If sdio->boundary then we want to schedule the IO now to
757+
* avoid metadata seeks.
758+
*/
759+
if (sdio->boundary) {
760+
ret = dio_send_cur_page(dio, sdio, map_bh);
761+
dio_bio_submit(dio, sdio);
762+
page_cache_release(sdio->cur_page);
763+
sdio->cur_page = NULL;
764+
}
771765
return ret;
772766
}
773767

0 commit comments

Comments
 (0)