linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: NeilBrown <neilb@suse.com>, Matthew Wilcox <willy@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, tytso@mit.edu, jack@suse.cz,
	viro@zeniv.linux.org.uk, Dave Kleikamp <dave.kleikamp@oracle.com>
Subject: Re: [PATCH v2 06/17] mm: doc comment for scary spot in write_one_page
Date: Wed, 12 Apr 2017 18:55:48 -0400	[thread overview]
Message-ID: <1492037748.19286.3.camel@redhat.com> (raw)
In-Reply-To: <87lgr5ux4e.fsf@notabene.neil.brown.name>

On Thu, 2017-04-13 at 07:36 +1000, NeilBrown wrote:
> On Wed, Apr 12 2017, Jeff Layton wrote:
> 
> > On Wed, 2017-04-12 at 07:38 -0700, Matthew Wilcox wrote:
> > > On Wed, Apr 12, 2017 at 09:01:34AM -0400, Jeff Layton wrote:
> > > > On Wed, 2017-04-12 at 08:06 -0400, Jeff Layton wrote:
> > > > > Not sure what to do here just yet.
> > > > > 
> > > > > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> > > > > ---
> > > > >  mm/page-writeback.c | 6 ++++++
> > > > >  1 file changed, 6 insertions(+)
> > > > > 
> > > > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> > > > > index de0dbf12e2c1..3ac8399dc984 100644
> > > > > --- a/mm/page-writeback.c
> > > > > +++ b/mm/page-writeback.c
> > > > > @@ -2388,6 +2388,12 @@ int write_one_page(struct page *page)
> > > > >  		ret = mapping->a_ops->writepage(page, &wbc);
> > > > >  		if (ret == 0) {
> > > > >  			wait_on_page_writeback(page);
> > > > > +			/*
> > > > > +			 * FIXME: is this racy? What guarantees that PG_error
> > > > > +			 * will still be set once we get around to checking it?
> > > > > +			 * What if writeback fails, but then a read is issued
> > > > > +			 * before we check this, and that calls ClearPageError?
> > > > > +			 */
> > > > >  			if (PageError(page))
> > > > >  				ret = -EIO;
> > > > >  		}
> > > > 
> > > > Ahh, we are always under the page lock here, and this is generally used
> > > > for writing out directory pages anyway. I'm fine with dropping this
> > > > patch unless someone else sees a problem here.
> > > 
> > > ->writepage drops the page lock.  We're still holding a refcount on this
> > > page, but that's not going to prevent read being called.  But maybe the
> > > filesystem won't call read on a page that's marked as PageError?
> > 
> > Hard to be sure there. I really wonder if that check is needed at all,
> > the more I look at it. After all, we are calling writepage with
> > WB_SYNC_ALL so we should get an error there.
> 
> WB_SYNC_ALL doesn't cause writepage to wait.  It might case it to ask
> for REQ_SYNC, so the write requests gets priority in the block layer.
> WB_SYNC_ALL does cause writepages (with an 's') to wait.
> (At least, that is how I read the code).
> 

Yeah, I realized that after I sent it. If it waited, we wouldn't need
to wait_on_page_writeback there.

> > 
> > Is it also possible these pages could be written back before that point
> > (due to memory pressure or something) and that fail?
> 
> Probably, in which case clear_page_dirty_for_io() will fail and
> write_one_page() will just unlock the page.
> 

Right. So we're already potentially missing errors here for writeback
if it happened to occur before we called clear_page_dirty_for_io.

> > 
> > Maybe we should just have a call to filemap_check_errors on exiting
> > this function?
> 
> I'm leaning in that direction.
> 
> > With the the wb_err_t based stuff, we could change it to sample the
> > wb_err early, and then use that to see if an error has occurred since
> > then. Maybe we should even allow callers to pass a wb_err_t in here, so
> > we can report errors that have occurred since a known point?
> 
> That feels to me like over-engineering.  We would need to
> unconditionally call writepage() for that to work.
> 
> We seem to be agreed that write errors for buffered writes are reported
> per-address-space.  To get per-page errors you have to use direct IO.
> Let's focus on that policy and make it work.
>

That makes sense. I don't think we'd need to always call writepage
there though. We just need to call filemap_check_wb_error even in the
case where writepage wasn't called. IOW, we want to know if there was a
writeback error on the inode, even if it occurred before we tried to
clear the dirty flag.

So, with the new API, we just have to ensure that we sample the
wb_err_t at an earlier time, and then pass that value into
write_one_page so that it can use it to detect the errors since then.

For something like JFS (which apparently uses this function for its fs
journal), the "since" value could be the value at the time that the
journal was last flushed. Then you know whether something failed
regardless of whether it was synced out to disk before this function
was called.

Most of the other callers use this for synchronous directory changes,
so those might want to keep a wb_err_t value in their inode structures,
depending on what they're looking for there. Again, I think this is a
place where we need some input from the fs maintainers.
-- 
Jeff Layton <jlayton@redhat.com>

  reply	other threads:[~2017-04-12 22:55 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 [this message]
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 ` [PATCH v2 13/17] mm: don't TestClearPageError in __filemap_fdatawait_range Jeff Layton
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=1492037748.19286.3.camel@redhat.com \
    --to=jlayton@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.kleikamp@oracle.com \
    --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 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).