linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] Use the memalloc_nofs scope API
@ 2018-02-19 14:02 Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 01/10] fs: buffer - Use memalloc_nofs API to allocate pages Goldwyn Rodrigues
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko

This attempt is to remove the use of AOP_FLAG_NOFS and replacing
it with the new scope API of memory allocation memalloc_nofs_save()
and memalloc_nofs_restore().

Since we change to scope based memory allocation, we no longer need
AOP_FLAGS_NOFS parameters and hence this flag was removeed.
The only other parameter is AOP_FLAGS_CONT_EXPAND. Since this is only used
by reiserfs, we can remove that by creating a function within reiserfs.

With all usages of AOP flags removed, address_operations.write_begin()
prototype becomes a little smaller: by removing the flags parameter.

Git: https://github.com/goldwynr/linux/tree/nofs

-- 
Goldwyn

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/10] fs: buffer - Use memalloc_nofs API to allocate pages
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  2018-02-19 14:24   ` Michal Hocko
  2018-02-19 14:02 ` [PATCH 02/10] fs: mpage use memalloc_nofs_save/restore while allocating bios Goldwyn Rodrigues
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/buffer.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index 9a73924db22f..1787b29f3fb3 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -45,6 +45,7 @@
 #include <linux/mpage.h>
 #include <linux/bit_spinlock.h>
 #include <linux/pagevec.h>
+#include <linux/sched/mm.h>
 #include <trace/events/block.h>
 
 static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
@@ -836,7 +837,8 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
 		bool retry)
 {
 	struct buffer_head *bh, *head;
-	gfp_t gfp = GFP_NOFS;
+	gfp_t gfp = GFP_KERNEL;
+	unsigned int nofs_flags;
 	long offset;
 
 	if (retry)
@@ -844,6 +846,7 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
 
 	head = NULL;
 	offset = PAGE_SIZE;
+	nofs_flags = memalloc_nofs_save();
 	while ((offset -= size) >= 0) {
 		bh = alloc_buffer_head(gfp);
 		if (!bh)
@@ -858,11 +861,13 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
 		/* Link the buffer to its page */
 		set_bh_page(bh, page, offset);
 	}
+	memalloc_nofs_restore(nofs_flags);
 	return head;
 /*
  * In case anything failed, we just free everything we got.
  */
 no_grow:
+	memalloc_nofs_restore(nofs_flags);
 	if (head) {
 		do {
 			bh = head;
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/10] fs: mpage use memalloc_nofs_save/restore while allocating bios
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 01/10] fs: buffer - Use memalloc_nofs API to allocate pages Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 03/10] ext4: Use memalloc_nofs_* scope API Goldwyn Rodrigues
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/mpage.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/mpage.c b/fs/mpage.c
index b7e7f570733a..8d54676c44cb 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -30,6 +30,7 @@
 #include <linux/backing-dev.h>
 #include <linux/pagevec.h>
 #include <linux/cleancache.h>
+#include <linux/sched/mm.h>
 #include "internal.h"
 
 /*
@@ -614,13 +615,16 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
 
 alloc_new:
 	if (bio == NULL) {
+		unsigned nofs_flag;
 		if (first_unmapped == blocks_per_page) {
 			if (!bdev_write_page(bdev, blocks[0] << (blkbits - 9),
 								page, wbc))
 				goto out;
 		}
+		nofs_flag = memalloc_nofs_save();
 		bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
-				BIO_MAX_PAGES, GFP_NOFS|__GFP_HIGH);
+				BIO_MAX_PAGES, GFP_KERNEL|__GFP_HIGH);
+		memalloc_nofs_restore(nofs_flag);
 		if (bio == NULL)
 			goto confused;
 
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/10] ext4: Use memalloc_nofs_* scope API
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 01/10] fs: buffer - Use memalloc_nofs API to allocate pages Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 02/10] fs: mpage use memalloc_nofs_save/restore while allocating bios Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 04/10] f2fs: " Goldwyn Rodrigues
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/ext4/inline.c      | 21 +++++++++++++--------
 fs/ext4/move_extent.c | 12 ++++++++----
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 70cf4c7b268a..e59f8a8e40e7 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -7,6 +7,7 @@
 #include <linux/iomap.h>
 #include <linux/fiemap.h>
 #include <linux/iversion.h>
+#include <linux/sched/mm.h>
 
 #include "ext4_jbd2.h"
 #include "ext4.h"
@@ -525,6 +526,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
 	struct page *page = NULL;
 	unsigned from, to;
 	struct ext4_iloc iloc;
+	int nofs_flags;
 
 	if (!ext4_has_inline_data(inode)) {
 		/*
@@ -551,9 +553,12 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
 
 	/* We cannot recurse into the filesystem as the transaction is already
 	 * started */
-	flags |= AOP_FLAG_NOFS;
+	nofs_flags = memalloc_nofs_save();
 
 	page = grab_cache_page_write_begin(mapping, 0, flags);
+
+	memalloc_nofs_restore(nofs_flags);
+
 	if (!page) {
 		ret = -ENOMEM;
 		goto out;
@@ -645,6 +650,8 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
 	handle_t *handle;
 	struct page *page;
 	struct ext4_iloc iloc;
+	unsigned nofs_flags;
+
 
 	if (pos + len > ext4_get_max_inline_size(inode))
 		goto convert;
@@ -675,9 +682,11 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
 		goto convert;
 	}
 
-	flags |= AOP_FLAG_NOFS;
+	nofs_flags = memalloc_nofs_save();
 
 	page = grab_cache_page_write_begin(mapping, 0, flags);
+
+	memalloc_nofs_restore(nofs_flags);
 	if (!page) {
 		ret = -ENOMEM;
 		goto out;
@@ -873,17 +882,13 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
 			goto out_journal;
 	}
 
