Skip to content

Commit

Permalink
NFS: Don't inadvertently clear writeback errors
Browse files Browse the repository at this point in the history
vfs_fsync() has the side effect of clearing unreported writeback errors,
so we need to make sure that we do not abuse it in situations where
applications might not normally expect us to report those errors.

The solution is to replace calls to vfs_fsync() with calls to nfs_wb_all().

Signed-off-by: Trond Myklebust <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
  • Loading branch information
trondmy authored and amschuma-ntap committed Apr 25, 2019
1 parent 22876f5 commit aded8d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fs/nfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ nfs_file_flush(struct file *file, fl_owner_t id)
return 0;

/* Flush writes to the server and return any errors */
return vfs_fsync(file, 0);
return nfs_wb_all(inode);
}

ssize_t
Expand Down Expand Up @@ -655,7 +655,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)

/* Return error values */
if (nfs_need_check_write(file, inode)) {
int err = vfs_fsync(file, 0);
int err = nfs_wb_all(inode);
if (err < 0)
result = err;
}
Expand Down Expand Up @@ -709,7 +709,7 @@ do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
* Flush all pending writes before doing anything
* with locks..
*/
vfs_fsync(filp, 0);
nfs_wb_all(inode);

l_ctx = nfs_get_lock_context(nfs_file_open_context(filp));
if (!IS_ERR(l_ctx)) {
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/nfs4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ 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 vfs_fsync(file, 0);
return nfs_wb_all(inode);
}

#ifdef CONFIG_NFS_V4_2
Expand Down

0 comments on commit aded8d7

Please sign in to comment.