Skip to content

Commit 67dd23f

Browse files
scottmayhewTrond Myklebust
authored andcommitted
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: 6fbda89 ("NFS: Replace custom error reporting mechanism with generic one") Signed-off-by: Scott Mayhew <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 048c397 commit 67dd23f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

fs/nfs/file.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ static int
141141
nfs_file_flush(struct file *file, fl_owner_t id)
142142
{
143143
struct inode *inode = file_inode(file);
144+
errseq_t since;
144145

145146
dprintk("NFS: flush(%pD2)\n", file);
146147

@@ -149,7 +150,9 @@ nfs_file_flush(struct file *file, fl_owner_t id)
149150
return 0;
150151

151152
/* Flush writes to the server and return any errors */
152-
return nfs_wb_all(inode);
153+
since = filemap_sample_wb_err(file->f_mapping);
154+
nfs_wb_all(inode);
155+
return filemap_check_wb_err(file->f_mapping, since);
153156
}
154157

155158
ssize_t

fs/nfs/nfs4file.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static int
110110
nfs4_file_flush(struct file *file, fl_owner_t id)
111111
{
112112
struct inode *inode = file_inode(file);
113+
errseq_t since;
113114

114115
dprintk("NFS: flush(%pD2)\n", file);
115116

@@ -125,7 +126,9 @@ nfs4_file_flush(struct file *file, fl_owner_t id)
125126
return filemap_fdatawrite(file->f_mapping);
126127

127128
/* Flush writes to the server and return any errors */
128-
return nfs_wb_all(inode);
129+
since = filemap_sample_wb_err(file->f_mapping);
130+
nfs_wb_all(inode);
131+
return filemap_check_wb_err(file->f_mapping, since);
129132
}
130133

131134
#ifdef CONFIG_NFS_V4_2

0 commit comments

Comments
 (0)