All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/24] Begin removing PageError
@ 2022-05-27 15:50 Matthew Wilcox (Oracle)
  2022-05-27 15:50 ` [PATCH 01/24] block: Remove check of PageError Matthew Wilcox (Oracle)
                   ` (24 more replies)
  0 siblings, 25 replies; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

The approach I'm taking is to remove the checks for PageError (and
folio_test_error).  Once nobody is checking the error flag, we can safely
remove all places that set/clear it.

After this series, there are some places which still use it.  Lots of
the converted places are trivial -- they should have been checking the
uptodate flag.  The trickiest are the ones which have multiple steps
and signal "hey, something went wrong with one step in the read of this
page/folio" by setting the error flag.

I'm thinking about (ab)using PageChecked == PG_owner_priv_1 for this
purpose.  It'd be nice to be able to use page->private for this, but
that's not always available.  I know some filesystems already ascribe
a meaning to PG_owner_priv_1, but those can be distinguished by whether
the uptodate flag is set.

Thoughts?  Most of these look like good cleanups that we want to have
anyway.

Matthew Wilcox (Oracle) (24):
  block: Remove check of PageError
  afs: Remove check of PageError
  freevxfs: Remove check of PageError
  gfs: Check PageUptodate instead of PageError
  hfs: Remove check for PageError
  hfsplus: Remove check for PageError
  ntfs: Remove check for PageError
  ext2: Remove check for PageError
  nilfs2: Remove check for PageError
  ntfs: Remove check for PageError
  ntfs3: Remove check for PageError
  reiserfs: Remove check for PageError
  ufs: Remove checks for PageError
  remap_range: Remove check of uptodate flag
  jfs: Remove check for PageUptodate
  iomap: Remove test for folio error
  orangefs: Remove test for folio error
  buffer: Remove check for PageError
  nfs: Leave pages in the pagecache if readpage failed
  btrfs: Use a folio in wait_dev_supers()
  buffer: Don't test folio error in block_read_full_folio()
  squashfs: Return the actual error from squashfs_read_folio()
  hostfs: Handle page write errors correctly
  ocfs2: Use filemap_write_and_wait_range() in
    ocfs2_cow_sync_writeback()

 block/partitions/core.c |  4 ----
 fs/afs/mntpt.c          |  6 ------
 fs/btrfs/disk-io.c      | 19 ++++++++-----------
 fs/buffer.c             | 13 ++++++++-----
 fs/ext2/dir.c           |  3 +--
 fs/freevxfs/vxfs_subr.c |  6 ------
 fs/gfs2/lops.c          |  2 +-
 fs/hfs/bnode.c          |  4 ----
 fs/hfsplus/bnode.c      |  4 ----
 fs/hostfs/hostfs_kern.c |  6 +++---
 fs/iomap/buffered-io.c  |  3 ---
 fs/jfs/jfs_metapage.c   |  2 +-
 fs/nfs/read.c           |  4 ----
 fs/nilfs2/dir.c         |  2 +-
 fs/ntfs/aops.h          |  7 +------
 fs/ntfs/file.c          |  5 -----
 fs/ntfs3/ntfs_fs.h      |  7 +------
 fs/ocfs2/refcounttree.c | 42 ++++++-----------------------------------
 fs/orangefs/inode.c     |  4 +---
 fs/reiserfs/xattr.c     |  9 +--------
 fs/remap_range.c        | 11 +----------
 fs/squashfs/file.c      | 15 ++++++++-------
 fs/ufs/dir.c            |  2 +-
 fs/ufs/util.c           | 11 -----------
 24 files changed, 43 insertions(+), 148 deletions(-)

-- 
2.34.1


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

* [PATCH 01/24] block: Remove check of PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:47   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 02/24] afs: " Matthew Wilcox (Oracle)
                   ` (23 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() sees a page with PageError set, it returns a
PTR_ERR().  Checking PageError again is simply dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 block/partitions/core.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/block/partitions/core.c b/block/partitions/core.c
index 8a0ec929023b..a9a51bac42df 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -716,14 +716,10 @@ void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p)
 			(pgoff_t)(n >> (PAGE_SHIFT - 9)), NULL);
 	if (IS_ERR(page))
 		goto out;
-	if (PageError(page))
-		goto out_put_page;
 
 	p->v = page;
 	return (unsigned char *)page_address(page) +
 			((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << SECTOR_SHIFT);
-out_put_page:
-	put_page(page);
 out:
 	p->v = NULL;
 	return NULL;
-- 
2.34.1


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

* [PATCH 02/24] afs: Remove check of PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
  2022-05-27 15:50 ` [PATCH 01/24] block: Remove check of PageError Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:47   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 03/24] freevxfs: " Matthew Wilcox (Oracle)
                   ` (22 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this is dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/afs/mntpt.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index bbb2c210d139..97f50e9fd9eb 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -132,12 +132,6 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)
 		if (IS_ERR(page))
 			return PTR_ERR(page);
 
-		if (PageError(page)) {
-			ret = afs_bad(AFS_FS_I(d_inode(mntpt)), afs_file_error_mntpt);
-			put_page(page);
-			return ret;
-		}
-
 		buf = kmap(page);
 		ret = -EINVAL;
 		if (buf[size - 1] == '.')
-- 
2.34.1


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

* [PATCH 03/24] freevxfs: Remove check of PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
  2022-05-27 15:50 ` [PATCH 01/24] block: Remove check of PageError Matthew Wilcox (Oracle)
  2022-05-27 15:50 ` [PATCH 02/24] afs: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:48   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 04/24] gfs: Check PageUptodate instead " Matthew Wilcox (Oracle)
                   ` (21 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this is dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/freevxfs/vxfs_subr.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/fs/freevxfs/vxfs_subr.c b/fs/freevxfs/vxfs_subr.c
index 6143ebab940d..041e818c4577 100644
--- a/fs/freevxfs/vxfs_subr.c
+++ b/fs/freevxfs/vxfs_subr.c
@@ -75,15 +75,9 @@ vxfs_get_page(struct address_space *mapping, u_long n)
 		kmap(pp);
 		/** if (!PageChecked(pp)) **/
 			/** vxfs_check_page(pp); **/
-		if (PageError(pp))
-			goto fail;
 	}
 	
 	return (pp);
