aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2012-06-20 15:53:42 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-29 11:46:44 -0400
commita5c58892b427a2752e3ec44b0aad4ce9221dc63b (patch)
tree8558ab576a41c36b6c4c22592d308de2d5c5b0fb
parenteeebf91675421b730448489ebf4720e5c419beec (diff)
NFS: Create a v4-specific fsync function
v2 and v3 don't need to worry about doing a pnfs layoutcommit. Signed-off-by: Bryan Schumaker <bjschuma@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/file.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index a6708e6b438d..8941ac41c59b 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -265,7 +265,7 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
265 * fall back to doing a synchronous write. 265 * fall back to doing a synchronous write.
266 */ 266 */
267static int 267static int
268nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) 268nfs_file_fsync_commit(struct file *file, loff_t start, loff_t end, int datasync)
269{ 269{
270 struct dentry *dentry = file->f_path.dentry; 270 struct dentry *dentry = file->f_path.dentry;
271 struct nfs_open_context *ctx = nfs_file_open_context(file); 271 struct nfs_open_context *ctx = nfs_file_open_context(file);
@@ -277,9 +277,6 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
277 dentry->d_parent->d_name.name, dentry->d_name.name, 277 dentry->d_parent->d_name.name, dentry->d_name.name,
278 datasync); 278 datasync);
279 279
280 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
281 mutex_lock(&inode->i_mutex);
282
283 nfs_inc_stats(inode, NFSIOS_VFSFSYNC); 280 nfs_inc_stats(inode, NFSIOS_VFSFSYNC);
284 have_error = test_and_clear_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); 281 have_error = test_and_clear_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
285 status = nfs_commit_inode(inode, FLUSH_SYNC); 282 status = nfs_commit_inode(inode, FLUSH_SYNC);
@@ -290,10 +287,20 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
290 ret = xchg(&ctx->error, 0); 287 ret = xchg(&ctx->error, 0);
291 if (!ret && status < 0) 288 if (!ret && status < 0)
292 ret = status; 289 ret = status;
293 if (!ret && !datasync) 290 return ret;
294 /* application has asked for meta-data sync */ 291}
295 ret = pnfs_layoutcommit_inode(inode, true); 292
293static int
294nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
295{
296 int ret;
297 struct inode *inode = file->f_path.dentry->d_inode;
298
299 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
300 mutex_lock(&inode->i_mutex);
301 ret = nfs_file_fsync_commit(file, start, end, datasync);
296 mutex_unlock(&inode->i_mutex); 302 mutex_unlock(&inode->i_mutex);
303
297 return ret; 304 return ret;
298} 305}
299 306
@@ -956,6 +963,23 @@ out_drop:
956 goto out_put_ctx; 963 goto out_put_ctx;
957} 964}
958 965
966static int
967nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
968{
969 int ret;
970 struct inode *inode = file->f_path.dentry->d_inode;
971
972 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
973 mutex_lock(&inode->i_mutex);
974 ret = nfs_file_fsync_commit(file, start, end, datasync);
975 if (!ret && !datasync)
976 /* application has asked for meta-data sync */
977 ret = pnfs_layoutcommit_inode(inode, true);
978 mutex_unlock(&inode->i_mutex);
979
980 return ret;
981}
982
959const struct file_operations nfs4_file_operations = { 983const struct file_operations nfs4_file_operations = {
960 .llseek = nfs_file_llseek, 984 .llseek = nfs_file_llseek,
961 .read = do_sync_read, 985 .read = do_sync_read,
@@ -966,7 +990,7 @@ const struct file_operations nfs4_file_operations = {
966 .open = nfs4_file_open, 990 .open = nfs4_file_open,
967 .flush = nfs_file_flush, 991 .flush = nfs_file_flush,
968 .release = nfs_file_release, 992 .release = nfs_file_release,
969 .fsync = nfs_file_fsync, 993 .fsync = nfs4_file_fsync,
970 .lock = nfs_lock, 994 .lock = nfs_lock,
971 .flock = nfs_flock, 995 .flock = nfs_flock,
972 .splice_read = nfs_file_splice_read, 996 .splice_read = nfs_file_splice_read,