summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2022-02-22 09:45:38 -0500
committerMatthew Wilcox (Oracle) <willy@infradead.org>2022-05-08 14:28:19 -0400
commitdf8081801dc8e6292390fe33198174b6a60d4356 (patch)
treeb1791c1d2da94506df8eafe726c562fc61c6306a /fs/f2fs
parent2d878178baf32dda7eaf6c1de05a42ab19fe4094 (diff)
downloadlinux-stable-df8081801dc8e6292390fe33198174b6a60d4356.tar.gz
linux-stable-df8081801dc8e6292390fe33198174b6a60d4356.tar.bz2
linux-stable-df8081801dc8e6292390fe33198174b6a60d4356.zip
f2fs: Convert f2fs_grab_cache_page() to use scoped memory APIs
Prevent GFP_FS allocations by using memalloc_nofs_save() instead of AOP_FLAG_NOFS. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/f2fs.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 8c570de21ed5..74929ade4b5e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -18,6 +18,7 @@
#include <linux/kobject.h>
#include <linux/sched.h>
#include <linux/cred.h>
+#include <linux/sched/mm.h>
#include <linux/vmalloc.h>
#include <linux/bio.h>
#include <linux/blkdev.h>
@@ -2654,6 +2655,7 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
pgoff_t index, bool for_write)
{
struct page *page;
+ unsigned int flags;
if (IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)) {
if (!for_write)
@@ -2673,7 +2675,12 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
if (!for_write)
return grab_cache_page(mapping, index);
- return grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS);
+
+ flags = memalloc_nofs_save();
+ page = grab_cache_page_write_begin(mapping, index, 0);
+ memalloc_nofs_restore(flags);
+
+ return page;
}
static inline struct page *f2fs_pagecache_get_page(