From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] xfs: don't eat an EIO/ENOSPC writeback error when scrubbing data fork
Date: Mon, 22 Jun 2020 10:17:13 -0700 [thread overview]
Message-ID: <20200622171713.GG11245@magnolia> (raw)
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>
---
fs/xfs/scrub/bmap.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
index 7badd6dfe544..03be7cf3fe5a 100644
--- a/fs/xfs/scrub/bmap.c
+++ b/fs/xfs/scrub/bmap.c
@@ -47,7 +47,15 @@ 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.
+ */
+ mapping_set_error(VFS_I(sc->ip)->i_mapping, error);
+ } else if (error)
goto out;
}
next reply other threads:[~2020-06-22 17:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-22 17:17 Darrick J. Wong [this message]
2020-06-22 22:08 ` [PATCH] xfs: don't eat an EIO/ENOSPC writeback error when scrubbing data fork Dave Chinner
2020-06-22 23:28 ` Darrick J. Wong
2020-06-22 23:58 ` Dave Chinner
2020-06-23 1:02 ` Darrick J. Wong
2020-06-23 2:37 ` Dave Chinner
2020-06-23 2:42 ` Darrick J. Wong
2020-06-23 3:50 ` Darrick J. Wong
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=20200622171713.GG11245@magnolia \
--to=darrick.wong@oracle.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