@@ -21,6 +21,7 @@
#include <linux/gfs2_ondisk.h>
#include <linux/backing-dev.h>
#include <linux/uio.h>
+#include <linux/sched/mm.h>
#include <trace/events/writeback.h>
#include "gfs2.h"
@@ -671,6 +672,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
pgoff_t index = pos >> PAGE_SHIFT;
unsigned from = pos & (PAGE_SIZE - 1);
struct page *page;
+ unsigned nofs_flags;
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh);
error = gfs2_glock_nq(&ip->i_gh);
@@ -719,8 +721,9 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
goto out_trans_fail;
error = -ENOMEM;
- flags |= AOP_FLAG_NOFS;
+ nofs_flags = memalloc_nofs_save();
page = grab_cache_page_write_begin(mapping, index, flags);
+ memalloc_nofs_restore(nofs_flags);
*pagep = page;
if (unlikely(!page))
goto out_endtrans;