-	/*
-	 * We cannot recurse into the filesystem as the transaction
-	 * is already started.
-	 */
-	flags |= AOP_FLAG_NOFS;
-
 	if (ret == -ENOSPC) {
+		int nofs_flags = memalloc_nofs_save();
 		ret = ext4_da_convert_inline_data_to_extent(mapping,
 							    inode,
 							    flags,
 							    fsdata);
+		memalloc_nofs_restore(nofs_flags);
 		ext4_journal_stop(handle);
 		if (ret == -ENOSPC &&
 		    ext4_should_retry_alloc(inode->i_sb, &retries))
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index b96e4bd3b3ec..9e35e72dcd29 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -8,6 +8,7 @@
 #include <linux/fs.h>
 #include <linux/quotaops.h>
 #include <linux/slab.h>
+#include <linux/sched/mm.h>
 #include "ext4_jbd2.h"
 #include "ext4.h"
 #include "ext4_extents.h"
@@ -127,7 +128,7 @@ mext_page_double_lock(struct inode *inode1, struct inode *inode2,
 		      pgoff_t index1, pgoff_t index2, struct page *page[2])
 {
 	struct address_space *mapping[2];
-	unsigned fl = AOP_FLAG_NOFS;
+	unsigned nofs_fl = memalloc_nofs_save();
 
 	BUG_ON(!inode1 || !inode2);
 	if (inode1 < inode2) {
@@ -141,11 +142,14 @@ mext_page_double_lock(struct inode *inode1, struct inode *inode2,
 		mapping[1] = inode1->i_mapping;
 	}
 
-	page[0] = grab_cache_page_write_begin(mapping[0], index1, fl);
-	if (!page[0])
+	page[0] = grab_cache_page_write_begin(mapping[0], index1, 0);
+	if (!page[0]) {
+		memalloc_nofs_restore(nofs_fl);
 		return -ENOMEM;
+	}
 
-	page[1] = grab_cache_page_write_begin(mapping[1], index2, fl);
+	page[1] = grab_cache_page_write_begin(mapping[1], index2, 0);
+	memalloc_nofs_restore(nofs_fl);
 	if (!page[1]) {
 		unlock_page(page[0]);
 		put_page(page[0]);
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/10] f2fs: Use memalloc_nofs_* scope API
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
                   ` (2 preceding siblings ...)
  2018-02-19 14:02 ` [PATCH 03/10] ext4: Use memalloc_nofs_* scope API Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 05/10] gfs2: " Goldwyn Rodrigues
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/f2fs/f2fs.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 6300ac5bcbe4..98b0827af06e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -24,6 +24,7 @@
 #include <linux/bio.h>
 #include <linux/blkdev.h>
 #include <linux/quotaops.h>
+#include <linux/sched/mm.h>
 #include <crypto/hash.h>
 
 #define __FS_HAS_ENCRYPTION IS_ENABLED(CONFIG_F2FS_FS_ENCRYPTION)
@@ -1905,6 +1906,8 @@ static inline s64 valid_inode_count(struct f2fs_sb_info *sbi)
 static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
 						pgoff_t index, bool for_write)
 {
+	struct page *pg = NULL;
+	unsigned nofs_flags;
 #ifdef CONFIG_F2FS_FAULT_INJECTION
 	struct page *page = find_lock_page(mapping, index);
 
@@ -1918,7 +1921,11 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
 #endif
 	if (!for_write)
 		return grab_cache_page(mapping, index);
-	return grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS);
+
+	nofs_flags = memalloc_nofs_save();
+	pg = grab_cache_page_write_begin(mapping, index, 0);
+	memalloc_nofs_restore(nofs_flags);
+	return pg;
 }
 
 static inline struct page *f2fs_pagecache_get_page(
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/10] gfs2: Use memalloc_nofs_* scope API
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
                   ` (3 preceding siblings ...)
  2018-02-19 14:02 ` [PATCH 04/10] f2fs: " Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 06/10] fs: iomap use " Goldwyn Rodrigues
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/gfs2/aops.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 2f725b4a386b..802d2d223902 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -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;
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/10] fs: iomap use memalloc_nofs_* scope API
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
                   ` (4 preceding siblings ...)
  2018-02-19 14:02 ` [PATCH 05/10] gfs2: " Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  2018-02-19 22:30   ` Dave Chinner
  2018-02-19 14:02 ` [PATCH 07/10] fs: namei " Goldwyn Rodrigues
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

While we are at it, remove the flags parameter from iomap_write_begin()
since we passed AOP_FLAG_NOFS to it.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/iomap.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index afd163586aa0..afaf6ffff34f 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -27,6 +27,7 @@
 #include <linux/task_io_accounting_ops.h>
 #include <linux/dax.h>
 #include <linux/sched/signal.h>
+#include <linux/sched/mm.h>
 
 #include "internal.h"
 
@@ -109,19 +110,22 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
 }
 
 static int
-iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
+iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
 		struct page **pagep, struct iomap *iomap)
 {
 	pgoff_t index = pos >> PAGE_SHIFT;
 	struct page *page;
 	int status = 0;
+	unsigned nofs_flags;
 
 	BUG_ON(pos + len > iomap->offset + iomap->length);
 
 	if (fatal_signal_pending(current))
 		return -EINTR;
 
-	page = grab_cache_page_write_begin(inode->i_mapping, index, flags);
+	nofs_flags = memalloc_nofs_save();
+	page = grab_cache_page_write_begin(inode->i_mapping, index, 0);
+	memalloc_nofs_restore(nofs_flags);
 	if (!page)
 		return -ENOMEM;
 
@@ -158,7 +162,6 @@ iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 	struct iov_iter *i = data;
 	long status = 0;
 	ssize_t written = 0;
-	unsigned int flags = AOP_FLAG_NOFS;
 
 	do {
 		struct page *page;
@@ -188,7 +191,7 @@ iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 			break;
 		}
 
-		status = iomap_write_begin(inode, pos, bytes, flags, &page,
+		status = iomap_write_begin(inode, pos, bytes, &page,
 				iomap);
 		if (unlikely(status))
 			break;
@@ -287,7 +290,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 			return PTR_ERR(rpage);
 
 		status = iomap_write_begin(inode, pos, bytes,
-					   AOP_FLAG_NOFS, &page, iomap);
+					   &page, iomap);
 		put_page(rpage);
 		if (unlikely(status))
 			return status;
@@ -338,7 +341,7 @@ static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset,
 	struct page *page;
 	int status;
 
-	status = iomap_write_begin(inode, pos, bytes, AOP_FLAG_NOFS, &page,
+	status = iomap_write_begin(inode, pos, bytes, &page,
 				   iomap);
 	if (status)
 		return status;
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/10] fs: namei use memalloc_nofs_* scope API
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
                   ` (5 preceding siblings ...)
  2018-02-19 14:02 ` [PATCH 06/10] fs: iomap use " Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 08/10] fs: Eliminate AOP_FLAG_NOFS Goldwyn Rodrigues
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/namei.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/namei.c b/fs/namei.c
index 921ae32dbc80..6cb314a256c5 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -39,6 +39,7 @@
 #include <linux/bitops.h>
 #include <linux/init_task.h>
 #include <linux/uaccess.h>
+#include <linux/sched/mm.h>
 
 #include "internal.h"
 #include "mount.h"
@@ -4797,7 +4798,7 @@ int __page_symlink(struct inode *inode, const char *symname, int len, int nofs)
 	int err;
 	unsigned int flags = 0;
 	if (nofs)
-		flags |= AOP_FLAG_NOFS;
+		flags = memalloc_nofs_save();
 
 retry:
 	err = pagecache_write_begin(NULL, mapping, 0, len-1,
@@ -4815,8 +4816,12 @@ int __page_symlink(struct inode *inode, const char *symname, int len, int nofs)
 		goto retry;
 
 	mark_inode_dirty(inode);
+	if (nofs)
+		memalloc_nofs_restore(flags);
 	return 0;
 fail:
+	if (nofs)
+		memalloc_nofs_restore(flags);
 	return err;
 }
 EXPORT_SYMBOL(__page_symlink);
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/10] fs: Eliminate AOP_FLAG_NOFS
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
                   ` (6 preceding siblings ...)
  2018-02-19 14:02 ` [PATCH 07/10] fs: namei " Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 09/10] reiserfs: cont_expand() to eliminate AOP_FLAG_CONT_EXPAND Goldwyn Rodrigues
  2018-02-19 14:02 ` [PATCH 10/10] fs: Remove flags parameter from aops->write_begin() Goldwyn Rodrigues
  9 siblings, 0 replies; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 include/linux/fs.h | 3 ---
 mm/filemap.c       | 6 +-----
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2a815560fda0..877bccb9874f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -260,9 +260,6 @@ enum positive_aop_returns {
 };
 
 #define AOP_FLAG_CONT_EXPAND		0x0001 /* called from cont_expand */
