This is a note to let you know that I've just added the patch titled mm: mark async iocb read as NOWAIT once some data has been copied to the 5.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-mark-async-iocb-read-as-nowait-once-some-data-has-been-copied.patch and it can be found in the queue-5.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 13bd691421bc191a402d2e0d3da5f248d170a632 Mon Sep 17 00:00:00 2001 From: Jens Axboe <axboe@xxxxxxxxx> Date: Sat, 17 Oct 2020 08:31:29 -0600 Subject: mm: mark async iocb read as NOWAIT once some data has been copied From: Jens Axboe <axboe@xxxxxxxxx> commit 13bd691421bc191a402d2e0d3da5f248d170a632 upstream. Once we've copied some data for an iocb that is marked with IOCB_WAITQ, we should no longer attempt to async lock a new page. Instead make sure we return the copied amount, and let the caller retry, instead of returning -EIOCBQUEUED for a new page. This should only be possible with read-ahead disabled on the below device, and multiple threads racing on the same file. Haven't been able to reproduce on anything else. Cc: stable@xxxxxxxxxxxxxxx # v5.9 Fixes: 1a0a7853b901 ("mm: support async buffered reads in generic_file_buffered_read()") Reported-by: Kent Overstreet <kent.overstreet@xxxxxxxxx> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- mm/filemap.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2179,6 +2179,14 @@ ssize_t generic_file_buffered_read(struc last_index = (*ppos + iter->count + PAGE_SIZE-1) >> PAGE_SHIFT; offset = *ppos & ~PAGE_MASK; + /* + * If we've already successfully copied some data, then we + * can no longer safely return -EIOCBQUEUED. Hence mark + * an async read NOWAIT at that point. + */ + if (written && (iocb->ki_flags & IOCB_WAITQ)) + iocb->ki_flags |= IOCB_NOWAIT; + for (;;) { struct page *page; pgoff_t end_index; Patches currently in stable-queue which might be from axboe@xxxxxxxxx are queue-5.9/io_uring-convert-advanced-xarray-uses-to-the-normal-api.patch queue-5.9/io_uring-reference-nsproxy-for-file-table-commands.patch queue-5.9/io_uring-stash-ctx-task-reference-for-sqpoll.patch queue-5.9/io_uring-return-cancelation-status-from-poll-timeout-files-handlers.patch queue-5.9/io_uring-fix-xarray-usage-in-io_uring_add_task_file.patch queue-5.9/io_uring-fix-use-of-xarray-in-__io_uring_files_cancel.patch queue-5.9/io-wq-fix-use-after-free-in-io_wq_worker_running.patch queue-5.9/io_uring-don-t-rely-on-weak-files-references.patch queue-5.9/ata-ahci-mvebu-make-sata-phy-optional-for-armada-3720.patch queue-5.9/io_uring-allow-timeout-poll-files-killing-to-take-task-into-account.patch queue-5.9/mm-mark-async-iocb-read-as-nowait-once-some-data-has-been-copied.patch queue-5.9/io_uring-move-dropping-of-files-into-separate-helper.patch queue-5.9/io_uring-unconditionally-grab-req-task.patch queue-5.9/io_uring-enable-task-files-specific-overflow-flushing.patch queue-5.9/io_wq-make-io_wqe-lock-a-raw_spinlock_t.patch queue-5.9/ata-sata_rcar-fix-dma-boundary-mask.patch queue-5.9/io_uring-no-need-to-call-xa_destroy-on-empty-xarray.patch