The patch titled Subject: mm: use filemap_range_needs_writeback() for O_DIRECT reads has been added to the -mm tree. Its filename is mm-use-filemap_range_needs_writeback-for-o_direct-reads.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-use-filemap_range_needs_writeback-for-o_direct-reads.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-use-filemap_range_needs_writeback-for-o_direct-reads.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Jens Axboe <axboe@xxxxxxxxx> Subject: mm: use filemap_range_needs_writeback() for O_DIRECT reads For the generic page cache read helper, use the better variant of checking for the need to call filemap_write_and_wait_range() when doing O_DIRECT reads. This avoids falling back to the slow path for IOCB_NOWAIT, if there are no pages to wait for (or write out). Link: https://lkml.kernel.org/r/20210224164455.1096727-3-axboe@xxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Reviewed-by: Jan Kara <jack@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/filemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/mm/filemap.c~mm-use-filemap_range_needs_writeback-for-o_direct-reads +++ a/mm/filemap.c @@ -2614,8 +2614,8 @@ generic_file_read_iter(struct kiocb *ioc size = i_size_read(inode); if (iocb->ki_flags & IOCB_NOWAIT) { - if (filemap_range_has_page(mapping, iocb->ki_pos, - iocb->ki_pos + count - 1)) + if (filemap_range_needs_writeback(mapping, iocb->ki_pos, + iocb->ki_pos + count - 1)) return -EAGAIN; } else { retval = filemap_write_and_wait_range(mapping, _ Patches currently in -mm which might be from axboe@xxxxxxxxx are swap-fix-swapfile-read-write-offset.patch mm-provide-filemap_range_needs_writeback-helper.patch mm-use-filemap_range_needs_writeback-for-o_direct-reads.patch iomap-use-filemap_range_needs_writeback-for-o_direct-reads.patch