-#define AOP_FLAG_NOFS			0x0002 /* used by filesystem to direct
-						* helper code (eg buffer layer)
-						* to clear GFP_FS from alloc */
 
 /*
  * oh the beauties of C type declarations.
diff --git a/mm/filemap.c b/mm/filemap.c
index 693f62212a59..07d28fedd62f 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3080,12 +3080,8 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
 					pgoff_t index, unsigned flags)
 {
 	struct page *page;
-	int fgp_flags = FGP_LOCK|FGP_WRITE|FGP_CREAT;
 
-	if (flags & AOP_FLAG_NOFS)
-		fgp_flags |= FGP_NOFS;
-
-	page = pagecache_get_page(mapping, index, fgp_flags,
+	page = pagecache_get_page(mapping, index, FGP_LOCK|FGP_WRITE|FGP_CREAT,
 			mapping_gfp_mask(mapping));
 	if (page)
 		wait_for_stable_page(page);
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/10] reiserfs: cont_expand() to eliminate AOP_FLAG_CONT_EXPAND
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
                   ` (7 preceding siblings ...)
  2018-02-19 14:02 ` [PATCH 08/10] fs: Eliminate AOP_FLAG_NOFS Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  2018-02-19 14:55   ` Matthew Wilcox
  2018-02-19 14:02 ` [PATCH 10/10] fs: Remove flags parameter from aops->write_begin() Goldwyn Rodrigues
  9 siblings, 1 reply; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Reiserfs is the only user of AOP_FLAG_CONT_EXPAND. Remove the flag
and add a function cont_expand to deal with pos increment.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/reiserfs/inode.c | 38 +++++++++++++++++++++++++++-----------
 include/linux/fs.h  |  2 --
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index b13fc024d2ee..44895c4dc354 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2761,13 +2761,6 @@ static int reiserfs_write_begin(struct file *file,
 	int old_ref = 0;
 
  	inode = mapping->host;
-	*fsdata = NULL;
- 	if (flags & AOP_FLAG_CONT_EXPAND &&
- 	    (pos & (inode->i_sb->s_blocksize - 1)) == 0) {
- 		pos ++;
-		*fsdata = (void *)(unsigned long)flags;
-	}
-
 	index = pos >> PAGE_SHIFT;
 	page = grab_cache_page_write_begin(mapping, index, flags);
 	if (!page)
@@ -2894,9 +2887,6 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
 	unsigned start;
 	bool locked = false;
 
-	if ((unsigned long)fsdata & AOP_FLAG_CONT_EXPAND)
-		pos ++;
-
 	reiserfs_wait_on_write_block(inode->i_sb);
 	if (reiserfs_transaction_running(inode->i_sb))
 		th = current->journal_info;
@@ -3278,6 +3268,32 @@ static ssize_t reiserfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 	return ret;
 }
 
+int cont_expand(struct inode *inode, loff_t pos)
+{
+	void *fsdata;
+	struct page *page;
+	int err;
+
+	err = inode_newsize_ok(inode, pos);
+	if (err)
+		goto out;
+	if ((pos & (inode->i_sb->s_blocksize -1)) == 0)
+		pos++;
+
+	err = reiserfs_write_begin(NULL, inode->i_mapping, pos, 0, 0,
+			&page, &fsdata);
+	if (err)
+		goto out;
+
+	err = reiserfs_write_end(NULL, inode->i_mapping, pos, 0, 0, page, fsdata);
+	if (err)
+		goto out;
+
+out:
+	return err;
+
+}
+
 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
 {
 	struct inode *inode = d_inode(dentry);
@@ -3313,7 +3329,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
 
 		/* fill in hole pointers in the expanding truncate case. */
 		if (attr->ia_size > inode->i_size) {
-			error = generic_cont_expand_simple(inode, attr->ia_size);
+			error = cont_expand(inode, attr->ia_size);
 			if (REISERFS_I(inode)->i_prealloc_count > 0) {
 				int err;
 				struct reiserfs_transaction_handle th;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 877bccb9874f..67f81b737935 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -259,8 +259,6 @@ enum positive_aop_returns {
 	AOP_TRUNCATED_PAGE	= 0x80001,
 };
 
-#define AOP_FLAG_CONT_EXPAND		0x0001 /* called from cont_expand */
-
 /*
  * oh the beauties of C type declarations.
  */
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/10] fs: Remove flags parameter from aops->write_begin()
  2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
                   ` (8 preceding siblings ...)
  2018-02-19 14:02 ` [PATCH 09/10] reiserfs: cont_expand() to eliminate AOP_FLAG_CONT_EXPAND Goldwyn Rodrigues
@ 2018-02-19 14:02 ` Goldwyn Rodrigues
  9 siblings, 0 replies; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-19 14:02 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mhocko, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 drivers/gpu/drm/i915/i915_gem.c            |  4 ++--
 drivers/staging/lustre/lustre/llite/rw26.c |  5 ++---
 fs/9p/vfs_addr.c                           |  4 ++--
 fs/adfs/inode.c                            |  4 ++--
 fs/affs/file.c                             | 10 +++++-----
 fs/afs/internal.h                          |  2 +-
 fs/afs/write.c                             |  4 ++--
 fs/block_dev.c                             |  4 ++--
 fs/buffer.c                                | 18 +++++++++---------
 fs/ceph/addr.c                             |  4 ++--
 fs/cifs/file.c                             |  4 ++--
 fs/ecryptfs/mmap.c                         |  4 ++--
 fs/exofs/inode.c                           |  5 ++---
 fs/ext2/inode.c                            |  4 ++--
 fs/ext4/ext4.h                             |  2 --
 fs/ext4/inline.c                           | 18 ++++++------------
 fs/ext4/inode.c                            | 18 +++++++++---------
 fs/ext4/move_extent.c                      |  4 ++--
 fs/f2fs/data.c                             |  4 ++--
 fs/f2fs/f2fs.h                             |  2 +-
 fs/f2fs/super.c                            |  2 +-
 fs/fat/inode.c                             |  4 ++--
 fs/fuse/file.c                             |  6 +++---
 fs/gfs2/aops.c                             |  4 ++--
 fs/hfs/extent.c                            |  2 +-
 fs/hfs/inode.c                             |  4 ++--
 fs/hfsplus/extents.c                       |  2 +-
 fs/hfsplus/inode.c                         |  4 ++--
 fs/hostfs/hostfs_kern.c                    |  4 ++--
 fs/hpfs/file.c                             |  4 ++--
 fs/hugetlbfs/inode.c                       |  2 +-
 fs/iomap.c                                 |  2 +-
 fs/jffs2/file.c                            |  6 +++---
 fs/jfs/inode.c                             |  4 ++--
 fs/libfs.c                                 |  4 ++--
 fs/minix/inode.c                           |  4 ++--
 fs/namei.c                                 |  2 +-
 fs/nfs/file.c                              |  4 ++--
 fs/nilfs2/recovery.c                       |  2 +-
 fs/ocfs2/aops.c                            |  2 +-
 fs/omfs/file.c                             |  4 ++--
 fs/reiserfs/inode.c                        |  6 +++---
 fs/sysv/itree.c                            |  4 ++--
 fs/ubifs/file.c                            | 11 +++++------
 fs/udf/file.c                              |  4 ++--
 fs/udf/inode.c                             |  4 ++--
 fs/ufs/inode.c                             |  4 ++--
 include/linux/buffer_head.h                |  6 +++---
 include/linux/fs.h                         |  6 +++---
 include/linux/pagemap.h                    |  2 +-
 include/trace/events/ext4.h                | 21 ++++++++-------------
 include/trace/events/f2fs.h                | 12 ++++--------
 mm/filemap.c                               | 10 ++++------
 mm/shmem.c                                 |  2 +-
 54 files changed, 133 insertions(+), 155 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index dd89abd2263d..ec9efb4d93c9 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2797,7 +2797,7 @@ i915_gem_object_pwrite_gtt(struct drm_i915_gem_object *obj,
 			len = remain;
 
 		err = pagecache_write_begin(obj->base.filp, mapping,
-					    offset, len, 0,
+					    offset, len,
 					    &page, &data);
 		if (err < 0)
 			return err;
@@ -5612,7 +5612,7 @@ i915_gem_object_create_from_data(struct drm_i915_private *dev_priv,
 		void *pgdata, *vaddr;
 
 		err = pagecache_write_begin(file, file->f_mapping,
-					    offset, len, 0,
+					    offset, len,
 					    &page, &pgdata);
 		if (err < 0)
 			goto fail;
diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c
index 722e5ea1af5f..735512b99e89 100644
--- a/drivers/staging/lustre/lustre/llite/rw26.c
+++ b/drivers/staging/lustre/lustre/llite/rw26.c
@@ -439,7 +439,7 @@ static int ll_prepare_partial_page(const struct lu_env *env, struct cl_io *io,
 }
 
 static int ll_write_begin(struct file *file, struct address_space *mapping,
-			  loff_t pos, unsigned int len, unsigned int flags,
+			  loff_t pos, unsigned int len,
 			  struct page **pagep, void **fsdata)
 {
 	struct ll_cl_context *lcc;
@@ -489,8 +489,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
 			goto out;
 
 		if (!vmpage) {
-			vmpage = grab_cache_page_write_begin(mapping, index,
-							     flags);
+			vmpage = grab_cache_page_write_begin(mapping, index);
 			if (!vmpage) {
 				result = -ENOMEM;
 				goto out;
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index e1cbdfdb7c68..5a51110a157c 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -266,7 +266,7 @@ v9fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 }
 
 static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
-			    loff_t pos, unsigned len, unsigned flags,
+			    loff_t pos, unsigned len,
 			    struct page **pagep, void **fsdata)
 {
 	int retval = 0;
@@ -280,7 +280,7 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
 
 	v9inode = V9FS_I(inode);
 start:
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page) {
 		retval = -ENOMEM;
 		goto out;
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 8dbd36f5e581..c47af801d427 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -54,13 +54,13 @@ static void adfs_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int adfs_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
 	*pagep = NULL;
-	ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+	ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata,
 				adfs_get_block,
 				&ADFS_I(mapping->host)->mmu_private);
 	if (unlikely(ret))
diff --git a/fs/affs/file.c b/fs/affs/file.c
index a85817f54483..2ca2044e4702 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -413,13 +413,13 @@ affs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 }
 
 static int affs_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
 	*pagep = NULL;
-	ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+	ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata,
 				affs_get_block,
 				&AFFS_I(mapping->host)->mmu_private);
 	if (unlikely(ret))
@@ -629,7 +629,7 @@ affs_readpage_ofs(struct file *file, struct page *page)
 }
 
 static int affs_write_begin_ofs(struct file *file, struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned flags,
+				loff_t pos, unsigned len,
 				struct page **pagep, void **fsdata)
 {
 	struct inode *inode = mapping->host;
@@ -649,7 +649,7 @@ static int affs_write_begin_ofs(struct file *file, struct address_space *mapping
 	}
 
 	index = pos >> PAGE_SHIFT;
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 	*pagep = page;
@@ -858,7 +858,7 @@ affs_truncate(struct inode *inode)
 		loff_t isize = inode->i_size;
 		int res;
 
-		res = mapping->a_ops->write_begin(NULL, mapping, isize, 0, 0, &page, &fsdata);
+		res = mapping->a_ops->write_begin(NULL, mapping, isize, 0, &page, &fsdata);
 		if (!res)
 			res = mapping->a_ops->write_end(NULL, mapping, isize, 0, 0, page, fsdata);
 		else
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index f38d6a561a84..0cc5270596c6 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -938,7 +938,7 @@ extern int afs_check_volume_status(struct afs_volume *, struct key *);
  */
 extern int afs_set_page_dirty(struct page *);
 extern int afs_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata);
 extern int afs_write_end(struct file *file, struct address_space *mapping,
 			loff_t pos, unsigned len, unsigned copied,
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 9370e2feb999..82760729e222 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -68,7 +68,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
  * prepare to perform part of a write to a page
  */
 int afs_write_begin(struct file *file, struct address_space *mapping,
-		    loff_t pos, unsigned len, unsigned flags,
+		    loff_t pos, unsigned len,
 		    struct page **pagep, void **fsdata)
 {
 	struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
@@ -88,7 +88,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
 	 */
 	BUILD_BUG_ON(PAGE_SIZE > 32768 && sizeof(page->private) < 8);
 
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 4a181fcb5175..b0f54ef9193a 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -578,10 +578,10 @@ static int blkdev_readpages(struct file *file, struct address_space *mapping,
 }
 
 static int blkdev_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
-	return block_write_begin(mapping, pos, len, flags, pagep,
+	return block_write_begin(mapping, pos, len, pagep,
 				 blkdev_get_block);
 }
 
diff --git a/fs/buffer.c b/fs/buffer.c
index 1787b29f3fb3..5f4c912c3bdf 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2082,13 +2082,13 @@ static int __block_commit_write(struct inode *inode, struct page *page,
  * The filesystem needs to handle block truncation upon failure.
  */
 int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len,
-		unsigned flags, struct page **pagep, get_block_t *get_block)
+		struct page **pagep, get_block_t *get_block)
 {
 	pgoff_t index = pos >> PAGE_SHIFT;
 	struct page *page;
 	int status;
 
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 
@@ -2334,7 +2334,7 @@ int generic_cont_expand_simple(struct inode *inode, loff_t size)
 		goto out;
 
 	err = pagecache_write_begin(NULL, mapping, size, 0,
-				    AOP_FLAG_CONT_EXPAND, &page, &fsdata);
+				    &page, &fsdata);
 	if (err)
 		goto out;
 
@@ -2369,7 +2369,7 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
 		}
 		len = PAGE_SIZE - zerofrom;
 
-		err = pagecache_write_begin(file, mapping, curpos, len, 0,
+		err = pagecache_write_begin(file, mapping, curpos, len,
 					    &page, &fsdata);
 		if (err)
 			goto out;
@@ -2402,7 +2402,7 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
 		}
 		len = offset - zerofrom;
 
-		err = pagecache_write_begin(file, mapping, curpos, len, 0,
+		err = pagecache_write_begin(file, mapping, curpos, len,
 					    &page, &fsdata);
 		if (err)
 			goto out;
@@ -2423,7 +2423,7 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
  * We may have to extend the file.
  */
 int cont_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata,
 			get_block_t *get_block, loff_t *bytes)
 {
@@ -2442,7 +2442,7 @@ int cont_write_begin(struct file *file, struct address_space *mapping,
 		(*bytes)++;
 	}
 
-	return block_write_begin(mapping, pos, len, flags, pagep, get_block);
+	return block_write_begin(mapping, pos, len, pagep, get_block);
 }
 EXPORT_SYMBOL(cont_write_begin);
 
@@ -2551,7 +2551,7 @@ static void attach_nobh_buffers(struct page *page, struct buffer_head *head)
  * The filesystem needs to handle block truncation upon failure.
  */
 int nobh_write_begin(struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata,
 			get_block_t *get_block)
 {
@@ -2573,7 +2573,7 @@ int nobh_write_begin(struct address_space *mapping,
 	from = pos & (PAGE_SIZE - 1);
 	to = from + len;
 
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 	*pagep = page;
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index b4336b42ce3b..d21c2f842e08 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1322,7 +1322,7 @@ static int ceph_update_writeable_page(struct file *file,
  * clean, or already dirty within the same snap context.
  */
 static int ceph_write_begin(struct file *file, struct address_space *mapping,
-			    loff_t pos, unsigned len, unsigned flags,
+			    loff_t pos, unsigned len,
 			    struct page **pagep, void **fsdata)
 {
 	struct inode *inode = file_inode(file);
@@ -1332,7 +1332,7 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
 
 	do {
 		/* get a page */
-		page = grab_cache_page_write_begin(mapping, index, 0);
+		page = grab_cache_page_write_begin(mapping, index);
 		if (!page)
 			return -ENOMEM;
 
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 7cee97b93a61..1d5be6cb28d5 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3944,7 +3944,7 @@ bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
 }
 
 static int cifs_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int oncethru = 0;
@@ -3958,7 +3958,7 @@ static int cifs_write_begin(struct file *file, struct address_space *mapping,
 	cifs_dbg(FYI, "write_begin from %lld len %d\n", (long long)pos, len);
 
 start:
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page) {
 		rc = -ENOMEM;
 		goto out;
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index cdf358b209d9..10d4dbd844c0 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -277,7 +277,7 @@ static int fill_zeros_to_end_of_page(struct page *page, unsigned int to)
  */
 static int ecryptfs_write_begin(struct file *file,
 			struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	pgoff_t index = pos >> PAGE_SHIFT;
@@ -285,7 +285,7 @@ static int ecryptfs_write_begin(struct file *file,
 	loff_t prev_page_end_size;
 	int rc = 0;
 
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 	*pagep = page;
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 0ac62811b341..b6d39012397d 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -862,7 +862,7 @@ static void _write_failed(struct inode *inode, loff_t to)
 }
 
 int exofs_write_begin(struct file *file, struct address_space *mapping,
-		loff_t pos, unsigned len, unsigned flags,
+		loff_t pos, unsigned len,
 		struct page **pagep, void **fsdata)
 {
 	int ret = 0;
@@ -870,8 +870,7 @@ int exofs_write_begin(struct file *file, struct address_space *mapping,
 
 	page = *pagep;
 	if (page == NULL) {
-		page = grab_cache_page_write_begin(mapping, pos >> PAGE_SHIFT,
-						   flags);
+		page = grab_cache_page_write_begin(mapping, pos >> PAGE_SHIFT);
 		if (!page) {
 			EXOFS_DBGMSG("grab_cache_page_write_begin failed\n");
 			return -ENOMEM;
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 9b2ac55ac34f..0129a095f91c 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -881,12 +881,12 @@ ext2_readpages(struct file *file, struct address_space *mapping,
 
 static int
 ext2_write_begin(struct file *file, struct address_space *mapping,
-		loff_t pos, unsigned len, unsigned flags,
+		loff_t pos, unsigned len,
 		struct page **pagep, void **fsdata)
 {
 	int ret;
 
-	ret = block_write_begin(mapping, pos, len, flags, pagep,
+	ret = block_write_begin(mapping, pos, len, pagep,
 				ext2_get_block);
 	if (ret < 0)
 		ext2_write_failed(mapping, pos + len);
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 3241475a1733..ffeae3c26887 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2954,7 +2954,6 @@ extern int ext4_readpage_inline(struct inode *inode, struct page *page);
 extern int ext4_try_to_write_inline_data(struct address_space *mapping,
 					 struct inode *inode,
 					 loff_t pos, unsigned len,
-					 unsigned flags,
 					 struct page **pagep);
 extern int ext4_write_inline_data_end(struct inode *inode,
 				      loff_t pos, unsigned len,
@@ -2967,7 +2966,6 @@ ext4_journalled_write_inline_data(struct inode *inode,
 extern int ext4_da_write_inline_data_begin(struct address_space *mapping,
 					   struct inode *inode,
 					   loff_t pos, unsigned len,
-					   unsigned flags,
 					   struct page **pagep,
 					   void **fsdata);
 extern int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index e59f8a8e40e7..298830b25b9b 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -517,8 +517,7 @@ int ext4_readpage_inline(struct inode *inode, struct page *page)
 }
 
 static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
-					      struct inode *inode,
-					      unsigned flags)
+					      struct inode *inode)
 {
 	int ret, needed_blocks, no_expand;
 	handle_t *handle = NULL;
@@ -555,7 +554,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
 	 * started */
 	nofs_flags = memalloc_nofs_save();
 
-	page = grab_cache_page_write_begin(mapping, 0, flags);
+	page = grab_cache_page_write_begin(mapping, 0);
 
 	memalloc_nofs_restore(nofs_flags);
 
@@ -643,7 +642,6 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
 int ext4_try_to_write_inline_data(struct address_space *mapping,
 				  struct inode *inode,
 				  loff_t pos, unsigned len,
-				  unsigned flags,
 				  struct page **pagep)
 {
 	int ret;
@@ -684,7 +682,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
 
 	nofs_flags = memalloc_nofs_save();
 
-	page = grab_cache_page_write_begin(mapping, 0, flags);
+	page = grab_cache_page_write_begin(mapping, 0);
 
 	memalloc_nofs_restore(nofs_flags);
 	if (!page) {
@@ -717,8 +715,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
 	brelse(iloc.bh);
 	return ret;
 convert:
-	return ext4_convert_inline_data_to_extent(mapping,
-						  inode, flags);
+	return ext4_convert_inline_data_to_extent(mapping, inode);
 }
 
 int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
@@ -793,13 +790,12 @@ ext4_journalled_write_inline_data(struct inode *inode,
  */
 static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping,
 						 struct inode *inode,
-						 unsigned flags,
 						 void **fsdata)
 {
 	int ret = 0, inline_size;
 	struct page *page;
 
-	page = grab_cache_page_write_begin(mapping, 0, flags);
+	page = grab_cache_page_write_begin(mapping, 0);
 	if (!page)
 		return -ENOMEM;
 
@@ -852,7 +848,6 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping,
 int ext4_da_write_inline_data_begin(struct address_space *mapping,
 				    struct inode *inode,
 				    loff_t pos, unsigned len,
-				    unsigned flags,
 				    struct page **pagep,
 				    void **fsdata)
 {
@@ -886,7 +881,6 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
 		int nofs_flags = memalloc_nofs_save();
 		ret = ext4_da_convert_inline_data_to_extent(mapping,
 							    inode,
-							    flags,
 							    fsdata);
 		memalloc_nofs_restore(nofs_flags);
 		ext4_journal_stop(handle);
@@ -897,7 +891,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
 	}
 
 
-	page = grab_cache_page_write_begin(mapping, 0, flags);
+	page = grab_cache_page_write_begin(mapping, 0);
 	if (!page) {
 		ret = -ENOMEM;
 		goto out_journal;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c94780075b04..a8b8bad7bd8b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1239,7 +1239,7 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len,
 #endif
 
 static int ext4_write_begin(struct file *file, struct address_space *mapping,
-			    loff_t pos, unsigned len, unsigned flags,
+			    loff_t pos, unsigned len,
 			    struct page **pagep, void **fsdata)
 {
 	struct inode *inode = mapping->host;
@@ -1253,7 +1253,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
 	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
 		return -EIO;
 
-	trace_ext4_write_begin(inode, pos, len, flags);
+	trace_ext4_write_begin(inode, pos, len);
 	/*
 	 * Reserve one block more for addition to orphan list in case
 	 * we allocate blocks but write fails for some reason
@@ -1265,7 +1265,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
 
 	if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
 		ret = ext4_try_to_write_inline_data(mapping, inode, pos, len,
-						    flags, pagep);
+						    pagep);
 		if (ret < 0)
 			return ret;
 		if (ret == 1)
@@ -1280,7 +1280,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
 	 * the page (if needed) without using GFP_NOFS.
 	 */
 retry_grab:
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 	unlock_page(page);
@@ -3003,7 +3003,7 @@ static int ext4_da_write_credits(struct inode *inode, loff_t pos, unsigned len)
 }
 
 static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
-			       loff_t pos, unsigned len, unsigned flags,
+			       loff_t pos, unsigned len,
 			       struct page **pagep, void **fsdata)
 {
 	int ret, retries = 0;
@@ -3021,14 +3021,14 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
 	    S_ISLNK(inode->i_mode)) {
 		*fsdata = (void *)FALL_BACK_TO_NONDELALLOC;
 		return ext4_write_begin(file, mapping, pos,
-					len, flags, pagep, fsdata);
+					len, pagep, fsdata);
 	}
 	*fsdata = (void *)0;
-	trace_ext4_da_write_begin(inode, pos, len, flags);
+	trace_ext4_da_write_begin(inode, pos, len);
 
 	if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
 		ret = ext4_da_write_inline_data_begin(mapping, inode,
-						      pos, len, flags,
+						      pos, len,
 						      pagep, fsdata);
 		if (ret < 0)
 			return ret;
@@ -3044,7 +3044,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
 	 * the page (if needed) without using GFP_NOFS.
 	 */
 retry_grab:
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 	unlock_page(page);
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 9e35e72dcd29..e0caa00ea6fb 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -142,13 +142,13 @@ mext_page_double_lock(struct inode *inode1, struct inode *inode2,
 		mapping[1] = inode1->i_mapping;
 	}
 
-	page[0] = grab_cache_page_write_begin(mapping[0], index1, 0);
+	page[0] = grab_cache_page_write_begin(mapping[0], index1);
 	if (!page[0]) {
 		memalloc_nofs_restore(nofs_fl);
 		return -ENOMEM;
 	}
 
-	page[1] = grab_cache_page_write_begin(mapping[1], index2, 0);
+	page[1] = grab_cache_page_write_begin(mapping[1], index2);
 	memalloc_nofs_restore(nofs_fl);
 	if (!page[1]) {
 		unlock_page(page[0]);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7578ed1a85e0..bb99733b819d 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2134,7 +2134,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
 }
 
 static int f2fs_write_begin(struct file *file, struct address_space *mapping,
-		loff_t pos, unsigned len, unsigned flags,
+		loff_t pos, unsigned len,
 		struct page **pagep, void **fsdata)
 {
 	struct inode *inode = mapping->host;
@@ -2145,7 +2145,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 	block_t blkaddr = NULL_ADDR;
 	int err = 0;
 
-	trace_f2fs_write_begin(inode, pos, len, flags);
+	trace_f2fs_write_begin(inode, pos, len);
 
 	if (f2fs_is_atomic_file(inode) &&
 			!available_free_memory(sbi, INMEM_PAGES)) {
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 98b0827af06e..b314b0cca8a2 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1923,7 +1923,7 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
 		return grab_cache_page(mapping, index);
 
 	nofs_flags = memalloc_nofs_save();
-	pg = grab_cache_page_write_begin(mapping, index, 0);
+	pg = grab_cache_page_write_begin(mapping, index);
 	memalloc_nofs_restore(nofs_flags);
 	return pg;
 }
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 8173ae688814..e7a9a590ddd9 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1507,7 +1507,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
 		tocopy = min_t(unsigned long, sb->s_blocksize - offset,
 								towrite);
 retry:
-		err = a_ops->write_begin(NULL, mapping, off, tocopy, 0,
+		err = a_ops->write_begin(NULL, mapping, off, tocopy,
 							&page, NULL);
 		if (unlikely(err)) {
 			if (err == -ENOMEM) {
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index ffbbf0520d9e..652a0c5f2908 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -214,13 +214,13 @@ static void fat_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int fat_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int err;
 
 	*pagep = NULL;
-	err = cont_write_begin(file, mapping, pos, len, flags,
+	err = cont_write_begin(file, mapping, pos, len,
 				pagep, fsdata, fat_get_block,
 				&MSDOS_I(mapping->host)->mmu_private);
 	if (err < 0)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index a201fb0ac64f..eeb13c97584a 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1063,7 +1063,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
 			break;
 
 		err = -ENOMEM;
-		page = grab_cache_page_write_begin(mapping, index, 0);
+		page = grab_cache_page_write_begin(mapping, index);
 		if (!page)
 			break;
 
@@ -1940,7 +1940,7 @@ static int fuse_writepages(struct address_space *mapping,
  * but how to implement it without killing performance need more thinking.
  */
 static int fuse_write_begin(struct file *file, struct address_space *mapping,
-		loff_t pos, unsigned len, unsigned flags,
+		loff_t pos, unsigned len,
 		struct page **pagep, void **fsdata)
 {
 	pgoff_t index = pos >> PAGE_SHIFT;
@@ -1951,7 +1951,7 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping,
 
 	WARN_ON(!fc->writeback_cache);
 
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		goto error;
 
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 802d2d223902..c438c71bfec6 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -659,7 +659,7 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping,
  */
 
 static int gfs2_write_begin(struct file *file, struct address_space *mapping,
-			    loff_t pos, unsigned len, unsigned flags,
+			    loff_t pos, unsigned len,
 			    struct page **pagep, void **fsdata)
 {
 	struct gfs2_inode *ip = GFS2_I(mapping->host);
@@ -722,7 +722,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
 
 	error = -ENOMEM;
 	nofs_flags = memalloc_nofs_save();
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	memalloc_nofs_restore(nofs_flags);
 	*pagep = page;
 	if (unlikely(!page))
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
index 5d0182654580..e7564f0a9110 100644
--- a/fs/hfs/extent.c
+++ b/fs/hfs/extent.c
@@ -485,7 +485,7 @@ void hfs_file_truncate(struct inode *inode)
 
 		/* XXX: Can use generic_cont_expand? */
 		size = inode->i_size - 1;
-		res = pagecache_write_begin(NULL, mapping, size+1, 0, 0,
+		res = pagecache_write_begin(NULL, mapping, size+1, 0,
 					    &page, &fsdata);
 		if (!res) {
 			res = pagecache_write_end(NULL, mapping, size+1, 0, 0,
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 2538b49cc349..38a5a44ed950 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -49,13 +49,13 @@ static void hfs_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int hfs_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
 	*pagep = NULL;
-	ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+	ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata,
 				hfs_get_block,
 				&HFS_I(mapping->host)->phys_size);
 	if (unlikely(ret))
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index e8770935ce6d..0cc237ef2732 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -546,7 +546,7 @@ void hfsplus_file_truncate(struct inode *inode)
 		void *fsdata;
 		loff_t size = inode->i_size;
 
-		res = pagecache_write_begin(NULL, mapping, size, 0, 0,
+		res = pagecache_write_begin(NULL, mapping, size, 0,
 					    &page, &fsdata);
 		if (res)
 			return;
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index c0c8d433864f..70d81f4f3b8c 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -44,13 +44,13 @@ static void hfsplus_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int hfsplus_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
 	*pagep = NULL;
-	ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+	ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata,
 				hfsplus_get_block,
 				&HFSPLUS_I(mapping->host)->phys_size);
 	if (unlikely(ret))
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index c148e7f4f451..947a5bf543aa 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -468,12 +468,12 @@ static int hostfs_readpage(struct file *file, struct page *page)
 }
 
 static int hostfs_write_begin(struct file *file, struct address_space *mapping,
-			      loff_t pos, unsigned len, unsigned flags,
+			      loff_t pos, unsigned len,
 			      struct page **pagep, void **fsdata)
 {
 	pgoff_t index = pos >> PAGE_SHIFT;
 
-	*pagep = grab_cache_page_write_begin(mapping, index, flags);
+	*pagep = grab_cache_page_write_begin(mapping, index);
 	if (!*pagep)
 		return -ENOMEM;
 	return 0;
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index 1ecec124e76f..b4caa9bd0d1f 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -152,13 +152,13 @@ static void hpfs_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int hpfs_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
 	*pagep = NULL;
-	ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+	ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata,
 				hpfs_get_block,
 				&hpfs_i(mapping->host)->mmu_private);
 	if (unlikely(ret))
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 8fe1b0aa2896..1911f3bc130b 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -302,7 +302,7 @@ static ssize_t hugetlbfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
 
 static int hugetlbfs_write_begin(struct file *file,
 			struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	return -EINVAL;
diff --git a/fs/iomap.c b/fs/iomap.c
index afaf6ffff34f..711dfa22213c 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -124,7 +124,7 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
 		return -EINTR;
 
 	nofs_flags = memalloc_nofs_save();
-	page = grab_cache_page_write_begin(inode->i_mapping, index, 0);
+	page = grab_cache_page_write_begin(inode->i_mapping, index);
 	memalloc_nofs_restore(nofs_flags);
 	if (!page)
 		return -ENOMEM;
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index bd0428bebe9b..aba7e915e7a4 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -25,7 +25,7 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
 			loff_t pos, unsigned len, unsigned copied,
 			struct page *pg, void *fsdata);
 static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata);
 static int jffs2_readpage (struct file *filp, struct page *pg);
 
@@ -129,7 +129,7 @@ static int jffs2_readpage (struct file *filp, struct page *pg)
 }
 
 static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	struct page *pg;
@@ -139,7 +139,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
 	uint32_t pageofs = index << PAGE_SHIFT;
 	int ret = 0;
 
-	pg = grab_cache_page_write_begin(mapping, index, flags);
+	pg = grab_cache_page_write_begin(mapping, index);
 	if (!pg)
 		return -ENOMEM;
 	*pagep = pg;
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 054cc761b426..f65876c6c597 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -314,12 +314,12 @@ static void jfs_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int jfs_write_begin(struct file *file, struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned flags,
+				loff_t pos, unsigned len,
 				struct page **pagep, void **fsdata)
 {
 	int ret;
 
-	ret = nobh_write_begin(mapping, pos, len, flags, pagep, fsdata,
+	ret = nobh_write_begin(mapping, pos, len, pagep, fsdata,
 				jfs_get_block);
 	if (unlikely(ret))
 		jfs_write_failed(mapping, pos + len);
diff --git a/fs/libfs.c b/fs/libfs.c
index 7ff3cb904acd..0af0ba1f9283 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -424,7 +424,7 @@ int simple_readpage(struct file *file, struct page *page)
 EXPORT_SYMBOL(simple_readpage);
 
 int simple_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	struct page *page;
@@ -432,7 +432,7 @@ int simple_write_begin(struct file *file, struct address_space *mapping,
 
 	index = pos >> PAGE_SHIFT;
 
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 72e308c3e66b..26caaba24f0d 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -407,12 +407,12 @@ static void minix_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int minix_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
-	ret = block_write_begin(mapping, pos, len, flags, pagep,
+	ret = block_write_begin(mapping, pos, len, pagep,
 				minix_get_block);
 	if (unlikely(ret))
 		minix_write_failed(mapping, pos + len);
diff --git a/fs/namei.c b/fs/namei.c
index 6cb314a256c5..b23142853feb 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4802,7 +4802,7 @@ int __page_symlink(struct inode *inode, const char *symname, int len, int nofs)
 
 retry:
 	err = pagecache_write_begin(NULL, mapping, 0, len-1,
-				flags, &page, &fsdata);
+				&page, &fsdata);
 	if (err)
 		goto fail;
 
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 81cca49a8375..d3d5c6ef904b 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -322,7 +322,7 @@ static int nfs_want_read_modify_write(struct file *file, struct page *page,
  * increment the page use counts until he is done with the page.
  */
 static int nfs_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
@@ -334,7 +334,7 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping,
 		file, mapping->host->i_ino, len, (long long) pos);
 
 start:
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 	*pagep = page;
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c
index 5139efed1888..c986bab23423 100644
--- a/fs/nilfs2/recovery.c
+++ b/fs/nilfs2/recovery.c
@@ -520,7 +520,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
 
 		pos = rb->blkoff << inode->i_blkbits;
 		err = block_write_begin(inode->i_mapping, pos, blocksize,
-					0, &page, nilfs_get_block);
+					&page, nilfs_get_block);
 		if (unlikely(err)) {
 			loff_t isize = inode->i_size;
 
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index e8e205bf2e41..5650df1b7dee 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -1906,7 +1906,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
 }
 
 static int ocfs2_write_begin(struct file *file, struct address_space *mapping,
-			     loff_t pos, unsigned len, unsigned flags,
+			     loff_t pos, unsigned len,
 			     struct page **pagep, void **fsdata)
 {
 	int ret;
diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index bf83e6644333..c4db04b0e120 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -317,12 +317,12 @@ static void omfs_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int omfs_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
-	ret = block_write_begin(mapping, pos, len, flags, pagep,
+	ret = block_write_begin(mapping, pos, len, pagep,
 				omfs_get_block);
 	if (unlikely(ret))
 		omfs_write_failed(mapping, pos + len);
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 44895c4dc354..8b6dcd7d327b 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2751,7 +2751,7 @@ static void reiserfs_truncate_failed_write(struct inode *inode)
 
 static int reiserfs_write_begin(struct file *file,
 				struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned flags,
+				loff_t pos, unsigned len,
 				struct page **pagep, void **fsdata)
 {
 	struct inode *inode;
@@ -2762,7 +2762,7 @@ static int reiserfs_write_begin(struct file *file,
 
  	inode = mapping->host;
 	index = pos >> PAGE_SHIFT;
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (!page)
 		return -ENOMEM;
 	*pagep = page;
@@ -3280,7 +3280,7 @@ int cont_expand(struct inode *inode, loff_t pos)
 	if ((pos & (inode->i_sb->s_blocksize -1)) == 0)
 		pos++;
 
-	err = reiserfs_write_begin(NULL, inode->i_mapping, pos, 0, 0,
+	err = reiserfs_write_begin(NULL, inode->i_mapping, pos, 0,
 			&page, &fsdata);
 	if (err)
 		goto out;
diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index bcb67b0cabe7..ec72eaa9f4b3 100644
--- a/fs/sysv/itree.c
+++ b/fs/sysv/itree.c
@@ -477,12 +477,12 @@ static void sysv_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int sysv_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
-	ret = block_write_begin(mapping, pos, len, flags, pagep, get_block);
+	ret = block_write_begin(mapping, pos, len, pagep, get_block);
 	if (unlikely(ret))
 		sysv_write_failed(mapping, pos + len);
 
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index cf348ba99238..53084b29b055 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -226,8 +226,7 @@ static void release_existing_page_budget(struct ubifs_info *c)
 }
 
 static int write_begin_slow(struct address_space *mapping,
-			    loff_t pos, unsigned len, struct page **pagep,
-			    unsigned flags)
+			    loff_t pos, unsigned len, struct page **pagep)
 {
 	struct inode *inode = mapping->host;
 	struct ubifs_info *c = inode->i_sb->s_fs_info;
@@ -255,7 +254,7 @@ static int write_begin_slow(struct address_space *mapping,
 	if (unlikely(err))
 		return err;
 
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (unlikely(!page)) {
 		ubifs_release_budget(c, &req);
 		return -ENOMEM;
@@ -430,7 +429,7 @@ static int allocate_budget(struct ubifs_info *c, struct page *page,
  * without forcing write-back. The slow path does not make this assumption.
  */
 static int ubifs_write_begin(struct file *file, struct address_space *mapping,
-			     loff_t pos, unsigned len, unsigned flags,
+			     loff_t pos, unsigned len,
 			     struct page **pagep, void **fsdata)
 {
 	struct inode *inode = mapping->host;
@@ -448,7 +447,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
 		return -EROFS;
 
 	/* Try out the fast-path part first */
-	page = grab_cache_page_write_begin(mapping, index, flags);
+	page = grab_cache_page_write_begin(mapping, index);
 	if (unlikely(!page))
 		return -ENOMEM;
 
@@ -504,7 +503,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
 		unlock_page(page);
 		put_page(page);
 
-		return write_begin_slow(mapping, pos, len, pagep, flags);
+		return write_begin_slow(mapping, pos, len, pagep);
 	}
 
 	/*
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 356c2bf148a5..9a7ed361ae92 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -88,14 +88,14 @@ static int udf_adinicb_writepage(struct page *page,
 
 static int udf_adinicb_write_begin(struct file *file,
 			struct address_space *mapping, loff_t pos,
-			unsigned len, unsigned flags, struct page **pagep,
+			unsigned len, struct page **pagep,
 			void **fsdata)
 {
 	struct page *page;
 
 	if (WARN_ON_ONCE(pos >= PAGE_SIZE))
 		return -EIO;
-	page = grab_cache_page_write_begin(mapping, 0, flags);
+	page = grab_cache_page_write_begin(mapping, 0);
 	if (!page)
 		return -ENOMEM;
 	*pagep = page;
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index c23744d5ae5c..b6a30322052a 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -195,12 +195,12 @@ static int udf_readpages(struct file *file, struct address_space *mapping,
 }
 
 static int udf_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
-	ret = block_write_begin(mapping, pos, len, flags, pagep, udf_get_block);
+	ret = block_write_begin(mapping, pos, len, pagep, udf_get_block);
 	if (unlikely(ret))
 		udf_write_failed(mapping, pos + len);
 	return ret;
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index c843ec858cf7..4f0be14542dc 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -495,12 +495,12 @@ static void ufs_write_failed(struct address_space *mapping, loff_t to)
 }
 
 static int ufs_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	int ret;
 
-	ret = block_write_begin(mapping, pos, len, flags, pagep,
+	ret = block_write_begin(mapping, pos, len, pagep,
 				ufs_getfrag_block);
 	if (unlikely(ret))
 		ufs_write_failed(mapping, pos + len);
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 894e5d125de6..4a1b25dd602e 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -225,7 +225,7 @@ int block_read_full_page(struct page*, get_block_t*);
 int block_is_partially_uptodate(struct page *page, unsigned long from,
 				unsigned long count);
 int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len,
-		unsigned flags, struct page **pagep, get_block_t *get_block);
+		struct page **pagep, get_block_t *get_block);
 int __block_write_begin(struct page *page, loff_t pos, unsigned len,
 		get_block_t *get_block);
 int block_write_end(struct file *, struct address_space *,
@@ -237,7 +237,7 @@ int generic_write_end(struct file *, struct address_space *,
 void page_zero_new_buffers(struct page *page, unsigned from, unsigned to);
 void clean_page_buffers(struct page *page);
 int cont_write_begin(struct file *, struct address_space *, loff_t,
-			unsigned, unsigned, struct page **, void **,
+			unsigned, struct page **, void **,
 			get_block_t *, loff_t *);
 int generic_cont_expand_simple(struct inode *inode, loff_t size);
 int block_commit_write(struct page *page, unsigned from, unsigned to);
@@ -257,7 +257,7 @@ static inline int block_page_mkwrite_return(int err)
 }
 sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *);
 int block_truncate_page(struct address_space *, loff_t, get_block_t *);
-int nobh_write_begin(struct address_space *, loff_t, unsigned, unsigned,
+int nobh_write_begin(struct address_space *, loff_t, unsigned,
 				struct page **, void **, get_block_t*);
 int nobh_write_end(struct file *, struct address_space *,
 				loff_t, unsigned, unsigned,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 67f81b737935..7f9565ec56d7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -337,7 +337,7 @@ struct address_space_operations {
 			struct list_head *pages, unsigned nr_pages);
 
 	int (*write_begin)(struct file *, struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned flags,
+				loff_t pos, unsigned len,
 				struct page **pagep, void **fsdata);
 	int (*write_end)(struct file *, struct address_space *mapping,
 				loff_t pos, unsigned len, unsigned copied,
@@ -376,7 +376,7 @@ extern const struct address_space_operations empty_aops;
  * to write into the pagecache.
  */
 int pagecache_write_begin(struct file *, struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned flags,
+				loff_t pos, unsigned len,
 				struct page **pagep, void **fsdata);
 
 int pagecache_write_end(struct file *, struct address_space *mapping,
@@ -3127,7 +3127,7 @@ extern int noop_fsync(struct file *, loff_t, loff_t, int);
 extern int simple_empty(struct dentry *);
 extern int simple_readpage(struct file *file, struct page *page);
 extern int simple_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata);
 extern int simple_write_end(struct file *file, struct address_space *mapping,
 			loff_t pos, unsigned len, unsigned copied,
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 34ce3ebf97d5..7a8aa306b370 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -377,7 +377,7 @@ unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start,
 			struct page **entries, pgoff_t *indices);
 
 struct page *grab_cache_page_write_begin(struct address_space *mapping,
-			pgoff_t index, unsigned flags);
+			pgoff_t index);
 
 /*
  * Returns locked page at given index in given cache, creating it if needed.
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index 4d0e3af4e561..9f15847e5672 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -272,17 +272,15 @@ TRACE_EVENT(ext4_begin_ordered_truncate,
 
 DECLARE_EVENT_CLASS(ext4__write_begin,
 
-	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
-		 unsigned int flags),
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len),
 
-	TP_ARGS(inode, pos, len, flags),
+	TP_ARGS(inode, pos, len),
 
 	TP_STRUCT__entry(
 		__field(	dev_t,	dev			)
 		__field(	ino_t,	ino			)
 		__field(	loff_t,	pos			)
 		__field(	unsigned int, len		)
-		__field(	unsigned int, flags		)
 	),
 
 	TP_fast_assign(
@@ -290,29 +288,26 @@ DECLARE_EVENT_CLASS(ext4__write_begin,
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= pos;
 		__entry->len	= len;
-		__entry->flags	= flags;
 	),
 
-	TP_printk("dev %d,%d ino %lu pos %lld len %u flags %u",
+	TP_printk("dev %d,%d ino %lu pos %lld len %u",
 		  MAJOR(__entry->dev), MINOR(__entry->dev),
 		  (unsigned long) __entry->ino,
-		  __entry->pos, __entry->len, __entry->flags)
+		  __entry->pos, __entry->len)
 );
 
 DEFINE_EVENT(ext4__write_begin, ext4_write_begin,
 
-	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
-		 unsigned int flags),
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len),
 
-	TP_ARGS(inode, pos, len, flags)
+	TP_ARGS(inode, pos, len)
 );
 
 DEFINE_EVENT(ext4__write_begin, ext4_da_write_begin,
 
-	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
-		 unsigned int flags),
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len),
 
-	TP_ARGS(inode, pos, len, flags)
+	TP_ARGS(inode, pos, len)
 );
 
 DECLARE_EVENT_CLASS(ext4__write_end,
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 06c87f9f720c..f7167f5bf2ad 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -1090,17 +1090,15 @@ DEFINE_EVENT_CONDITION(f2fs__bio, f2fs_submit_write_bio,
 
 TRACE_EVENT(f2fs_write_begin,
 
-	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
-				unsigned int flags),
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len),
 
-	TP_ARGS(inode, pos, len, flags),
+	TP_ARGS(inode, pos, len),
 
 	TP_STRUCT__entry(
 		__field(dev_t,	dev)
 		__field(ino_t,	ino)
 		__field(loff_t,	pos)
 		__field(unsigned int, len)
-		__field(unsigned int, flags)
 	),
 
 	TP_fast_assign(
@@ -1108,14 +1106,12 @@ TRACE_EVENT(f2fs_write_begin,
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= pos;
 		__entry->len	= len;
-		__entry->flags	= flags;
 	),
 
-	TP_printk("dev = (%d,%d), ino = %lu, pos = %llu, len = %u, flags = %u",
+	TP_printk("dev = (%d,%d), ino = %lu, pos = %llu, len = %u",
 		show_dev_ino(__entry),
 		(unsigned long long)__entry->pos,
-		__entry->len,
-		__entry->flags)
+		__entry->len)
 );
 
 TRACE_EVENT(f2fs_write_end,
diff --git a/mm/filemap.c b/mm/filemap.c
index 07d28fedd62f..64f768e10fbd 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2974,13 +2974,12 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
 EXPORT_SYMBOL(generic_write_checks);
 
 int pagecache_write_begin(struct file *file, struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned flags,
+				loff_t pos, unsigned len,
 				struct page **pagep, void **fsdata)
 {
 	const struct address_space_operations *aops = mapping->a_ops;
 
-	return aops->write_begin(file, mapping, pos, len, flags,
-							pagep, fsdata);
+	return aops->write_begin(file, mapping, pos, len, pagep, fsdata);
 }
 EXPORT_SYMBOL(pagecache_write_begin);
 
@@ -3077,7 +3076,7 @@ EXPORT_SYMBOL(generic_file_direct_write);
  * page. This function is specifically for buffered writes.
  */
 struct page *grab_cache_page_write_begin(struct address_space *mapping,
-					pgoff_t index, unsigned flags)
+					pgoff_t index)
 {
 	struct page *page;
 
@@ -3097,7 +3096,6 @@ ssize_t generic_perform_write(struct file *file,
 	const struct address_space_operations *a_ops = mapping->a_ops;
 	long status = 0;
 	ssize_t written = 0;
-	unsigned int flags = 0;
 
 	do {
 		struct page *page;
@@ -3131,7 +3129,7 @@ ssize_t generic_perform_write(struct file *file,
 			break;
 		}
 
-		status = a_ops->write_begin(file, mapping, pos, bytes, flags,
+		status = a_ops->write_begin(file, mapping, pos, bytes,
 						&page, &fsdata);
 		if (unlikely(status < 0))
 			break;
diff --git a/mm/shmem.c b/mm/shmem.c
index 1907688b75ee..72f61a9631ea 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2352,7 +2352,7 @@ static int shmem_initxattrs(struct inode *, const struct xattr *, void *);
 
 static int
 shmem_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned len,
 			struct page **pagep, void **fsdata)
 {
 	struct inode *inode = mapping->host;
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 01/10] fs: buffer - Use memalloc_nofs API to allocate pages
  2018-02-19 14:02 ` [PATCH 01/10] fs: buffer - Use memalloc_nofs API to allocate pages Goldwyn Rodrigues
@ 2018-02-19 14:24   ` Michal Hocko
  0 siblings, 0 replies; 16+ messages in thread
From: Michal Hocko @ 2018-02-19 14:24 UTC (permalink / raw)
  To: Goldwyn Rodrigues; +Cc: linux-fsdevel, Goldwyn Rodrigues

On Mon 19-02-18 08:02:21, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 

I am pretty sure we really need a changelog here.

> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> ---
>  fs/buffer.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/buffer.c b/fs/buffer.c
> index 9a73924db22f..1787b29f3fb3 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -45,6 +45,7 @@
>  #include <linux/mpage.h>
>  #include <linux/bit_spinlock.h>
>  #include <linux/pagevec.h>
> +#include <linux/sched/mm.h>
>  #include <trace/events/block.h>
>  
>  static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
> @@ -836,7 +837,8 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
>  		bool retry)
>  {
>  	struct buffer_head *bh, *head;
> -	gfp_t gfp = GFP_NOFS;
> +	gfp_t gfp = GFP_KERNEL;
> +	unsigned int nofs_flags;
>  	long offset;
>  
>  	if (retry)
> @@ -844,6 +846,7 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
>  
>  	head = NULL;
>  	offset = PAGE_SIZE;
> +	nofs_flags = memalloc_nofs_save();

OK, so what is the actual scope here. What kind of context is recursion
problematic? This is a helper function and as such it is the caller who
knows the fs context. So this is quite opposite to what how the scope
API should be used. It is not about pure GFP_NOFS replacement. We really
want to document those scopes.

>  	while ((offset -= size) >= 0) {
>  		bh = alloc_buffer_head(gfp);
>  		if (!bh)
> @@ -858,11 +861,13 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
>  		/* Link the buffer to its page */
>  		set_bh_page(bh, page, offset);
>  	}
> +	memalloc_nofs_restore(nofs_flags);
>  	return head;
>  /*
>   * In case anything failed, we just free everything we got.
>   */
>  no_grow:
> +	memalloc_nofs_restore(nofs_flags);
>  	if (head) {
>  		do {
>  			bh = head;
> -- 
> 2.16.1

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 09/10] reiserfs: cont_expand() to eliminate AOP_FLAG_CONT_EXPAND
  2018-02-19 14:02 ` [PATCH 09/10] reiserfs: cont_expand() to eliminate AOP_FLAG_CONT_EXPAND Goldwyn Rodrigues
@ 2018-02-19 14:55   ` Matthew Wilcox
  0 siblings, 0 replies; 16+ messages in thread
From: Matthew Wilcox @ 2018-02-19 14:55 UTC (permalink / raw)
  To: Goldwyn Rodrigues; +Cc: linux-fsdevel, mhocko, Goldwyn Rodrigues

On Mon, Feb 19, 2018 at 08:02:29AM -0600, Goldwyn Rodrigues wrote:
> +++ b/include/linux/fs.h
> @@ -259,8 +259,6 @@ enum positive_aop_returns {
>  	AOP_TRUNCATED_PAGE	= 0x80001,
>  };
>  
> -#define AOP_FLAG_CONT_EXPAND		0x0001 /* called from cont_expand */
> -
>  /*
>   * oh the beauties of C type declarations.
>   */

This hunk needs to be part of patch 10, or you'll hit a bisection problem
(fs/buffer.c still uses it).

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 06/10] fs: iomap use memalloc_nofs_* scope API
  2018-02-19 14:02 ` [PATCH 06/10] fs: iomap use " Goldwyn Rodrigues
@ 2018-02-19 22:30   ` Dave Chinner
  2018-02-20  9:05     ` Michal Hocko
  0 siblings, 1 reply; 16+ messages in thread
From: Dave Chinner @ 2018-02-19 22:30 UTC (permalink / raw)
  To: Goldwyn Rodrigues; +Cc: linux-fsdevel, mhocko, Goldwyn Rodrigues

On Mon, Feb 19, 2018 at 08:02:26AM -0600, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> While we are at it, remove the flags parameter from iomap_write_begin()
> since we passed AOP_FLAG_NOFS to it.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> ---
>  fs/iomap.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/iomap.c b/fs/iomap.c
> index afd163586aa0..afaf6ffff34f 100644
> --- a/fs/iomap.c
> +++ b/fs/iomap.c
> @@ -27,6 +27,7 @@
>  #include <linux/task_io_accounting_ops.h>
>  #include <linux/dax.h>
>  #include <linux/sched/signal.h>
> +#include <linux/sched/mm.h>
>  
>  #include "internal.h"
>  
> @@ -109,19 +110,22 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
>  }
>  
>  static int
> -iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
> +iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
>  		struct page **pagep, struct iomap *iomap)
>  {
>  	pgoff_t index = pos >> PAGE_SHIFT;
>  	struct page *page;
>  	int status = 0;
> +	unsigned nofs_flags;
>  
>  	BUG_ON(pos + len > iomap->offset + iomap->length);
>  
>  	if (fatal_signal_pending(current))
>  		return -EINTR;
>  
> -	page = grab_cache_page_write_begin(inode->i_mapping, index, flags);
> +	nofs_flags = memalloc_nofs_save();
> +	page = grab_cache_page_write_begin(inode->i_mapping, index, 0);
> +	memalloc_nofs_restore(nofs_flags);

This is wrong. flags are provided by the caller, so the caller
decides on the memory allocation scope, not this function.

As it is, I can't say I like this whole patchset. This is not what
the scoped memory allocation API was intended for. i.e. it was
intended to mark large regions of memory allocation restrictions for
disjoint operations, not replace a neat, clean flag interface
with a mess of save/restore calls and new ways to screw up error
handling....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 06/10] fs: iomap use memalloc_nofs_* scope API
  2018-02-19 22:30   ` Dave Chinner
@ 2018-02-20  9:05     ` Michal Hocko
  2018-02-20 12:16       ` Goldwyn Rodrigues
  0 siblings, 1 reply; 16+ messages in thread
From: Michal Hocko @ 2018-02-20  9:05 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Goldwyn Rodrigues, linux-fsdevel, Goldwyn Rodrigues

On Tue 20-02-18 09:30:53, Dave Chinner wrote:
> On Mon, Feb 19, 2018 at 08:02:26AM -0600, Goldwyn Rodrigues wrote:
> > From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> > 
> > While we are at it, remove the flags parameter from iomap_write_begin()
> > since we passed AOP_FLAG_NOFS to it.
> > 
> > Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> > ---
> >  fs/iomap.c | 15 +++++++++------
> >  1 file changed, 9 insertions(+), 6 deletions(-)
> > 
> > diff --git a/fs/iomap.c b/fs/iomap.c
> > index afd163586aa0..afaf6ffff34f 100644
> > --- a/fs/iomap.c
> > +++ b/fs/iomap.c
> > @@ -27,6 +27,7 @@
> >  #include <linux/task_io_accounting_ops.h>
> >  #include <linux/dax.h>
> >  #include <linux/sched/signal.h>
> > +#include <linux/sched/mm.h>
> >  
> >  #include "internal.h"
> >  
> > @@ -109,19 +110,22 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
> >  }
> >  
> >  static int
> > -iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
> > +iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
> >  		struct page **pagep, struct iomap *iomap)
> >  {
> >  	pgoff_t index = pos >> PAGE_SHIFT;
> >  	struct page *page;
> >  	int status = 0;
> > +	unsigned nofs_flags;
> >  
> >  	BUG_ON(pos + len > iomap->offset + iomap->length);
> >  
> >  	if (fatal_signal_pending(current))
> >  		return -EINTR;
> >  
> > -	page = grab_cache_page_write_begin(inode->i_mapping, index, flags);
> > +	nofs_flags = memalloc_nofs_save();
> > +	page = grab_cache_page_write_begin(inode->i_mapping, index, 0);
> > +	memalloc_nofs_restore(nofs_flags);
> 
> This is wrong. flags are provided by the caller, so the caller
> decides on the memory allocation scope, not this function.
> 
> As it is, I can't say I like this whole patchset. This is not what
> the scoped memory allocation API was intended for. i.e. it was
> intended to mark large regions of memory allocation restrictions for
> disjoint operations, not replace a neat, clean flag interface
> with a mess of save/restore calls and new ways to screw up error
> handling....

100% agreed! My original plan was to identify reclaim recursion
sensitive contexts per fs and then remove explicit GFP_NOFS called
solely from those contexts. [1] should help to identify the later. The
harderst part is the first part of course. It requires the detailed
knowledge of the fs reclaim implementation of course.

[1] http://lkml.kernel.org/r/20170106141845.24362-1-mhocko@kernel.org
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 06/10] fs: iomap use memalloc_nofs_* scope API
  2018-02-20  9:05     ` Michal Hocko
