On 2/14/22 10:08 AM, Matthew Wilcox wrote: > On Mon, Feb 14, 2022 at 09:43:52AM -0800, Stefan Roesch wrote: >> This adds noio support for async buffered writes in filemap_get_pages. >> The idea is to handle the failure gracefully and return -EAGAIN if we >> can't get the memory quickly. > > But it doesn't return -EAGAIN? > > folio = filemap_alloc_folio(mapping_gfp_mask(mapping), 0); > if (!folio) > return -ENOMEM; > >> Signed-off-by: Stefan Roesch <shr@xxxxxx> >> --- >> mm/filemap.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/mm/filemap.c b/mm/filemap.c >> index d2fb817c0845..0ff4278c3961 100644 >> --- a/mm/filemap.c >> +++ b/mm/filemap.c >> @@ -2591,10 +2591,15 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, >> filemap_get_read_batch(mapping, index, last_index, fbatch); >> } >> if (!folio_batch_count(fbatch)) { >> + unsigned int pflags; >> + >> if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) >> - return -EAGAIN; >> + pflags = memalloc_noio_save(); >> err = filemap_create_folio(filp, mapping, >> iocb->ki_pos >> PAGE_SHIFT, fbatch); >> + if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) >> + memalloc_noio_restore(pflags); >> + >> if (err == AOP_TRUNCATED_PAGE) >> goto retry; >> return err; > > I would also not expect the memalloc_noio_save/restore calls to be > here. Surely they should be at the top of the call chain where > IOCB_NOWAIT/IOCB_WAITQ are set? This patch will be removed from the next version of the patch series.