mbox series

[0/2] mm: Add readahead support for IOCB_NOWAIT

Message ID 20240812090525.80299-1-laoar.shao@gmail.com (mailing list archive)
Headers show
Series mm: Add readahead support for IOCB_NOWAIT | expand

Message

Yafang Shao Aug. 12, 2024, 9:05 a.m. UTC
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@gmail.com/ [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(-)