diff mbox series

[08/22] f2fs: Convert f2fs_grab_cache_page() to use scoped memory APIs

Message ID 20220222194820.737755-9-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Remove aop flags | expand

Commit Message

Matthew Wilcox Feb. 22, 2022, 7:48 p.m. UTC
Prevent GFP_FS allocations by using memalloc_nofs_save() instead
of AOP_FLAG_NOFS.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/f2fs.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Feb. 23, 2022, 6:57 a.m. UTC | #1
On Tue, Feb 22, 2022 at 07:48:06PM +0000, Matthew Wilcox (Oracle) wrote:
> Prevent GFP_FS allocations by using memalloc_nofs_save() instead
> of AOP_FLAG_NOFS.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 51ba0f8ffd86..324553da3bdd 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>
@@ -2557,6 +2558,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)
@@ -2576,7 +2578,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(