linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-mm@kvack.org, "Theodore Ts'o" <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	linux-ext4@vger.kernel.org
Subject: [PATCH v3 12/18] ext4: Return error from ext4_readpage
Date: Fri, 16 Oct 2020 17:04:37 +0100	[thread overview]
Message-ID: <20201016160443.18685-13-willy@infradead.org> (raw)
In-Reply-To: <20201016160443.18685-1-willy@infradead.org>

The error returned from ext4_map_blocks() was being discarded, leading
to the generic -EIO being returned to userspace.  Now ext4 can return
more precise errors.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ext4/readpage.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
index f014c5e473a9..00a024f3a954 100644
--- a/fs/ext4/readpage.c
+++ b/fs/ext4/readpage.c
@@ -237,7 +237,7 @@ int ext4_mpage_readpages(struct inode *inode,
 	sector_t blocks[MAX_BUF_PER_PAGE];
 	unsigned page_block;
 	struct block_device *bdev = inode->i_sb->s_bdev;
-	int length;
+	int length, err = 0;
 	unsigned relative_block = 0;
 	struct ext4_map_blocks map;
 	unsigned int nr_pages = rac ? readahead_count(rac) : 1;
@@ -301,14 +301,9 @@ int ext4_mpage_readpages(struct inode *inode,
 				map.m_lblk = block_in_file;
 				map.m_len = last_block - block_in_file;
 
-				if (ext4_map_blocks(NULL, inode, &map, 0) < 0) {
-				set_error_page:
-					SetPageError(page);
-					zero_user_segment(page, 0,
-							  PAGE_SIZE);
-					unlock_page(page);
-					goto next_page;
-				}
+				err = ext4_map_blocks(NULL, inode, &map, 0);
+				if (err < 0)
+					goto err;
 			}
 			if ((map.m_flags & EXT4_MAP_MAPPED) == 0) {
 				fully_mapped = 0;
@@ -395,6 +390,15 @@ int ext4_mpage_readpages(struct inode *inode,
 		} else
 			last_block_in_bio = blocks[blocks_per_page - 1];
 		goto next_page;
+	set_error_page:
+		err = -EIO;
+	err:
+		if (rac) {
+			SetPageError(page);
+			zero_user_segment(page, 0, PAGE_SIZE);
+		}
+		unlock_page(page);
+		goto next_page;
 	confused:
 		if (bio) {
 			submit_bio(bio);
@@ -410,7 +414,7 @@ int ext4_mpage_readpages(struct inode *inode,
 	}
 	if (bio)
 		submit_bio(bio);
-	return 0;
+	return err;
 }
 
 int __init ext4_init_post_read_processing(void)
-- 
2.28.0



  parent reply	other threads:[~2020-10-16 16:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 16:04 [PATCH v3 00/18] Allow readpage to return a locked page Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 01/18] cachefiles: Handle readpage error correctly Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 02/18] swap: Call aops->readahead if appropriate Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 03/18] fs: Add AOP_UPDATED_PAGE return value Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 04/18] mm/filemap: Inline wait_on_page_read into its one caller Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 05/18] 9p: Tell the VFS that readpage was synchronous Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 06/18] afs: " Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 07/18] ceph: " Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 08/18] cifs: " Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 09/18] cramfs: " Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 10/18] ecryptfs: " Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 11/18] ext4: " Matthew Wilcox (Oracle)
2020-10-18 14:24   ` Theodore Y. Ts'o
2020-10-16 16:04 ` Matthew Wilcox (Oracle) [this message]
2020-10-18 14:25   ` [PATCH v3 12/18] ext4: Return error from ext4_readpage Theodore Y. Ts'o
2020-10-18 15:04     ` Matthew Wilcox
2020-10-16 16:04 ` [PATCH v3 13/18] fuse: Tell the VFS that readpage was synchronous Matthew Wilcox (Oracle)
2020-10-20 14:13   ` Miklos Szeredi
2020-10-16 16:04 ` [PATCH v3 14/18] hostfs: " Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 15/18] jffs2: " Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 16/18] ubifs: " Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 17/18] udf: " Matthew Wilcox (Oracle)
2020-10-16 16:04 ` [PATCH v3 18/18] vboxsf: " Matthew Wilcox (Oracle)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201016160443.18685-13-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).