summaryrefslogtreecommitdiff
path: root/fs/nfs
diff options
context:
space:
mode:
authorScott Mayhew <smayhew@redhat.com>2020-08-01 07:10:38 -0400
committerTrond Myklebust <trond.myklebust@hammerspace.com>2020-08-01 15:37:48 -0400
commit67dd23f9e6fbaf163431912ef5599c5e0693476c (patch)
tree38c5b336d3c1ccddc3348a030423ab243d580501 /fs/nfs
parent048c397aa88b8c6ebbcce8b5c480ae53773f14b9 (diff)
nfs: ensure correct writeback errors are returned on close()
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>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/file.c5
-rw-r--r--fs/nfs/nfs4file.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index ccd6c1637b27..bb244fc39d4b 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -141,6 +141,7 @@ static int
nfs_file_flush(struct file *file, fl_owner_t id)
{
struct inode *inode = file_inode(file);
+ errseq_t since;
dprintk("NFS: flush(%pD2)\n", file);
@@ -149,7 +150,9 @@ nfs_file_flush(struct file *file, fl_owner_t id)
return 0;
/* Flush writes to the server and return any errors */
- return nfs_wb_all(inode);
+ since = filemap_sample_wb_err(file->f_mapping);
+ nfs_wb_all(inode);
+ return filemap_check_wb_err(file->f_mapping, since);
}
ssize_t
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 8e5d6223ddd3..a33970765467 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -110,6 +110,7 @@ static int
nfs4_file_flush(struct file *file, fl_owner_t id)
{
struct inode *inode = file_inode(file);
+ errseq_t since;
dprintk("NFS: flush(%pD2)\n", file);
@@ -125,7 +126,9 @@ nfs4_file_flush(struct file *file, fl_owner_t id)
return filemap_fdatawrite(file->f_mapping);
/* Flush writes to the server and return any errors */
- return nfs_wb_all(inode);
+ since = filemap_sample_wb_err(file->f_mapping);
+ nfs_wb_all(inode);
+ return filemap_check_wb_err(file->f_mapping, since);
}
#ifdef CONFIG_NFS_V4_2