nfs: ensure correct writeback errors are returned on close()
authorScott Mayhew <smayhew@redhat.com>
Sat, 1 Aug 2020 11:10:38 +0000 (07:10 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 11:07:38 +0000 (13:07 +0200)
commitcc03f4be0a15e70f56981750a9d84ab7613921ea
tree77853fb2bbc7b543e3174f11225ca38aed531a4e
parentf7002388d87325a7d43318e91f8dc0f703f39933
nfs: ensure correct writeback errors are returned on close()

[ Upstream commit 67dd23f9e6fbaf163431912ef5599c5e0693476c ]

nfs_wb_all() calls filemap_write_and_wait(), which uses
filemap_check_errors() to determine the error to return.
filemap_check_errors() only looks at the mapping->flags and will
therefore only return either -ENOSPC or -EIO.  To ensure that the
correct error is returned on close(), nfs{,4}_file_flush() should call
filemap_check_wb_err() which looks at the errseq value in
mapping->wb_err without consuming it.

Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with
generic one")
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/file.c
fs/nfs/nfs4file.c