Skip to content

Commit

Permalink
f2fs: Convert f2fs_grab_cache_page() to use scoped memory APIs
Browse files Browse the repository at this point in the history
Prevent GFP_FS allocations by using memalloc_nofs_save() instead
of AOP_FLAG_NOFS.

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) committed May 8, 2022
1 parent 2d87817 commit df80818
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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)
Expand All @@ -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(
Expand Down

0 comments on commit df80818

Please sign in to comment.