-		 
-fail:
-	vxfs_put_page(pp);
-	return ERR_PTR(-EIO);
 }
 
 /**
-- 
2.34.1


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

* [PATCH 04/24] gfs: Check PageUptodate instead of PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (2 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 03/24] freevxfs: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:48   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 05/24] hfs: Remove check for PageError Matthew Wilcox (Oracle)
                   ` (20 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

This is the correct flag to test to know if the read completed
successfully.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/gfs2/lops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 6ba51cbb94cf..9a9a35d68bd5 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -474,7 +474,7 @@ static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index,
 	page = find_get_page(jd->jd_inode->i_mapping, index);
 	wait_on_page_locked(page);
 
-	if (PageError(page))
+	if (!PageUptodate(page))
 		*done = true;
 
 	if (!*done)
-- 
2.34.1


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

* [PATCH 05/24] hfs: Remove check for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (3 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 04/24] gfs: Check PageUptodate instead " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:48   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 06/24] hfsplus: " Matthew Wilcox (Oracle)
                   ` (19 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this is dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/hfs/bnode.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index c0a73a6ffb28..c83fd0e8404d 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -296,10 +296,6 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
 		page = read_mapping_page(mapping, block++, NULL);
 		if (IS_ERR(page))
 			goto fail;
-		if (PageError(page)) {
-			put_page(page);
-			goto fail;
-		}
 		node->page[i] = page;
 	}
 
-- 
2.34.1


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

* [PATCH 06/24] hfsplus: Remove check for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (4 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 05/24] hfs: Remove check for PageError Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:48   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 07/24] ntfs: " Matthew Wilcox (Oracle)
                   ` (18 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this is dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/hfsplus/bnode.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index 177fae4e6581..a5ab00e54220 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -447,10 +447,6 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
 		page = read_mapping_page(mapping, block, NULL);
 		if (IS_ERR(page))
 			goto fail;
-		if (PageError(page)) {
-			put_page(page);
-			goto fail;
-		}
 		node->page[i] = page;
 	}
 
-- 
2.34.1


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

* [PATCH 07/24] ntfs: Remove check for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (5 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 06/24] hfsplus: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:48   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 08/24] ext2: " Matthew Wilcox (Oracle)
                   ` (17 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this is dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs/file.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index e1392a9b8ceb..37224ebdcd10 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -219,11 +219,6 @@ static int ntfs_attr_extend_initialized(ntfs_inode *ni, const s64 new_init_size)
 			err = PTR_ERR(page);
 			goto init_err_out;
 		}
-		if (unlikely(PageError(page))) {
-			put_page(page);
-			err = -EIO;
-			goto init_err_out;
-		}
 		/*
 		 * Update the initialized size in the ntfs inode.  This is
 		 * enough to make ntfs_writepage() work.
-- 
2.34.1


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

* [PATCH 08/24] ext2: Remove check for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (6 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 07/24] ntfs: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:49   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 09/24] nilfs2: " Matthew Wilcox (Oracle)
                   ` (16 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this test is not needed.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ext2/dir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 2c2f179b6977..3410e4132405 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -204,8 +204,7 @@ static struct page * ext2_get_page(struct inode *dir, unsigned long n,
 	if (!IS_ERR(page)) {
 		*page_addr = kmap_local_page(page);
 		if (unlikely(!PageChecked(page))) {
-			if (PageError(page) || !ext2_check_page(page, quiet,
-								*page_addr))
+			if (!ext2_check_page(page, quiet, *page_addr))
 				goto fail;
 		}
 	}
-- 
2.34.1


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

* [PATCH 09/24] nilfs2: Remove check for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (7 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 08/24] ext2: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:49   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 10/24] ntfs: " Matthew Wilcox (Oracle)
                   ` (15 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this test is not needed.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/nilfs2/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index f8f4c2ff52f4..decd6471300b 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -194,7 +194,7 @@ static struct page *nilfs_get_page(struct inode *dir, unsigned long n)
 	if (!IS_ERR(page)) {
 		kmap(page);
 		if (unlikely(!PageChecked(page))) {
-			if (PageError(page) || !nilfs_check_page(page))
+			if (!nilfs_check_page(page))
 				goto fail;
 		}
 	}
-- 
2.34.1


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

* [PATCH 10/24] ntfs: Remove check for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (8 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 09/24] nilfs2: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:49   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 11/24] ntfs3: " Matthew Wilcox (Oracle)
                   ` (14 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this is dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs/aops.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/ntfs/aops.h b/fs/ntfs/aops.h
index 934d5f79b9e7..0cac5458c023 100644
--- a/fs/ntfs/aops.h
+++ b/fs/ntfs/aops.h
@@ -74,13 +74,8 @@ static inline struct page *ntfs_map_page(struct address_space *mapping,
 {
 	struct page *page = read_mapping_page(mapping, index, NULL);
 
-	if (!IS_ERR(page)) {
+	if (!IS_ERR(page))
 		kmap(page);
-		if (!PageError(page))
-			return page;
-		ntfs_unmap_page(page);
-		return ERR_PTR(-EIO);
-	}
 	return page;
 }
 
-- 
2.34.1


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

* [PATCH 11/24] ntfs3: Remove check for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (9 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 10/24] ntfs: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:51   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 12/24] reiserfs: " Matthew Wilcox (Oracle)
                   ` (13 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this is dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/ntfs_fs.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 8de129a6419b..f28726c4e845 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -896,13 +896,8 @@ static inline struct page *ntfs_map_page(struct address_space *mapping,
 {
 	struct page *page = read_mapping_page(mapping, index, NULL);
 
-	if (!IS_ERR(page)) {
+	if (!IS_ERR(page))
 		kmap(page);
-		if (!PageError(page))
-			return page;
-		ntfs_unmap_page(page);
-		return ERR_PTR(-EIO);
-	}
 	return page;
 }
 
-- 
2.34.1


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

* [PATCH 12/24] reiserfs: Remove check for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (10 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 11/24] ntfs3: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:52   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 13/24] ufs: Remove checks " Matthew Wilcox (Oracle)
                   ` (12 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not a
page with PageError set, so this is dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/reiserfs/xattr.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index bd073836e141..436641369283 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -440,16 +440,9 @@ static struct page *reiserfs_get_page(struct inode *dir, size_t n)
 	 */
 	mapping_set_gfp_mask(mapping, GFP_NOFS);
 	page = read_mapping_page(mapping, n >> PAGE_SHIFT, NULL);
