aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/coda/file.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/fs/coda/file.c b/fs/coda/file.c
index d244d743a232..d9f1d9a85e04 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -27,19 +27,14 @@
27#include "coda_int.h" 27#include "coda_int.h"
28 28
29static ssize_t 29static ssize_t
30coda_file_read(struct file *coda_file, char __user *buf, size_t count, loff_t *ppos) 30coda_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
31{ 31{
32 struct coda_file_info *cfi; 32 struct file *coda_file = iocb->ki_filp;
33 struct file *host_file; 33 struct coda_file_info *cfi = CODA_FTOC(coda_file);
34 34
35 cfi = CODA_FTOC(coda_file);
36 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 35 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
37 host_file = cfi->cfi_container;
38 36
39 if (!host_file->f_op->read) 37 return vfs_iter_read(cfi->cfi_container, to, &iocb->ki_pos);
40 return -EINVAL;
41
42 return host_file->f_op->read(host_file, buf, count, ppos);
43} 38}
44 39
45static ssize_t 40static ssize_t
@@ -64,32 +59,25 @@ coda_file_splice_read(struct file *coda_file, loff_t *ppos,
64} 59}
65 60
66static ssize_t 61static ssize_t
67coda_file_write(struct file *coda_file, const char __user *buf, size_t count, loff_t *ppos) 62coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to)
68{ 63{
69 struct inode *host_inode, *coda_inode = file_inode(coda_file); 64 struct file *coda_file = iocb->ki_filp;
70 struct coda_file_info *cfi; 65 struct inode *coda_inode = file_inode(coda_file);
66 struct coda_file_info *cfi = CODA_FTOC(coda_file);
71 struct file *host_file; 67 struct file *host_file;
72 ssize_t ret; 68 ssize_t ret;
73 69
74 cfi = CODA_FTOC(coda_file);
75 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 70 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
76 host_file = cfi->cfi_container;
77
78 if (!host_file->f_op->write)
79 return -EINVAL;
80 71
81 host_inode = file_inode(host_file); 72 host_file = cfi->cfi_container;
82 file_start_write(host_file); 73 file_start_write(host_file);
83 mutex_lock(&coda_inode->i_mutex); 74 mutex_lock(&coda_inode->i_mutex);
84 75 ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos);
85 ret = host_file->f_op->write(host_file, buf, count, ppos); 76 coda_inode->i_size = file_inode(host_file)->i_size;
86
87 coda_inode->i_size = host_inode->i_size;
88 coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9; 77 coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
89 coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC; 78 coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC;
90 mutex_unlock(&coda_inode->i_mutex); 79 mutex_unlock(&coda_inode->i_mutex);
91 file_end_write(host_file); 80 file_end_write(host_file);
92
93 return ret; 81 return ret;
94} 82}
95 83
@@ -231,8 +219,10 @@ int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync)
231 219
232const struct file_operations coda_file_operations = { 220const struct file_operations coda_file_operations = {
233 .llseek = generic_file_llseek, 221 .llseek = generic_file_llseek,
234 .read = coda_file_read, 222 .read = new_sync_read,
235 .write = coda_file_write, 223 .write = new_sync_write,
224 .read_iter = coda_file_read_iter,
225 .write_iter = coda_file_write_iter,
236 .mmap = coda_file_mmap, 226 .mmap = coda_file_mmap,
237 .open = coda_open, 227 .open = coda_open,
238 .release = coda_release, 228 .release = coda_release,