aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-01 23:49:24 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-11 22:28:27 -0400
commit42b1ab979d92d21ae2ea376e77f33f18973b9581 (patch)
tree89d3d43076a89e2140d025683bae4c058df5eb10
parente1200fe68f20759f359698f8a8dc81d06d1265f5 (diff)
9p: get rid of v9fs_direct_file_read()
do it in ->direct_IO()... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/9p/vfs_addr.c21
-rw-r--r--fs/9p/vfs_file.c42
2 files changed, 12 insertions, 51 deletions
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index afe3225aaf36..2e38f9a5b472 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -251,21 +251,20 @@ static ssize_t
251v9fs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos) 251v9fs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
252{ 252{
253 struct file *file = iocb->ki_filp; 253 struct file *file = iocb->ki_filp;
254 if (rw == WRITE) { 254 ssize_t n;
255 ssize_t written; 255 int err = 0;
256 int err = 0; 256 if (rw & WRITE) {
257 257 n = p9_client_write(file->private_data, pos, iter, &err);
258 written = p9_client_write(file->private_data, pos, iter, &err); 258 if (n) {
259 if (written) {
260 struct inode *inode = file_inode(file); 259 struct inode *inode = file_inode(file);
261 loff_t i_size = i_size_read(inode); 260 loff_t i_size = i_size_read(inode);
262 if (pos + written > i_size) 261 if (pos + n > i_size)
263 inode_add_bytes(inode, pos + written - i_size); 262 inode_add_bytes(inode, pos + n - i_size);
264 return written;
265 } 263 }
266 return err; 264 } else {
265 n = p9_client_read(file->private_data, pos, iter, &err);
267 } 266 }
268 return -EINVAL; 267 return n ? n : err;
269} 268}
270 269
271static int v9fs_write_begin(struct file *filp, struct address_space *mapping, 270static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 069f70d3758f..53a1c85b8a20 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -575,44 +575,6 @@ out_unlock:
575 return VM_FAULT_NOPAGE; 575 return VM_FAULT_NOPAGE;
576} 576}
577 577
578static ssize_t
579v9fs_direct_read(struct file *filp, char __user *udata, size_t count,
580 loff_t *offsetp)
581{
582 loff_t size, offset;
583 struct inode *inode;
584 struct address_space *mapping;
585
586 offset = *offsetp;
587 mapping = filp->f_mapping;
588 inode = mapping->host;
589 if (!count)
590 return 0;
591 size = i_size_read(inode);
592 if (offset < size)
593 filemap_write_and_wait_range(mapping, offset,
594 offset + count - 1);
595
596 return v9fs_file_read(filp, udata, count, offsetp);
597}
598
599/**
600 * v9fs_cached_file_read - read from a file
601 * @filp: file pointer to read
602 * @data: user data buffer to read data into
603 * @count: size of buffer
604 * @offset: offset at which to read data
605 *
606 */
607static ssize_t
608v9fs_cached_file_read(struct file *filp, char __user *data, size_t count,
609 loff_t *offset)
610{
611 if (filp->f_flags & O_DIRECT)
612 return v9fs_direct_read(filp, data, count, offset);
613 return new_sync_read(filp, data, count, offset);
614}
615
616/** 578/**
617 * v9fs_mmap_file_read - read from a file 579 * v9fs_mmap_file_read - read from a file
618 * @filp: file pointer to read 580 * @filp: file pointer to read
@@ -690,7 +652,7 @@ static const struct vm_operations_struct v9fs_mmap_file_vm_ops = {
690 652
691const struct file_operations v9fs_cached_file_operations = { 653const struct file_operations v9fs_cached_file_operations = {
692 .llseek = generic_file_llseek, 654 .llseek = generic_file_llseek,
693 .read = v9fs_cached_file_read, 655 .read = new_sync_read,
694 .write = new_sync_write, 656 .write = new_sync_write,
695 .read_iter = generic_file_read_iter, 657 .read_iter = generic_file_read_iter,
696 .write_iter = generic_file_write_iter, 658 .write_iter = generic_file_write_iter,
@@ -703,7 +665,7 @@ const struct file_operations v9fs_cached_file_operations = {
703 665
704const struct file_operations v9fs_cached_file_operations_dotl = { 666const struct file_operations v9fs_cached_file_operations_dotl = {
705 .llseek = generic_file_llseek, 667 .llseek = generic_file_llseek,
706 .read = v9fs_cached_file_read, 668 .read = new_sync_read,
707 .write = new_sync_write, 669 .write = new_sync_write,
708 .read_iter = generic_file_read_iter, 670 .read_iter = generic_file_read_iter,
709 .write_iter = generic_file_write_iter, 671 .write_iter = generic_file_write_iter,