Message ID | 20220214174403.4147994-4-shr@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Support sync buffered writes for io-uring | expand |
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@fb.com> > --- > 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?
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. I don't understand why this helps you. filemap_get_pages() is for reads, not writes.
This patch will be removed from the next version. On 2/14/22 11:33 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. > > I don't understand why this helps you. filemap_get_pages() is for > reads, not writes.
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@fb.com> >> --- >> 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.
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;
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. Signed-off-by: Stefan Roesch <shr@fb.com> --- mm/filemap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)