linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Jeff Layton <jlayton@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>,
	Andres Freund <andres@anarazel.de>,
	Andreas Dilger <adilger@dilger.ca>,
	20180410184356.GD3563@thunk.org,
	"Theodore Y. Ts'o" <tytso@mit.edu>,
	Ext4 Developers List <linux-ext4@vger.kernel.org>,
	Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	"Joshua D. Drake" <jd@commandprompt.com>
Subject: Re: fsync() errors is unsafe and risks data loss
Date: Sat, 21 Apr 2018 20:14:29 +0200	[thread overview]
Message-ID: <20180421181429.vhomy6oi5weht7s2@quack2.suse.cz> (raw)
In-Reply-To: <1523531354.4532.21.camel@redhat.com>

On Thu 12-04-18 07:09:14, Jeff Layton wrote:
> On Wed, 2018-04-11 at 20:02 -0700, Matthew Wilcox wrote:
> > At the moment, when we open a file, we sample the current state of the
> > writeback error and only report new errors.  We could set it to zero
> > instead, and report the most recent error as soon as anything happens
> > which would report an error.  That way err = close(open("file")); would
> > report the most recent error.
> > 
> > That's not going to be persistent across the data structure for that inode
> > being removed from memory; we'd need filesystem support for persisting
> > that.  But maybe it's "good enough" to only support it for recent files.
> > 
> > Jeff, what do you think?
> 
> I hate it :). We could do that, but....yecchhhh.
> 
> Reporting errors only in the case where the inode happened to stick
> around in the cache seems too unreliable for real-world usage, and might
> be problematic for some use cases. I'm also not sure it would really be
> helpful.

So this is never going to be perfect but I think we could do good enough
by:
1) Mark inodes that hit IO error.
2) If the inode gets evicted from memory we store the fact that we hit an
error for this IO in a more space efficient data structure (sparse bitmap,
radix tree, extent tree, whatever).
3) If the underlying device gets destroyed, we can just switch the whole SB
to an error state and forget per inode info.
4) If there's too much of per-inode error info (probably per-fs configurable
limit in terms of number of inodes), we would yell in the kernel log,
switch the whole fs to the error state and forget per inode info.

This way there won't be silent loss of IO errors. Memory usage would be
reasonably limited. It could happen the whole fs would switch to error state
"prematurely" but if that's a problem for the machine, admin could tune the
limit for number of inodes to keep IO errors for...

> I think the crux of the matter here is not really about error reporting,
> per-se.

I think this is related but a different question.

> I asked this at LSF last year, and got no real answer:
> 
> When there is a writeback error, what should be done with the dirty
> page(s)? Right now, we usually just mark them clean and carry on. Is
> that the right thing to do?
> 
> One possibility would be to invalidate the range that failed to be
> written (or the whole file) and force the pages to be faulted in again
> on the next access. It could be surprising for some applications to not
> see the results of their writes on a subsequent read after such an
> event.
> 
> Maybe that's ok in the face of a writeback error though? IDK.

I can see the admin wanting to rather kill the machine with OOM than having
to deal with data loss due to IO errors (e.g. if he has HA server fail over
set up).  Or retry for some time before dropping the dirty data.  Or do
what we do now (possibly with invalidating pages as you say). As Dave said
elsewhere there's not one strategy that's going to please everybody. So it
might be beneficial to have this configurable like XFS has it for metadata.

OTOH if I look at the problem from application developer POV, most apps
will just declare game over at the face of IO errors (if they take care to
check for them at all). And the sophisticated apps that will try some kind
of error recovery have to be prepared that the data is just gone (as
depending on what exactly the kernel does is rather fragile) so I'm not
sure how much practical value the configurable behavior on writeback errors
would bring.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  parent reply	other threads:[~2018-04-21 23:19 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 22:07 fsync() errors is unsafe and risks data loss Andres Freund
2018-04-11 21:52 ` Andreas Dilger
2018-04-12  0:09   ` Dave Chinner
2018-04-12  2:32     ` Andres Freund
2018-04-12  2:51       ` Andres Freund
2018-04-12  5:09       ` Theodore Y. Ts'o
2018-04-12  5:45       ` Dave Chinner
2018-04-12 11:24         ` Jeff Layton
2018-04-12 21:11           ` Andres Freund
2018-04-12 10:19       ` Lukas Czerner
2018-04-12 19:46         ` Andres Freund
2018-04-12  2:17   ` Andres Freund
2018-04-12  3:02     ` Matthew Wilcox
2018-04-12 11:09       ` Jeff Layton
2018-04-12 11:19         ` Matthew Wilcox
2018-04-12 12:01         ` Dave Chinner
2018-04-12 15:08           ` Jeff Layton
2018-04-12 22:44             ` Dave Chinner
2018-04-13 13:18               ` Jeff Layton
2018-04-13 13:25                 ` Andres Freund
2018-04-13 14:02                 ` Matthew Wilcox
2018-04-14  1:47                   ` Dave Chinner
2018-04-14  2:04                     ` Andres Freund
2018-04-18 23:59                       ` Dave Chinner
2018-04-19  0:23                         ` Eric Sandeen
2018-04-14  2:38                     ` Matthew Wilcox
2018-04-19  0:13                       ` Dave Chinner
2018-04-19  0:40                         ` Matthew Wilcox
2018-04-19  1:08                           ` Theodore Y. Ts'o
2018-04-19 17:40                             ` Matthew Wilcox
2018-04-19 23:27                               ` Theodore Y. Ts'o
2018-04-19 23:28                           ` Dave Chinner
2018-04-12 15:16           ` Theodore Y. Ts'o
2018-04-12 20:13             ` Andres Freund
2018-04-12 20:28               ` Matthew Wilcox
2018-04-12 21:14                 ` Jeff Layton
2018-04-12 21:31                   ` Matthew Wilcox
2018-04-13 12:56                     ` Jeff Layton
2018-04-12 21:21                 ` Theodore Y. Ts'o
2018-04-12 21:24                   ` Matthew Wilcox
2018-04-12 21:37                   ` Andres Freund
2018-04-12 20:24         ` Andres Freund
2018-04-12 21:27           ` Jeff Layton
2018-04-12 21:53             ` Andres Freund
2018-04-12 21:57               ` Theodore Y. Ts'o
2018-04-21 18:14         ` Jan Kara [this message]
2018-04-12  5:34     ` Theodore Y. Ts'o
2018-04-12 19:55       ` Andres Freund
2018-04-12 21:52         ` Theodore Y. Ts'o
2018-04-12 22:03           ` Andres Freund
2018-04-18 18:09     ` J. Bruce Fields
2018-04-13 14:48 ` Matthew Wilcox
2018-04-21 16:59   ` Jan Kara
     [not found] <8da874c9-cf9c-d40a-3474-b773190878e7@commandprompt.com>
     [not found] ` <20180410184356.GD3563@thunk.org>
2018-04-10 19:47   ` Martin Steigerwald
2018-04-18 16:52     ` J. Bruce Fields
2018-04-19  8:39       ` Christoph Hellwig
2018-04-19 14:10         ` J. Bruce Fields

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=20180421181429.vhomy6oi5weht7s2@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=20180410184356.GD3563@thunk.org \
    --cc=adilger@dilger.ca \
    --cc=andres@anarazel.de \
    --cc=jd@commandprompt.com \
    --cc=jlayton@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --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).