aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/file.c8
-rw-r--r--fs/nfs/internal.h2
-rw-r--r--fs/nfs/nfs4file.c33
3 files changed, 7 insertions, 36 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 748bb813b8ec..cdf862188618 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -233,7 +233,7 @@ EXPORT_SYMBOL_GPL(nfs_file_mmap);
233 * nfs_file_write() that a write error occurred, and hence cause it to 233 * nfs_file_write() that a write error occurred, and hence cause it to
234 * fall back to doing a synchronous write. 234 * fall back to doing a synchronous write.
235 */ 235 */
236int 236static int
237nfs_file_fsync_commit(struct file *file, loff_t start, loff_t end, int datasync) 237nfs_file_fsync_commit(struct file *file, loff_t start, loff_t end, int datasync)
238{ 238{
239 struct nfs_open_context *ctx = nfs_file_open_context(file); 239 struct nfs_open_context *ctx = nfs_file_open_context(file);
@@ -263,9 +263,8 @@ nfs_file_fsync_commit(struct file *file, loff_t start, loff_t end, int datasync)
263out: 263out:
264 return ret; 264 return ret;
265} 265}
266EXPORT_SYMBOL_GPL(nfs_file_fsync_commit);
267 266
268static int 267int
269nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) 268nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
270{ 269{
271 int ret; 270 int ret;
@@ -280,6 +279,8 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
280 break; 279 break;
281 inode_lock(inode); 280 inode_lock(inode);
282 ret = nfs_file_fsync_commit(file, start, end, datasync); 281 ret = nfs_file_fsync_commit(file, start, end, datasync);
282 if (!ret)
283 ret = pnfs_sync_inode(inode, !!datasync);
283 inode_unlock(inode); 284 inode_unlock(inode);
284 /* 285 /*
285 * If nfs_file_fsync_commit detected a server reboot, then 286 * If nfs_file_fsync_commit detected a server reboot, then
@@ -293,6 +294,7 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
293 trace_nfs_fsync_exit(inode, ret); 294 trace_nfs_fsync_exit(inode, ret);
294 return ret; 295 return ret;
295} 296}
297EXPORT_SYMBOL_GPL(nfs_file_fsync);
296 298
297/* 299/*
298 * Decide whether a read/modify/write cycle may be more efficient 300 * Decide whether a read/modify/write cycle may be more efficient
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 9a547aa3ec8e..c41c5f5baf03 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -358,7 +358,7 @@ int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
358int nfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); 358int nfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
359 359
360/* file.c */ 360/* file.c */
361int nfs_file_fsync_commit(struct file *, loff_t, loff_t, int); 361int nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync);
362loff_t nfs_file_llseek(struct file *, loff_t, int); 362loff_t nfs_file_llseek(struct file *, loff_t, int);
363ssize_t nfs_file_read(struct kiocb *, struct iov_iter *); 363ssize_t nfs_file_read(struct kiocb *, struct iov_iter *);
364ssize_t nfs_file_splice_read(struct file *, loff_t *, struct pipe_inode_info *, 364ssize_t nfs_file_splice_read(struct file *, loff_t *, struct pipe_inode_info *,
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 57ca1c8039c1..22c35abbee9d 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -128,37 +128,6 @@ nfs4_file_flush(struct file *file, fl_owner_t id)
128 return vfs_fsync(file, 0); 128 return vfs_fsync(file, 0);
129} 129}
130 130
131static int
132nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
133{
134 int ret;
135 struct inode *inode = file_inode(file);
136
137 trace_nfs_fsync_enter(inode);
138
139 nfs_inode_dio_wait(inode);
140 do {
141 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
142 if (ret != 0)
143 break;
144 inode_lock(inode);
145 ret = nfs_file_fsync_commit(file, start, end, datasync);
146 if (!ret)
147 ret = pnfs_sync_inode(inode, !!datasync);
148 inode_unlock(inode);
149 /*
150 * If nfs_file_fsync_commit detected a server reboot, then
151 * resend all dirty pages that might have been covered by
152 * the NFS_CONTEXT_RESEND_WRITES flag
153 */
154 start = 0;
155 end = LLONG_MAX;
156 } while (ret == -EAGAIN);
157
158 trace_nfs_fsync_exit(inode, ret);
159 return ret;
160}
161
162#ifdef CONFIG_NFS_V4_2 131#ifdef CONFIG_NFS_V4_2
163static loff_t nfs4_file_llseek(struct file *filep, loff_t offset, int whence) 132static loff_t nfs4_file_llseek(struct file *filep, loff_t offset, int whence)
164{ 133{
@@ -266,7 +235,7 @@ const struct file_operations nfs4_file_operations = {
266 .open = nfs4_file_open, 235 .open = nfs4_file_open,
267 .flush = nfs4_file_flush, 236 .flush = nfs4_file_flush,
268 .release = nfs_file_release, 237 .release = nfs_file_release,
269 .fsync = nfs4_file_fsync, 238 .fsync = nfs_file_fsync,
270 .lock = nfs_lock, 239 .lock = nfs_lock,
271 .flock = nfs_flock, 240 .flock = nfs_flock,
272 .splice_read = nfs_file_splice_read, 241 .splice_read = nfs_file_splice_read,