xfs: don't eat an EIO/ENOSPC writeback error when scrubbing data fork
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 29 Jun 2020 21:47:17 +0000 (14:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Aug 2020 06:23:52 +0000 (08:23 +0200)
commit427f3f5f76add5174584f52d656a2faaf7a24367
tree93a817fea1498f5d3237a2c1e6faa5fbd57b3da3
parent2b8e23834a57b3db93972dedd04f2eeaf5e44e99
xfs: don't eat an EIO/ENOSPC writeback error when scrubbing data fork

[ Upstream commit eb0efe5063bb10bcb653e4f8e92a74719c03a347 ]

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>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/xfs/scrub/bmap.c