From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: xfs <linux-xfs@vger.kernel.org>, Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH v2] xfs: don't eat an EIO/ENOSPC writeback error when scrubbing data fork
Date: Tue, 23 Jun 2020 12:49:34 -0400 [thread overview]
Message-ID: <20200623164934.GA56510@bfoster> (raw)
In-Reply-To: <20200623152350.GE7625@magnolia>
On Tue, Jun 23, 2020 at 08:23:50AM -0700, Darrick J. Wong wrote:
> On Tue, Jun 23, 2020 at 08:10:31AM -0400, Brian Foster wrote:
> > On Mon, Jun 22, 2020 at 08:50:10PM -0700, Darrick J. Wong wrote:
> > > From: Darrick J. Wong <darrick.wong@oracle.com>
> > >
> > > The data fork scrubber calls filemap_write_and_wait to flush dirty pages
> > > and delalloc reservations out to disk prior to checking the data fork's
> > > extent mappings. Unfortunately, this means that scrub can consume the
> > > EIO/ENOSPC errors that would otherwise have stayed around in the address
> > > space until (we hope) the writer application calls fsync to persist data
> > > and collect errors. The end result is that programs that wrote to a
> > > file might never see the error code and proceed as if nothing were
> > > wrong.
> > >
> > > xfs_scrub is not in a position to notify file writers about the
> > > writeback failure, and it's only here to check metadata, not file
> > > contents. Therefore, if writeback fails, we should stuff the error code
> > > back into the address space so that an fsync by the writer application
> > > can pick that up.
> > >
> > > Fixes: 99d9d8d05da2 ("xfs: scrub inode block mappings")
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > ---
> > > v2: explain why it's ok to keep going even if writeback fails
> > > ---
> > > fs/xfs/scrub/bmap.c | 19 ++++++++++++++++++-
> > > 1 file changed, 18 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
> > > index 7badd6dfe544..0d7062b7068b 100644
> > > --- a/fs/xfs/scrub/bmap.c
> > > +++ b/fs/xfs/scrub/bmap.c
> > > @@ -47,7 +47,24 @@ xchk_setup_inode_bmap(
> > > sc->sm->sm_type == XFS_SCRUB_TYPE_BMBTD) {
> > > inode_dio_wait(VFS_I(sc->ip));
> > > error = filemap_write_and_wait(VFS_I(sc->ip)->i_mapping);
> > > - if (error)
> > > + if (error == -ENOSPC || error == -EIO) {
> > > + /*
> > > + * If writeback hits EIO or ENOSPC, reflect it back
> > > + * into the address space mapping so that a writer
> > > + * program calling fsync to look for errors will still
> > > + * capture the error.
> > > + *
> > > + * However, we continue into the extent mapping checks
> > > + * because write failures do not necessarily imply
> > > + * anything about the correctness of the file metadata.
> > > + * The metadata and the file data could be on
> > > + * completely separate devices; a media failure might
> > > + * only affect a subset of the disk, etc. We properly
> > > + * account for delalloc extents, so leaving them in
> > > + * memory is fine.
> > > + */
> > > + mapping_set_error(VFS_I(sc->ip)->i_mapping, error);
> >
> > I think the more appropriate thing to do is open code the data write and
> > wait and use the variants of the latter that don't consume address space
> > errors in the first place (i.e. filemap_fdatawait_keep_errors()). Then
> > we wouldn't need the special error handling branch or perhaps the first
> > part of the comment. Hm?
>
> Yes, it's certainly possible. I don't want to go opencoding more vfs
> methods (like some e4 filesystems do) so I'll propose that as a second
> patch for 5.9.
>
What's the point of fixing it twice when the generic code already
exports the appropriate helpers? filemap_fdatawrite() and
filemap_fdatawait_keep_errors() are used fairly commonly afaict. That
seems much more straightforward to me than misusing a convenience helper
and trying to undo the undesirable effects after the fact.
> On second thought, I wonder if I should just drop the flush entirely?
> It's not a huge burden to skip past the delalloc reservations.
>
> Hmmm. Any preferences?
>
The context for the above is not clear to me. If the purpose is to check
on-disk metadata, shouldn't we flush the in-core content first? It would seem
a little strange to me for one file check to behave differently from
another if the only difference between the two is that some or more of a
file had been written back, but maybe I'm missing details..
Brian
> --D
>
> > Brian
> >
> > > + } else if (error)
> > > goto out;
> > > }
> > >
> > >
> >
>
next prev parent reply other threads:[~2020-06-23 16:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 3:50 [PATCH v2] xfs: don't eat an EIO/ENOSPC writeback error when scrubbing data fork Darrick J. Wong
2020-06-23 4:26 ` Dave Chinner
2020-06-23 12:10 ` Brian Foster
2020-06-23 15:23 ` Darrick J. Wong
2020-06-23 16:49 ` Brian Foster [this message]
2020-06-23 17:00 ` Darrick J. Wong
2020-06-23 17:15 ` Brian Foster
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=20200623164934.GA56510@bfoster \
--to=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.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