-	if (!IS_ERR(page)) {
+	if (!IS_ERR(page))
 		kmap(page);
-		if (PageError(page))
-			goto fail;
-	}
 	return page;
-
-fail:
-	reiserfs_put_page(page);
-	return ERR_PTR(-EIO);
 }
 
 static inline __u32 xattr_hash(const char *msg, int len)
-- 
2.34.1


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

* [PATCH 13/24] ufs: Remove checks for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (11 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 12/24] reiserfs: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:56   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 14/24] remap_range: Remove check of uptodate flag Matthew Wilcox (Oracle)
                   ` (11 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If read_mapping_page() encounters an error, it returns an errno, not
a page with PageError set, or a page that is not Uptodate, so this is
dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ufs/dir.c  |  2 +-
 fs/ufs/util.c | 11 -----------
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index b721d0bda5e5..391efaf1d528 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -193,7 +193,7 @@ static struct page *ufs_get_page(struct inode *dir, unsigned long n)
 	if (!IS_ERR(page)) {
 		kmap(page);
 		if (unlikely(!PageChecked(page))) {
-			if (PageError(page) || !ufs_check_page(page))
+			if (!ufs_check_page(page))
 				goto fail;
 		}
 	}
diff --git a/fs/ufs/util.c b/fs/ufs/util.c
index 4fa633f84274..08ddf41eaaad 100644
--- a/fs/ufs/util.c
+++ b/fs/ufs/util.c
@@ -264,17 +264,6 @@ struct page *ufs_get_locked_page(struct address_space *mapping,
 			put_page(page);
 			return NULL;
 		}
-
-		if (!PageUptodate(page) || PageError(page)) {
-			unlock_page(page);
-			put_page(page);
-
-			printk(KERN_ERR "ufs_change_blocknr: "
-			       "can not read page: ino %lu, index: %lu\n",
-			       inode->i_ino, index);
-
-			return ERR_PTR(-EIO);
-		}
 	}
 	if (!page_has_buffers(page))
 		create_empty_buffers(page, 1 << inode->i_blkbits, 0);
-- 
2.34.1


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

* [PATCH 14/24] remap_range: Remove check of uptodate flag
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (12 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 13/24] ufs: Remove checks " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:59   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 15/24] jfs: Remove check for PageUptodate Matthew Wilcox (Oracle)
                   ` (10 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

read_mapping_folio() returns an ERR_PTR if the folio is not
uptodate, so this check is simply dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/remap_range.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/fs/remap_range.c b/fs/remap_range.c
index e112b5424cdb..f1a3795812ce 100644
--- a/fs/remap_range.c
+++ b/fs/remap_range.c
@@ -148,16 +148,7 @@ static int generic_remap_check_len(struct inode *inode_in,
 /* Read a page's worth of file data into the page cache. */
 static struct folio *vfs_dedupe_get_folio(struct file *file, loff_t pos)
 {
-	struct folio *folio;
-
-	folio = read_mapping_folio(file->f_mapping, pos >> PAGE_SHIFT, file);
-	if (IS_ERR(folio))
-		return folio;
-	if (!folio_test_uptodate(folio)) {
-		folio_put(folio);
-		return ERR_PTR(-EIO);
-	}
-	return folio;
+	return read_mapping_folio(file->f_mapping, pos >> PAGE_SHIFT, file);
 }
 
 /*
-- 
2.34.1


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

* [PATCH 15/24] jfs: Remove check for PageUptodate
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (13 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 14/24] remap_range: Remove check of uptodate flag Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  5:59   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 16/24] iomap: Remove test for folio error Matthew Wilcox (Oracle)
                   ` (9 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

Pages returned from read_mapping_page() are always uptodate, so
this check is unnecessary.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/jfs/jfs_metapage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 387652ae14c2..2e8461ce74de 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -618,7 +618,7 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
 		SetPageUptodate(page);
 	} else {
 		page = read_mapping_page(mapping, page_index, NULL);
-		if (IS_ERR(page) || !PageUptodate(page)) {
+		if (IS_ERR(page)) {
 			jfs_err("read_mapping_page failed!");
 			return NULL;
 		}
-- 
2.34.1


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

* [PATCH 16/24] iomap: Remove test for folio error
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (14 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 15/24] jfs: Remove check for PageUptodate Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  6:00   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 17/24] orangefs: " Matthew Wilcox (Oracle)
                   ` (8 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

Just because there has been a read error doesn't mean we should avoid
marking this part of the folio as uptodate.  Indeed, it may overwrite
the error part of the folio and let us mark the entire folio uptodate.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/iomap/buffered-io.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index d2a9f699e17e..66278a14bfa7 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -154,9 +154,6 @@ static void iomap_iop_set_range_uptodate(struct folio *folio,
 static void iomap_set_range_uptodate(struct folio *folio,
 		struct iomap_page *iop, size_t off, size_t len)
 {
-	if (folio_test_error(folio))
-		return;
-
 	if (iop)
 		iomap_iop_set_range_uptodate(folio, iop, off, len);
 	else
-- 
2.34.1


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

* [PATCH 17/24] orangefs: Remove test for folio error
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (15 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 16/24] iomap: Remove test for folio error Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  6:00   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 18/24] buffer: Remove check for PageError Matthew Wilcox (Oracle)
                   ` (7 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

The page cache clears the error bit before calling ->read_folio(),
so this condition could never have been true.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/orangefs/inode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 5ce27dde3c79..7a8c0c6e698d 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -307,7 +307,7 @@ static int orangefs_read_folio(struct file *file, struct folio *folio)
 
 	ret = wait_for_direct_io(ORANGEFS_IO_READ, inode, &off, &iter,
 			folio_size(folio), inode->i_size, NULL, NULL, file);
-	/* this will only zero remaining unread portions of the page data */
+	/* this will only zero remaining unread portions of the folio data */
 	iov_iter_zero(~0U, &iter);
 	/* takes care of potential aliasing */
 	flush_dcache_folio(folio);
@@ -315,8 +315,6 @@ static int orangefs_read_folio(struct file *file, struct folio *folio)
 		folio_set_error(folio);
 	} else {
 		folio_mark_uptodate(folio);
-		if (folio_test_error(folio))
-			folio_clear_error(folio);
 		ret = 0;
 	}
 	/* unlock the folio after the ->read_folio() routine completes */
-- 
2.34.1


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

* [PATCH 18/24] buffer: Remove check for PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (16 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 17/24] orangefs: " Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  6:01   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 19/24] nfs: Leave pages in the pagecache if readpage failed Matthew Wilcox (Oracle)
                   ` (6 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If a buffer is completed with an error, its uptodate flag will be clear,
so the page_uptodate variable will have been set to 0.  There's no
need to check PageError here.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/buffer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index 898c7f301b1b..c37a9c3bfb2f 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -282,10 +282,10 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
 	spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
 
 	/*
-	 * If none of the buffers had errors and they are all
-	 * uptodate then we can set the page uptodate.
+	 * If all of the buffers are uptodate then we can set the page
+	 * uptodate.
 	 */
-	if (page_uptodate && !PageError(page))
+	if (page_uptodate)
 		SetPageUptodate(page);
 	unlock_page(page);
 	return;
-- 
2.34.1


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

* [PATCH 19/24] nfs: Leave pages in the pagecache if readpage failed
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (17 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 18/24] buffer: Remove check for PageError Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  6:02   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 20/24] btrfs: Use a folio in wait_dev_supers() Matthew Wilcox (Oracle)
                   ` (5 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

The pagecache handles readpage failing by itself; it doesn't want
filesystems to remove pages from under it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/nfs/read.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 5a9b043662e9..8ae2c8d1219d 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -120,12 +120,8 @@ static void nfs_readpage_release(struct nfs_page *req, int error)
 	if (nfs_error_is_fatal_on_server(error) && error != -ETIMEDOUT)
 		SetPageError(page);
 	if (nfs_page_group_sync_on_bit(req, PG_UNLOCKPAGE)) {
-		struct address_space *mapping = page_file_mapping(page);
-
 		if (PageUptodate(page))
 			nfs_fscache_write_page(inode, page);
-		else if (!PageError(page) && !PagePrivate(page))
-			generic_error_remove_page(mapping, page);
 		unlock_page(page);
 	}
 	nfs_release_request(req);
-- 
2.34.1


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

* [PATCH 20/24] btrfs: Use a folio in wait_dev_supers()
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (18 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 19/24] nfs: Leave pages in the pagecache if readpage failed Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  6:03   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 21/24] buffer: Don't test folio error in block_read_full_folio() Matthew Wilcox (Oracle)
                   ` (4 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

Remove a use of PageError and optimise putting the page reference twice.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/btrfs/disk-io.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 89e94ea2fef5..12b11e645c14 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4178,7 +4178,7 @@ static int wait_dev_supers(struct btrfs_device *device, int max_mirrors)
 		max_mirrors = BTRFS_SUPER_MIRROR_MAX;
 
 	for (i = 0; i < max_mirrors; i++) {
-		struct page *page;
+		struct folio *folio;
 
 		ret = btrfs_sb_log_location(device, i, READ, &bytenr);
 		if (ret == -ENOENT) {
@@ -4193,27 +4193,24 @@ static int wait_dev_supers(struct btrfs_device *device, int max_mirrors)
 		    device->commit_total_bytes)
 			break;
 
-		page = find_get_page(device->bdev->bd_inode->i_mapping,
+		folio = filemap_get_folio(device->bdev->bd_inode->i_mapping,
 				     bytenr >> PAGE_SHIFT);
-		if (!page) {
+		if (!folio) {
 			errors++;
 			if (i == 0)
 				primary_failed = true;
 			continue;
 		}
-		/* Page is submitted locked and unlocked once the IO completes */
-		wait_on_page_locked(page);
-		if (PageError(page)) {
+		/* Folio is unlocked once the IO completes */
+		folio_wait_locked(folio);
+		if (!folio_test_uptodate(folio)) {
 			errors++;
 			if (i == 0)
 				primary_failed = true;
 		}
 
-		/* Drop our reference */
-		put_page(page);
-
-		/* Drop the reference from the writing run */
-		put_page(page);
+		/* Drop our reference and the one from the writing run */
+		folio_put_refs(folio, 2);
 	}
 
 	/* log error, force error return */
-- 
2.34.1


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

* [PATCH 21/24] buffer: Don't test folio error in block_read_full_folio()
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (19 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 20/24] btrfs: Use a folio in wait_dev_supers() Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  6:05   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 22/24] squashfs: Return the actual error from squashfs_read_folio() Matthew Wilcox (Oracle)
                   ` (3 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

We can cache this information in a local variable instead of communicating
from one part of the function to another via folio flags.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/buffer.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index c37a9c3bfb2f..5a4609b8b2b4 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2259,6 +2259,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
 	unsigned int blocksize, bbits;
 	int nr, i;
 	int fully_mapped = 1;
+	bool page_error = false;
 
 	VM_BUG_ON_FOLIO(folio_test_large(folio), folio);
 
@@ -2283,8 +2284,10 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
 			if (iblock < lblock) {
 				WARN_ON(bh->b_size != blocksize);
 				err = get_block(inode, iblock, bh, 0);
-				if (err)
+				if (err) {
 					folio_set_error(folio);
+					page_error = true;
+				}
 			}
 			if (!buffer_mapped(bh)) {
 				folio_zero_range(folio, i * blocksize,
@@ -2311,7 +2314,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
 		 * All buffers are uptodate - we can set the folio uptodate
 		 * as well. But not if get_block() returned an error.
 		 */
-		if (!folio_test_error(folio))
+		if (!page_error)
 			folio_mark_uptodate(folio);
 		folio_unlock(folio);
 		return 0;
-- 
2.34.1


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

* [PATCH 22/24] squashfs: Return the actual error from squashfs_read_folio()
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (20 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 21/24] buffer: Don't test folio error in block_read_full_folio() Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  6:06   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 23/24] hostfs: Handle page write errors correctly Matthew Wilcox (Oracle)
                   ` (2 subsequent siblings)
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

Since we actually know what error happened, we can report it instead
of having the generic code return -EIO for pages that were unlocked
without being marked uptodate.  Also remove a test of PageError since
we have the return value at this point.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/squashfs/file.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index a8e495d8eb86..7f0904b20329 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -454,7 +454,7 @@ static int squashfs_read_folio(struct file *file, struct folio *folio)
 	int expected = index == file_end ?
 			(i_size_read(inode) & (msblk->block_size - 1)) :
 			 msblk->block_size;
-	int res;
+	int res = 0;
 	void *pageaddr;
 
 	TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n",
@@ -467,14 +467,15 @@ static int squashfs_read_folio(struct file *file, struct folio *folio)
 	if (index < file_end || squashfs_i(inode)->fragment_block ==
 					SQUASHFS_INVALID_BLK) {
 		u64 block = 0;
-		int bsize = read_blocklist(inode, index, &block);
-		if (bsize < 0)
+
+		res = read_blocklist(inode, index, &block);
+		if (res < 0)
 			goto error_out;
 
-		if (bsize == 0)
+		if (res == 0)
 			res = squashfs_readpage_sparse(page, expected);
 		else
-			res = squashfs_readpage_block(page, block, bsize, expected);
+			res = squashfs_readpage_block(page, block, res, expected);
 	} else
 		res = squashfs_readpage_fragment(page, expected);
 
@@ -488,11 +489,11 @@ static int squashfs_read_folio(struct file *file, struct folio *folio)
 	memset(pageaddr, 0, PAGE_SIZE);
 	kunmap_atomic(pageaddr);
 	flush_dcache_page(page);
-	if (!PageError(page))
+	if (res == 0)
 		SetPageUptodate(page);
 	unlock_page(page);
 
-	return 0;
+	return res;
 }
 
 
-- 
2.34.1


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

* [PATCH 23/24] hostfs: Handle page write errors correctly
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (21 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 22/24] squashfs: Return the actual error from squashfs_read_folio() Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  6:06   ` Christoph Hellwig
  2022-05-27 15:50 ` [PATCH 24/24] ocfs2: Use filemap_write_and_wait_range() in ocfs2_cow_sync_writeback() Matthew Wilcox (Oracle)
  2022-05-28  6:12 ` [PATCH 00/24] Begin removing PageError Christoph Hellwig
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

If a page can't be written back, we need to call mapping_set_error(),
not clear the page's Uptodate flag.  Also remove the clearing of PageError
on success; that flag is used for read errors, not write errors.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/hostfs/hostfs_kern.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index cc1bc6f93a01..07881b76d42f 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -416,15 +416,15 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
 
 	err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count);
 	if (err != count) {
-		ClearPageUptodate(page);
+		if (err >= 0)
+			err = -EIO;
+		mapping_set_error(mapping, err);
 		goto out;
 	}
 
 	if (base > inode->i_size)
 		inode->i_size = base;
 
-	if (PageError(page))
-		ClearPageError(page);
 	err = 0;
 
  out:
-- 
2.34.1


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

* [PATCH 24/24] ocfs2: Use filemap_write_and_wait_range() in ocfs2_cow_sync_writeback()
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (22 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 23/24] hostfs: Handle page write errors correctly Matthew Wilcox (Oracle)
@ 2022-05-27 15:50 ` Matthew Wilcox (Oracle)
  2022-05-28  6:07   ` Christoph Hellwig
  2022-05-28  6:12 ` [PATCH 00/24] Begin removing PageError Christoph Hellwig
  24 siblings, 1 reply; 51+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-05-27 15:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), linux-mm

Remove the open-coding of filemap_fdatawait_range().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ocfs2/refcounttree.c | 42 ++++++-----------------------------------
 1 file changed, 6 insertions(+), 36 deletions(-)

diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index e04358a46b68..1358981e80a3 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -3146,48 +3146,18 @@ int ocfs2_cow_sync_writeback(struct super_block *sb,
 			     struct inode *inode,
 			     u32 cpos, u32 num_clusters)
 {
-	int ret = 0;
-	loff_t offset, end, map_end;
-	pgoff_t page_index;
-	struct page *page;
+	int ret;
+	loff_t start, end;
 
 	if (ocfs2_should_order_data(inode))
 		return 0;
 
-	offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits;
-	end = offset + (num_clusters << OCFS2_SB(sb)->s_clustersize_bits);
+	start = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits;
+	end = start + (num_clusters << OCFS2_SB(sb)->s_clustersize_bits) - 1;
 
-	ret = filemap_fdatawrite_range(inode->i_mapping,
-				       offset, end - 1);
-	if (ret < 0) {
+	ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
+	if (ret < 0)
 		mlog_errno(ret);
-		return ret;
-	}
-
-	while (offset < end) {
-		page_index = offset >> PAGE_SHIFT;
-		map_end = ((loff_t)page_index + 1) << PAGE_SHIFT;
-		if (map_end > end)
-			map_end = end;
-
-		page = find_or_create_page(inode->i_mapping,
-					   page_index, GFP_NOFS);
-		BUG_ON(!page);
-
-		wait_on_page_writeback(page);
-		if (PageError(page)) {
-			ret = -EIO;
-			mlog_errno(ret);
-		} else
-			mark_page_accessed(page);
-
-		unlock_page(page);
-		put_page(page);
-		page = NULL;
-		offset = map_end;
-		if (ret)
-			break;
-	}
 
 	return ret;
 }
-- 
2.34.1


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

* Re: [PATCH 01/24] block: Remove check of PageError
  2022-05-27 15:50 ` [PATCH 01/24] block: Remove check of PageError Matthew Wilcox (Oracle)
@ 2022-05-28  5:47   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:47 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:13PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() sees a page with PageError set, it returns a
> PTR_ERR().  Checking PageError again is simply dead code.

Looks good:

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

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

* Re: [PATCH 02/24] afs: Remove check of PageError
  2022-05-27 15:50 ` [PATCH 02/24] afs: " Matthew Wilcox (Oracle)
@ 2022-05-28  5:47   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:47 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:14PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() encounters an error, it returns an errno, not a
> page with PageError set, so this is dead code.

Looks good:

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

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

* Re: [PATCH 03/24] freevxfs: Remove check of PageError
  2022-05-27 15:50 ` [PATCH 03/24] freevxfs: " Matthew Wilcox (Oracle)
@ 2022-05-28  5:48   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:48 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

>  		/** if (!PageChecked(pp)) **/
>  			/** vxfs_check_page(pp); **/
> -		if (PageError(pp))
> -			goto fail;

Can you remove this comment out code as well while you're at it?

Otherwise looks good:

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

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

* Re: [PATCH 04/24] gfs: Check PageUptodate instead of PageError
  2022-05-27 15:50 ` [PATCH 04/24] gfs: Check PageUptodate instead " Matthew Wilcox (Oracle)
@ 2022-05-28  5:48   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:48 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:16PM +0100, Matthew Wilcox (Oracle) wrote:
> This is the correct flag to test to know if the read completed
> successfully.

Looks good:

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

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

* Re: [PATCH 05/24] hfs: Remove check for PageError
  2022-05-27 15:50 ` [PATCH 05/24] hfs: Remove check for PageError Matthew Wilcox (Oracle)
@ 2022-05-28  5:48   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:48 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:17PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() encounters an error, it returns an errno, not a
> page with PageError set, so this is dead code.

Looks good:

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

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

* Re: [PATCH 06/24] hfsplus: Remove check for PageError
  2022-05-27 15:50 ` [PATCH 06/24] hfsplus: " Matthew Wilcox (Oracle)
@ 2022-05-28  5:48   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:48 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:18PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() encounters an error, it returns an errno, not a
> page with PageError set, so this is dead code.

Looks good:

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

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

* Re: [PATCH 07/24] ntfs: Remove check for PageError
  2022-05-27 15:50 ` [PATCH 07/24] ntfs: " Matthew Wilcox (Oracle)
@ 2022-05-28  5:48   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:48 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:19PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() encounters an error, it returns an errno, not a
> page with PageError set, so this is dead code.

Looks good:

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

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

* Re: [PATCH 08/24] ext2: Remove check for PageError
  2022-05-27 15:50 ` [PATCH 08/24] ext2: " Matthew Wilcox (Oracle)
@ 2022-05-28  5:49   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:49 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:20PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() encounters an error, it returns an errno, not a
> page with PageError set, so this test is not needed.

Looks good:

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

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

* Re: [PATCH 09/24] nilfs2: Remove check for PageError
  2022-05-27 15:50 ` [PATCH 09/24] nilfs2: " Matthew Wilcox (Oracle)
@ 2022-05-28  5:49   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:49 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:21PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() encounters an error, it returns an errno, not a
> page with PageError set, so this test is not needed.

Looks good:

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

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

* Re: [PATCH 10/24] ntfs: Remove check for PageError
  2022-05-27 15:50 ` [PATCH 10/24] ntfs: " Matthew Wilcox (Oracle)
@ 2022-05-28  5:49   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:49 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:22PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() encounters an error, it returns an errno, not a
> page with PageError set, so this is dead code.

Looks good:

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

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

* Re: [PATCH 11/24] ntfs3: Remove check for PageError
  2022-05-27 15:50 ` [PATCH 11/24] ntfs3: " Matthew Wilcox (Oracle)
@ 2022-05-28  5:51   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:51 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:23PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() encounters an error, it returns an errno, not a
> page with PageError set, so this is dead code.

Looks good:

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

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

* Re: [PATCH 12/24] reiserfs: Remove check for PageError
  2022-05-27 15:50 ` [PATCH 12/24] reiserfs: " Matthew Wilcox (Oracle)
@ 2022-05-28  5:52   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:52 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:24PM +0100, Matthew Wilcox (Oracle) wrote:
> If read_mapping_page() encounters an error, it returns an errno, not a
> page with PageError set, so this is dead code.

Looks good:

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

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

* Re: [PATCH 13/24] ufs: Remove checks for PageError
  2022-05-27 15:50 ` [PATCH 13/24] ufs: Remove checks " Matthew Wilcox (Oracle)
@ 2022-05-28  5:56   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:56 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

> --- a/fs/ufs/dir.c
> +++ b/fs/ufs/dir.c
> @@ -193,7 +193,7 @@ static struct page *ufs_get_page(struct inode *dir, unsigned long n)
>  	if (!IS_ERR(page)) {
>  		kmap(page);
>  		if (unlikely(!PageChecked(page))) {
> -			if (PageError(page) || !ufs_check_page(page))
> +			if (!ufs_check_page(page))
>  				goto fail;
>  		}

Unrelated note:  doing the PageChecked check inside of ufs_check_page
wuld really help readability for the casual reader.

>  	}
> diff --git a/fs/ufs/util.c b/fs/ufs/util.c
> index 4fa633f84274..08ddf41eaaad 100644
> --- a/fs/ufs/util.c
> +++ b/fs/ufs/util.c
> @@ -264,17 +264,6 @@ struct page *ufs_get_locked_page(struct address_space *mapping,
>  			put_page(page);
>  			return NULL;
>  		}
> -
> -		if (!PageUptodate(page) || PageError(page)) {
> -			unlock_page(page);
> -			put_page(page);
> -
> -			printk(KERN_ERR "ufs_change_blocknr: "
> -			       "can not read page: ino %lu, index: %lu\n",
> -			       inode->i_ino, index);
> -
> -			return ERR_PTR(-EIO);
> -		}

This looks good.  But this code could use some more love nd a removal
of the find_lock_page call by always just using read_mapping_page.
Especially a the truncate protection should apply equally to cached
pages and not just those freshly read off the disk.

But I guess for now this looks good:

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

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

* Re: [PATCH 14/24] remap_range: Remove check of uptodate flag
  2022-05-27 15:50 ` [PATCH 14/24] remap_range: Remove check of uptodate flag Matthew Wilcox (Oracle)
@ 2022-05-28  5:59   ` Christoph Hellwig
  2022-05-30 12:35     ` Matthew Wilcox
  0 siblings, 1 reply; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:59 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:26PM +0100, Matthew Wilcox (Oracle) wrote:
> read_mapping_folio() returns an ERR_PTR if the folio is not
> uptodate, so this check is simply dead code.

Looks good:

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

>  /* Read a page's worth of file data into the page cache. */
>  static struct folio *vfs_dedupe_get_folio(struct file *file, loff_t pos)
>  {
> +	return read_mapping_folio(file->f_mapping, pos >> PAGE_SHIFT, file);
>  }

But I wonder if this isn't useful enough to go to filemap.c in one form
or another.

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

* Re: [PATCH 15/24] jfs: Remove check for PageUptodate
  2022-05-27 15:50 ` [PATCH 15/24] jfs: Remove check for PageUptodate Matthew Wilcox (Oracle)
@ 2022-05-28  5:59   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  5:59 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:27PM +0100, Matthew Wilcox (Oracle) wrote:
> Pages returned from read_mapping_page() are always uptodate, so
> this check is unnecessary.

Looks good:

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

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

* Re: [PATCH 16/24] iomap: Remove test for folio error
  2022-05-27 15:50 ` [PATCH 16/24] iomap: Remove test for folio error Matthew Wilcox (Oracle)
@ 2022-05-28  6:00   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:00 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:28PM +0100, Matthew Wilcox (Oracle) wrote:
> Just because there has been a read error doesn't mean we should avoid
> marking this part of the folio as uptodate.  Indeed, it may overwrite
> the error part of the folio and let us mark the entire folio uptodate.

This does look sensible, but I'm a little worried about this area.

Did this survive an xfstests run with a sub-pagesize blocksize file
system?

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

* Re: [PATCH 17/24] orangefs: Remove test for folio error
  2022-05-27 15:50 ` [PATCH 17/24] orangefs: " Matthew Wilcox (Oracle)
@ 2022-05-28  6:00   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:00 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:29PM +0100, Matthew Wilcox (Oracle) wrote:
> The page cache clears the error bit before calling ->read_folio(),
> so this condition could never have been true.

Looks good:

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

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

* Re: [PATCH 18/24] buffer: Remove check for PageError
  2022-05-27 15:50 ` [PATCH 18/24] buffer: Remove check for PageError Matthew Wilcox (Oracle)
@ 2022-05-28  6:01   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:01 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:30PM +0100, Matthew Wilcox (Oracle) wrote:
> If a buffer is completed with an error, its uptodate flag will be clear,
> so the page_uptodate variable will have been set to 0.  There's no
> need to check PageError here.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Looks good:

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

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

* Re: [PATCH 19/24] nfs: Leave pages in the pagecache if readpage failed
  2022-05-27 15:50 ` [PATCH 19/24] nfs: Leave pages in the pagecache if readpage failed Matthew Wilcox (Oracle)
@ 2022-05-28  6:02   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:02 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:31PM +0100, Matthew Wilcox (Oracle) wrote:
> The pagecache handles readpage failing by itself; it doesn't want
> filesystems to remove pages from under it.

This looks sesible to me, but please Cc thisto the NFS list or
maintainers, it might be worth to dig out the history and possibly
test cases for it.

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

* Re: [PATCH 20/24] btrfs: Use a folio in wait_dev_supers()
  2022-05-27 15:50 ` [PATCH 20/24] btrfs: Use a folio in wait_dev_supers() Matthew Wilcox (Oracle)
@ 2022-05-28  6:03   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:03 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:32PM +0100, Matthew Wilcox (Oracle) wrote:
> Remove a use of PageError and optimise putting the page reference twice.

Looks good (although the entire code around it could use some love..)

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

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

* Re: [PATCH 21/24] buffer: Don't test folio error in block_read_full_folio()
  2022-05-27 15:50 ` [PATCH 21/24] buffer: Don't test folio error in block_read_full_folio() Matthew Wilcox (Oracle)
@ 2022-05-28  6:05   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:05 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:33PM +0100, Matthew Wilcox (Oracle) wrote:
> We can cache this information in a local variable instead of communicating
> from one part of the function to another via folio flags.

Looks sensibel, but I'd invert the polarity and name this
buffers_uptodate to match the API call based on it.

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

* Re: [PATCH 22/24] squashfs: Return the actual error from squashfs_read_folio()
  2022-05-27 15:50 ` [PATCH 22/24] squashfs: Return the actual error from squashfs_read_folio() Matthew Wilcox (Oracle)
@ 2022-05-28  6:06   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:06 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:34PM +0100, Matthew Wilcox (Oracle) wrote:
> Since we actually know what error happened, we can report it instead
> of having the generic code return -EIO for pages that were unlocked
> without being marked uptodate.  Also remove a test of PageError since
> we have the return value at this point.

Looks good:

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

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

* Re: [PATCH 23/24] hostfs: Handle page write errors correctly
  2022-05-27 15:50 ` [PATCH 23/24] hostfs: Handle page write errors correctly Matthew Wilcox (Oracle)
@ 2022-05-28  6:06   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:06 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:35PM +0100, Matthew Wilcox (Oracle) wrote:
> If a page can't be written back, we need to call mapping_set_error(),
> not clear the page's Uptodate flag.  Also remove the clearing of PageError
> on success; that flag is used for read errors, not write errors.

Looks good:

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

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

* Re: [PATCH 24/24] ocfs2: Use filemap_write_and_wait_range() in ocfs2_cow_sync_writeback()
  2022-05-27 15:50 ` [PATCH 24/24] ocfs2: Use filemap_write_and_wait_range() in ocfs2_cow_sync_writeback() Matthew Wilcox (Oracle)
@ 2022-05-28  6:07   ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:07 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

Looks good:

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

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

* Re: [PATCH 00/24] Begin removing PageError
  2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
                   ` (23 preceding siblings ...)
  2022-05-27 15:50 ` [PATCH 24/24] ocfs2: Use filemap_write_and_wait_range() in ocfs2_cow_sync_writeback() Matthew Wilcox (Oracle)
@ 2022-05-28  6:12 ` Christoph Hellwig
  24 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-28  6:12 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 04:50:12PM +0100, Matthew Wilcox (Oracle) wrote:
> After this series, there are some places which still use it.  Lots of
> the converted places are trivial -- they should have been checking the
> uptodate flag.  The trickiest are the ones which have multiple steps
> and signal "hey, something went wrong with one step in the read of this
> page/folio" by setting the error flag.

How many of those do we have left, and how many of those can't be
changed to just return them through errors or other on-stack means?

> I'm thinking about (ab)using PageChecked == PG_owner_priv_1 for this
> purpose.  It'd be nice to be able to use page->private for this, but
> that's not always available.  I know some filesystems already ascribe
> a meaning to PG_owner_priv_1, but those can be distinguished by whether
> the uptodate flag is set.

I suspect what to do will be very ad-hoc depending on the actual user.
The first priority is probably to isolate PageError so that it is only
used for that kind of communication insid a single file system so that
all the generic uses can go away.

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

* Re: [PATCH 14/24] remap_range: Remove check of uptodate flag
  2022-05-28  5:59   ` Christoph Hellwig
@ 2022-05-30 12:35     ` Matthew Wilcox
  0 siblings, 0 replies; 51+ messages in thread
From: Matthew Wilcox @ 2022-05-30 12:35 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-fsdevel, linux-mm

On Fri, May 27, 2022 at 10:59:03PM -0700, Christoph Hellwig wrote:
> On Fri, May 27, 2022 at 04:50:26PM +0100, Matthew Wilcox (Oracle) wrote:
> > read_mapping_folio() returns an ERR_PTR if the folio is not
> > uptodate, so this check is simply dead code.
> 
> Looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> >  /* Read a page's worth of file data into the page cache. */
> >  static struct folio *vfs_dedupe_get_folio(struct file *file, loff_t pos)
> >  {
> > +	return read_mapping_folio(file->f_mapping, pos >> PAGE_SHIFT, file);
> >  }
> 
> But I wonder if this isn't useful enough to go to filemap.c in one form
> or another.

It looks like it should be, but most in-kernel users of
read_mapping_folio() and its friends want to pass NULL for file as they
don't have an open file.

Indeed, this code used to until I realised we actually do have open
files here, so should pass them.  I don't think it affects anything;
the only users who need the struct file are network filesystems, and
nobody does dedupe across the network.  If it's not done transparently
by the server, it's an obvious server offload operation.

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

end of thread, other threads:[~2022-05-30 12:36 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
2022-05-27 15:50 ` [PATCH 01/24] block: Remove check of PageError Matthew Wilcox (Oracle)
2022-05-28  5:47   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 02/24] afs: " Matthew Wilcox (Oracle)
2022-05-28  5:47   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 03/24] freevxfs: " Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 04/24] gfs: Check PageUptodate instead " Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 05/24] hfs: Remove check for PageError Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 06/24] hfsplus: " Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 07/24] ntfs: " Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 08/24] ext2: " Matthew Wilcox (Oracle)
2022-05-28  5:49   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 09/24] nilfs2: " Matthew Wilcox (Oracle)
2022-05-28  5:49   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 10/24] ntfs: " Matthew Wilcox (Oracle)
2022-05-28  5:49   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 11/24] ntfs3: " Matthew Wilcox (Oracle)
2022-05-28  5:51   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 12/24] reiserfs: " Matthew Wilcox (Oracle)
2022-05-28  5:52   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 13/24] ufs: Remove checks " Matthew Wilcox (Oracle)
2022-05-28  5:56   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 14/24] remap_range: Remove check of uptodate flag Matthew Wilcox (Oracle)
2022-05-28  5:59   ` Christoph Hellwig
2022-05-30 12:35     ` Matthew Wilcox
2022-05-27 15:50 ` [PATCH 15/24] jfs: Remove check for PageUptodate Matthew Wilcox (Oracle)
2022-05-28  5:59   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 16/24] iomap: Remove test for folio error Matthew Wilcox (Oracle)
2022-05-28  6:00   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 17/24] orangefs: " Matthew Wilcox (Oracle)
2022-05-28  6:00   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 18/24] buffer: Remove check for PageError Matthew Wilcox (Oracle)
2022-05-28  6:01   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 19/24] nfs: Leave pages in the pagecache if readpage failed Matthew Wilcox (Oracle)
2022-05-28  6:02   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 20/24] btrfs: Use a folio in wait_dev_supers() Matthew Wilcox (Oracle)
2022-05-28  6:03   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 21/24] buffer: Don't test folio error in block_read_full_folio() Matthew Wilcox (Oracle)
2022-05-28  6:05   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 22/24] squashfs: Return the actual error from squashfs_read_folio() Matthew Wilcox (Oracle)
2022-05-28  6:06   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 23/24] hostfs: Handle page write errors correctly Matthew Wilcox (Oracle)
2022-05-28  6:06   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 24/24] ocfs2: Use filemap_write_and_wait_range() in ocfs2_cow_sync_writeback() Matthew Wilcox (Oracle)
2022-05-28  6:07   ` Christoph Hellwig
2022-05-28  6:12 ` [PATCH 00/24] Begin removing PageError Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.