We have use cases where we want to trigger readahead in preadv2(2) with RWF_NOWAIT set [0]. Readahead support was originally added for IOCB_NOWAIT in commit 2e85abf053b9 ("mm: allow read-ahead with IOCB_NOWAIT set"). However, this behavior was modified in commit efa8480a8316 ("fs: RWF_NOWAIT should imply IOCB_NOIO") due to concerns about potential blocking during memory reclamation. To prevent blocking on memory reclamation, we can utilize memalloc_nowait_{save,restore} to ensure non-blocking behavior. By restoring the original behavior, we can allow preadv2(IOCB_NOWAIT) to read data directly from disk if it's not already in the page cache. Changes: - fs: Add a new flag RWF_IOWAIT for preadv2(2) https://lore.kernel.org/linux-fsdevel/20240804080251.21239-1-laoar.shao@xxxxxxxxx/ [0] Yafang Shao (2): mm: Add memalloc_nowait_{save,restore} mm: allow read-ahead with IOCB_NOWAIT set include/linux/fs.h | 1 - include/linux/sched/mm.h | 30 ++++++++++++++++++++++++++++++ mm/filemap.c | 6 ++++++ 3 files changed, 36 insertions(+), 1 deletion(-) -- 2.43.5