Commit 7b281ee0 authored by Trond Myklebust's avatar Trond Myklebust

NFS: fsync() must exit with an error if page writeback failed

We need to ensure that if the call to filemap_write_and_wait_range()
fails, then we report that error back to the application.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent f39c1bfb
...@@ -287,10 +287,12 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -287,10 +287,12 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
ret = filemap_write_and_wait_range(inode->i_mapping, start, end); ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (ret != 0)
goto out;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
ret = nfs_file_fsync_commit(file, start, end, datasync); ret = nfs_file_fsync_commit(file, start, end, datasync);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
out:
return ret; return ret;
} }
......
...@@ -96,13 +96,15 @@ nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -96,13 +96,15 @@ nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
ret = filemap_write_and_wait_range(inode->i_mapping, start, end); ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (ret != 0)
goto out;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
ret = nfs_file_fsync_commit(file, start, end, datasync); ret = nfs_file_fsync_commit(file, start, end, datasync);
if (!ret && !datasync) if (!ret && !datasync)
/* application has asked for meta-data sync */ /* application has asked for meta-data sync */
ret = pnfs_layoutcommit_inode(inode, true); ret = pnfs_layoutcommit_inode(inode, true);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
out:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment