diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2020-05-29 10:18:25 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2020-06-01 21:16:28 -0700 |
commit | 5355c984a2b76afbad8398986ded547a9c0370b4 (patch) | |
tree | 78a57b30f0005ad8719692491c00bba1c497e5ea | |
parent | b9041979e55aec649c415f6815304c815d63090d (diff) |
xfs: don't eat an EIO/ENOSPC writeback error when scrubbing data fork
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>
-rw-r--r-- | fs/xfs/scrub/bmap.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c index add8598eacd5..46fd3cefbfd6 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; } |