coda: switch to ->read_iter/->write_iter

... and request the same from the local cache - all filesystems with
anything usable for that support those already.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2015-04-03 10:58:11 -04:00
parent 274a48869b
commit c12c49e702
1 changed files with 15 additions and 25 deletions

View File

@ -27,19 +27,14 @@
#include "coda_int.h" #include "coda_int.h"
static ssize_t static ssize_t
coda_file_read(struct file *coda_file, char __user *buf, size_t count, loff_t *ppos) coda_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
{ {
struct coda_file_info *cfi; struct file *coda_file = iocb->ki_filp;
struct file *host_file; struct coda_file_info *cfi = CODA_FTOC(coda_file);
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
if (!host_file->f_op->read) return vfs_iter_read(cfi->cfi_container, to, &iocb->ki_pos);
return -EINVAL;
return host_file->f_op->read(host_file, buf, count, ppos);
} }
static ssize_t static ssize_t
@ -64,32 +59,25 @@ coda_file_splice_read(struct file *coda_file, loff_t *ppos,
} }
static ssize_t static ssize_t
coda_file_write(struct file *coda_file, const char __user *buf, size_t count, loff_t *ppos) coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to)
{ {
struct inode *host_inode, *coda_inode = file_inode(coda_file); struct file *coda_file = iocb->ki_filp;
struct coda_file_info *cfi; struct inode *coda_inode = file_inode(coda_file);
struct coda_file_info *cfi = CODA_FTOC(coda_file);
struct file *host_file; struct file *host_file;
ssize_t ret; ssize_t ret;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container; host_file = cfi->cfi_container;
if (!host_file->f_op->write)
return -EINVAL;
host_inode = file_inode(host_file);
file_start_write(host_file); file_start_write(host_file);
mutex_lock(&coda_inode->i_mutex); mutex_lock(&coda_inode->i_mutex);
ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos);
ret = host_file->f_op->write(host_file, buf, count, ppos); coda_inode->i_size = file_inode(host_file)->i_size;
coda_inode->i_size = host_inode->i_size;
coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9; coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC; coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC;
mutex_unlock(&coda_inode->i_mutex); mutex_unlock(&coda_inode->i_mutex);
file_end_write(host_file); file_end_write(host_file);
return ret; return ret;
} }
@ -231,8 +219,10 @@ int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync)
const struct file_operations coda_file_operations = { const struct file_operations coda_file_operations = {
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
.read = coda_file_read, .read = new_sync_read,
.write = coda_file_write, .write = new_sync_write,
.read_iter = coda_file_read_iter,
.write_iter = coda_file_write_iter,
.mmap = coda_file_mmap, .mmap = coda_file_mmap,
.open = coda_open, .open = coda_open,
.release = coda_release, .release = coda_release,