All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	tytso@mit.edu, jack@suse.cz, willy@infradead.org, neilb@suse.com,
	viro@zeniv.linux.org.uk
Subject: [PATCH v2 13/17] mm: don't TestClearPageError in __filemap_fdatawait_range
Date: Wed, 12 Apr 2017 08:06:10 -0400	[thread overview]
Message-ID: <20170412120614.6111-14-jlayton@redhat.com> (raw)
In-Reply-To: <20170412120614.6111-1-jlayton@redhat.com>

The -EIO returned here can end up overriding whatever error is marked in
the address space, and be returned at fsync time, even when there is a
more appropriate error stored in the mapping.

Read errors are also sometimes tracked on a per-page level using
PG_error. Suppose we have a read error on a page, and then that page is
subsequently dirtied by overwriting the whole page. Writeback doesn't
clear PG_error, so we can then end up successfully writing back that
page and still return -EIO on fsync.

Worse yet, PG_error is cleared during a sync() syscall, but the -EIO
return from that is silently discarded. Any subsystem that is relying on
PG_error to report errors during fsync can easily lose writeback errors
due to this. All you need is a stray sync() call on the box at the wrong
time and you've lost the error.

Since the handling of the PG_error flag is somewhat inconsistent across
subsystems, let's just rely on marking the address space when there are
writeback errors. Change the TestClearPageError call to ClearPageError,
and make __filemap_fdatawait_range a void return function.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 mm/filemap.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 525dddc15abb..b43975ca7a2e 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -362,17 +362,16 @@ int filemap_flush(struct address_space *mapping)
 }
 EXPORT_SYMBOL(filemap_flush);
 
-static int __filemap_fdatawait_range(struct address_space *mapping,
+static void __filemap_fdatawait_range(struct address_space *mapping,
 				     loff_t start_byte, loff_t end_byte)
 {
 	pgoff_t index = start_byte >> PAGE_SHIFT;
 	pgoff_t end = end_byte >> PAGE_SHIFT;
 	struct pagevec pvec;
 	int nr_pages;
-	int ret = 0;
 
 	if (end_byte < start_byte)
-		goto out;
+		return;
 
 	pagevec_init(&pvec, 0);
 	while ((index <= end) &&
@@ -389,14 +388,11 @@ static int __filemap_fdatawait_range(struct address_space *mapping,
 				continue;
 
 			wait_on_page_writeback(page);
-			if (TestClearPageError(page))
-				ret = -EIO;
+			ClearPageError(page);
 		}
 		pagevec_release(&pvec);
 		cond_resched();
 	}
-out:
-	return ret;
 }
 
 /**
@@ -416,15 +412,10 @@ static int __filemap_fdatawait_range(struct address_space *mapping,
 int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte,
 			    loff_t end_byte)
 {
-	int ret, ret2;
 	wb_err_t since = READ_ONCE(mapping->wb_err);
 
-	ret = __filemap_fdatawait_range(mapping, start_byte, end_byte);
-	ret2 = filemap_check_wb_error(mapping, since);
-	if (!ret)
-		ret = ret2;
-
-	return ret;
+	__filemap_fdatawait_range(mapping, start_byte, end_byte);
+	return filemap_check_wb_error(mapping, since);
 }
 EXPORT_SYMBOL(filemap_fdatawait_range);
 
-- 
2.9.3

  parent reply	other threads:[~2017-04-12 12:06 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12 12:05 [PATCH v2 00/17] fs: introduce new writeback error reporting and convert existing API as a wrapper around it Jeff Layton
2017-04-12 12:05 ` [PATCH v2 01/17] mm: drop "wait" parameter from write_one_page Jeff Layton
2017-04-12 12:15   ` Jan Kara
2017-04-12 14:27   ` Matthew Wilcox
2017-04-12 14:34     ` Jeff Layton
2017-04-12 15:12     ` Dave Kleikamp
2017-04-12 12:05 ` [PATCH v2 02/17] mm: fix mapping_set_error call in me_pagecache_dirty Jeff Layton
2017-04-12 12:16   ` Jan Kara
2017-04-12 14:28   ` Matthew Wilcox
2017-04-12 12:06 ` [PATCH v2 03/17] buffer: use mapping_set_error instead of setting the flag Jeff Layton
2017-04-12 12:17   ` Jan Kara
2017-04-12 14:29   ` Matthew Wilcox
2017-04-12 12:06 ` [PATCH v2 04/17] ext2: don't test/clear AS_EIO flag Jeff Layton
2017-04-12 12:29   ` Jan Kara
2017-04-12 12:30     ` Jeff Layton
2017-04-12 12:06 ` [PATCH v2 05/17] orangefs: don't call filemap_write_and_wait from fsync Jeff Layton
2017-04-12 12:06 ` [PATCH v2 06/17] mm: doc comment for scary spot in write_one_page Jeff Layton
2017-04-12 13:01   ` Jeff Layton
2017-04-12 14:38     ` Matthew Wilcox
2017-04-12 15:52       ` Jeff Layton
2017-04-12 21:36         ` NeilBrown
2017-04-12 22:55           ` Jeff Layton
2017-04-12 12:06 ` [PATCH v2 07/17] fs: new infrastructure for writeback error handling and reporting Jeff Layton
2017-04-12 18:42   ` Jeff Layton
2017-04-12 21:55     ` NeilBrown
2017-04-12 23:01       ` Jeff Layton
2017-04-17 22:53         ` NeilBrown
2017-04-12 12:06 ` [PATCH v2 08/17] fs: retrofit old error reporting API onto new infrastructure Jeff Layton
2017-04-12 22:14   ` NeilBrown
2017-04-12 22:41     ` Jeff Layton
2017-04-17 22:56       ` NeilBrown
2017-04-21 12:46         ` Jeff Layton
2017-04-23 22:38           ` NeilBrown
2017-04-24 11:50             ` Jeff Layton
2017-04-17 15:17     ` Jeff Layton
2017-04-12 12:06 ` [PATCH v2 09/17] mm: remove AS_EIO and AS_ENOSPC flags Jeff Layton
2017-04-12 12:06 ` [PATCH v2 10/17] dax: set errors in mapping when writeback fails Jeff Layton
2017-04-12 12:06 ` [PATCH v2 11/17] nilfs2: set the mapping error when calling SetPageError on writeback Jeff Layton
2017-04-12 12:06 ` [PATCH v2 12/17] mm: ensure that we set mapping error if writeout() fails Jeff Layton
2017-04-12 12:06 ` Jeff Layton [this message]
2017-04-12 12:06 ` [PATCH v2 14/17] 9p: set mapping error when writeback fails in launder_page Jeff Layton
2017-04-12 12:06 ` [PATCH v2 15/17] fuse: set mapping error in writepage_locked when it fails Jeff Layton
2017-04-12 12:06 ` [PATCH v2 16/17] cifs: set mapping error when page writeback fails in writepage or launder_pages Jeff Layton
2017-04-12 12:06 ` [PATCH v2 17/17] cifs: remove some unneeded mapping_set_error calls Jeff Layton

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=20170412120614.6111-14-jlayton@redhat.com \
    --to=jlayton@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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 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.