@@ -42,6 +42,7 @@
#include <linux/ramfs.h>
#include <linux/page_idle.h>
#include <linux/migrate.h>
+#include <linux/sched/mm.h>
#include <asm/pgalloc.h>
#include <asm/tlbflush.h>
#include "internal.h"
@@ -133,11 +133,19 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
pgoff_t index, unsigned flags)
{
unsigned fgp_flags = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE;
+ gfp_t gfp = mapping_gfp_mask(mapping);
if (flags & AOP_FLAG_NOFS)
fgp_flags |= FGP_NOFS;
- return pagecache_get_page(mapping, index, fgp_flags,
- mapping_gfp_mask(mapping));
+
+ if (flags & AOP_FLAG_NOWAIT) {
+ fgp_flags |= FGP_NOWAIT;
+
+ gfp |= GFP_ATOMIC;
+ gfp &= ~__GFP_DIRECT_RECLAIM;
+ }
+
+ return pagecache_get_page(mapping, index, fgp_flags, gfp);
}
EXPORT_SYMBOL(grab_cache_page_write_begin);
This adds support for async buffered writes in the mm layer. When the AOP_FLAG_NOWAIT flag is set, if the page is not already loaded, the page gets created without blocking on the allocation. Signed-off-by: Stefan Roesch <shr@fb.com> --- mm/filemap.c | 1 + mm/folio-compat.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-)