linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: NeilBrown <neilb@suse.com>, linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	tytso@mit.edu, jack@suse.cz, willy@infradead.org,
	viro@zeniv.linux.org.uk
Subject: Re: [PATCH v2 08/17] fs: retrofit old error reporting API onto new infrastructure
Date: Mon, 17 Apr 2017 11:17:47 -0400	[thread overview]
Message-ID: <1492442267.13263.1.camel@redhat.com> (raw)
In-Reply-To: <87fuhduvcv.fsf@notabene.neil.brown.name>

On Thu, 2017-04-13 at 08:14 +1000, NeilBrown wrote:
> On Wed, Apr 12 2017, Jeff Layton wrote:
> 
> > Now that we have a better way to store and report errors that occur
> > during writeback, we need to convert the existing codebase to use it. We
> > could just adapt all of the filesystem code and related infrastructure
> > to the new API, but that's a lot of churn.
> > 
> > When it comes to setting errors in the mapping, filemap_set_wb_error is
> > a drop-in replacement for mapping_set_error. Turn that function into a
> > simple wrapper around the new one.
> > 
> > Because we want to ensure that writeback errors are always reported at
> > fsync time, inject filemap_report_wb_error calls much closer to the
> > syscall boundary. For fsync calls (and things like the nfsd equivalent),
> > we either return the error that the fsync operation returns, or the one
> > returned by filemap_report_wb_error. In both cases, we advance the
> > file->f_wb_err to the latest value.
> > 
> > The final piece of the puzzle is what to do about filemap_check_errors
> > calls that are being called directly or via filemap_* functions. Here,
> > we must take a little "creative license".
> > 
> > Since we now handle advancing the file->f_wb_err value at the generic
> > filesystem layer, we no longer need those callers to do anything like
> > that, or clear errors out of the mapping. A lot of the existing codebase
> > relies on being getting an error back from those functions when there is
> > a writeback problem, so we do still want to have them report writeback
> > errors somehow.
> > 
> > When reporting writeback errors, we will always report errors that have
> > occurred since a particular point in time. With the old writeback error
> > reporting, the time we used was "since it was last tested/cleared" which
> > is entirely arbitrary and potentially racy. Now, we can at least report
> > the latest error that has occurred since an arbitrary point in time
> > (represented as a sampled wb_err_t value).
> > 
> > In the case where we don't have a struct file to work with, this patch
> > just has the wrappers sample the mapping->wb_err value, and use that as
> > an arbitrary point from which to check for errors.
> > 
> > That's probably not ideal, particularly in the case of something like
> > filemap_fdatawait, but I'm not sure it's any worse than what we
> > already have, and this gives us a basis from which to work.
> 
> This aspect of the patch looked rather odd -- sampling a wb_err_t at
> some arbitrary time, and then comparing it later.  So that for going to
> the trouble of explaining it.
> 
> I suspect that the filemap_check_wb_error() will need to be moved
> into some parent of the current call site, which is essentially what you
> suggest below.  It would be nice if we could do that first, rather than
> having the current rather odd code.  But maybe this way is an easier
> transition.  It isn't obviously wrong, it just isn't obviously right
> either.
> 

I thought about this a bit over the weekend, and I think we have a
couple of other options here when we don't have a struct file to work
with.

1) we could pass in a zeroed out value for "since" when we don't have
struct file. The way the implementation works, that tells you whether
there has ever been a writeback error since the inode was first
instantiated. The downside there is that we don't have a way to clear
this out until the inode is evicted, so that's a clear behavior change
from how AS_* flags work today.

2) we could store a second wb_err_t value in the mapping. That one
would basically act as the wb_err_t "cursor" for these cases. We have
to do something like filemap_report_wb_error but would swap the value
into the mapping's cursor instead of dealing with struct file. That's
also not perfectly like what we have with AS_EIO/AS_ENOSPC flags, but
is probably close enough not to matter. Doing that with atomics may be
tricky though.

Alternately, we could just try to plumb in reasonable "since" values
for all of the callers. Some of those won't be too hard to do (and some
don't even really need the errors at all), but some I really have no
clue on.

Option #2 above gives us a stopgap way to move those callers over
without having to have them worry about the details as much.

> >  int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync)
> >  {
> > +	int ret, ret2;
> >  	struct inode *inode = file->f_mapping->host;
> >  
> >  	if (!file->f_op->fsync)
> > @@ -192,7 +193,9 @@ int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync)
> >  		spin_unlock(&inode->i_lock);
> >  		mark_inode_dirty_sync(inode);
> >  	}
> > -	return call_fsync(file, start, end, datasync);
> > +	ret = call_fsync(file, start, end, datasync);
> > +	ret2 = filemap_report_wb_error(file);
> > +	return ret ? : ret2;
> >  }
> >  EXPORT_SYMBOL(vfs_fsync_range);
> >  
> 
> ....
> 
> >  static int shm_fsync(struct file *file, loff_t start, loff_t end, int datasync)
> >  {
> > +	int ret, ret2;
> >  	struct shm_file_data *sfd = shm_file_data(file);
> >  
> >  	if (!sfd->file->f_op->fsync)
> >  		return -EINVAL;
> > -	return call_fsync(sfd->file, start, end, datasync);
> > +	ret = call_fsync(sfd->file, start, end, datasync);
> > +	ret2 = filemap_report_wb_error(file);
> > +	return ret ? : ret2;
> >  }
> 
> These are the only two places that call_fsync() is called.
> Did you consider moving the filemap_report_wb_error() call into
> call_fsync() ??
> 
> Thanks,
> NeilBrown

-- 
Jeff Layton <jlayton@redhat.com>

  parent reply	other threads:[~2017-04-17 15:17 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 [this message]
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=1492442267.13263.1.camel@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 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).