@ 2018-02-20 12:16       ` Goldwyn Rodrigues
  0 siblings, 0 replies; 16+ messages in thread
From: Goldwyn Rodrigues @ 2018-02-20 12:16 UTC (permalink / raw)
  To: Michal Hocko, Dave Chinner; +Cc: linux-fsdevel, Goldwyn Rodrigues



On 02/20/2018 03:05 AM, Michal Hocko wrote:
> On Tue 20-02-18 09:30:53, Dave Chinner wrote:
>> On Mon, Feb 19, 2018 at 08:02:26AM -0600, Goldwyn Rodrigues wrote:
>>> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>>>
>>> While we are at it, remove the flags parameter from iomap_write_begin()
>>> since we passed AOP_FLAG_NOFS to it.
>>>
>>> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
>>> ---
>>>  fs/iomap.c | 15 +++++++++------
>>>  1 file changed, 9 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/fs/iomap.c b/fs/iomap.c
>>> index afd163586aa0..afaf6ffff34f 100644
>>> --- a/fs/iomap.c
>>> +++ b/fs/iomap.c
>>> @@ -27,6 +27,7 @@
>>>  #include <linux/task_io_accounting_ops.h>
>>>  #include <linux/dax.h>
>>>  #include <linux/sched/signal.h>
>>> +#include <linux/sched/mm.h>
>>>  
>>>  #include "internal.h"
>>>  
>>> @@ -109,19 +110,22 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
>>>  }
>>>  
>>>  static int
>>> -iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
>>> +iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
>>>  		struct page **pagep, struct iomap *iomap)
>>>  {
>>>  	pgoff_t index = pos >> PAGE_SHIFT;
>>>  	struct page *page;
>>>  	int status = 0;
>>> +	unsigned nofs_flags;
>>>  
>>>  	BUG_ON(pos + len > iomap->offset + iomap->length);
>>>  
>>>  	if (fatal_signal_pending(current))
>>>  		return -EINTR;
>>>  
>>> -	page = grab_cache_page_write_begin(inode->i_mapping, index, flags);
>>> +	nofs_flags = memalloc_nofs_save();
>>> +	page = grab_cache_page_write_begin(inode->i_mapping, index, 0);
>>> +	memalloc_nofs_restore(nofs_flags);
>>
>> This is wrong. flags are provided by the caller, so the caller
>> decides on the memory allocation scope, not this function.

All callers are calling with the same parameter. However, this is not
the place to eliminate this. I agree the scope is too narrow.

>>
>> As it is, I can't say I like this whole patchset. This is not what
>> the scoped memory allocation API was intended for. i.e. it was
>> intended to mark large regions of memory allocation restrictions for
>> disjoint operations, not replace a neat, clean flag interface
>> with a mess of save/restore calls and new ways to screw up error
>> handling....
> 
> 100% agreed! My original plan was to identify reclaim recursion
> sensitive contexts per fs and then remove explicit GFP_NOFS called
> solely from those contexts. [1] should help to identify the later. The
> harderst part is the first part of course. It requires the detailed
> knowledge of the fs reclaim implementation of course.

Thanks. I misunderstood the scope concept.

In a previous test, I tried converting GFP_NOFS to GFP_KERNEL in order
to hang/crash the kernel with heavy I/O in low memory but failed. I
tried it with three filesystems. Hopefully, these patches will extract
out the positions which need attention.

> 
> [1] http://lkml.kernel.org/r/20170106141845.24362-1-mhocko@kernel.org
> 

-- 
Goldwyn

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-02-20 12:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 14:02 [PATCH 00/10] Use the memalloc_nofs scope API Goldwyn Rodrigues
2018-02-19 14:02 ` [PATCH 01/10] fs: buffer - Use memalloc_nofs API to allocate pages Goldwyn Rodrigues
2018-02-19 14:24   ` Michal Hocko
2018-02-19 14:02 ` [PATCH 02/10] fs: mpage use memalloc_nofs_save/restore while allocating bios Goldwyn Rodrigues
2018-02-19 14:02 ` [PATCH 03/10] ext4: Use memalloc_nofs_* scope API Goldwyn Rodrigues
2018-02-19 14:02 ` [PATCH 04/10] f2fs: " Goldwyn Rodrigues
2018-02-19 14:02 ` [PATCH 05/10] gfs2: " Goldwyn Rodrigues
2018-02-19 14:02 ` [PATCH 06/10] fs: iomap use " Goldwyn Rodrigues
2018-02-19 22:30   ` Dave Chinner
2018-02-20  9:05     ` Michal Hocko
2018-02-20 12:16       ` Goldwyn Rodrigues
2018-02-19 14:02 ` [PATCH 07/10] fs: namei " Goldwyn Rodrigues
2018-02-19 14:02 ` [PATCH 08/10] fs: Eliminate AOP_FLAG_NOFS Goldwyn Rodrigues
2018-02-19 14:02 ` [PATCH 09/10] reiserfs: cont_expand() to eliminate AOP_FLAG_CONT_EXPAND Goldwyn Rodrigues
2018-02-19 14:55   ` Matthew Wilcox
2018-02-19 14:02 ` [PATCH 10/10] fs: Remove flags parameter from aops->write_begin() Goldwyn Rodrigues

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).