aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/vfs_file.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-01 22:32:23 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-11 22:28:26 -0400
commit9565a5445240cd441f2c670aa7260ee8eb5dff79 (patch)
tree4449d982f9476fae8bff8ee9f78c673508b42a4e /fs/9p/vfs_file.c
parentc711a6b111322941a41bb024dbcc22b9858d5dd6 (diff)
9p: get rid of v9fs_direct_file_write()
just handle it in ->direct_IO() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/9p/vfs_file.c')
-rw-r--r--fs/9p/vfs_file.c75
1 files changed, 2 insertions, 73 deletions
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index a54d81f9097f..1e4619693721 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -688,77 +688,6 @@ v9fs_mmap_file_read(struct file *filp, char __user *data, size_t count,
688 return v9fs_file_read(filp, data, count, offset); 688 return v9fs_file_read(filp, data, count, offset);
689} 689}
690 690
691static ssize_t
692v9fs_direct_write(struct file *filp, const char __user * data,
693 size_t count, loff_t *offsetp)
694{
695 loff_t offset;
696 ssize_t retval;
697 struct inode *inode;
698 struct address_space *mapping;
699
700 offset = *offsetp;
701 mapping = filp->f_mapping;
702 inode = mapping->host;
703 if (!count)
704 return 0;
705
706 mutex_lock(&inode->i_mutex);
707 retval = filemap_write_and_wait_range(mapping, offset,
708 offset + count - 1);
709 if (retval)
710 goto err_out;
711 /*
712 * After a write we want buffered reads to be sure to go to disk to get
713 * the new data. We invalidate clean cached page from the region we're
714 * about to write. We do this *before* the write so that if we fail
715 * here we fall back to buffered write
716 */
717 if (mapping->nrpages) {
718 pgoff_t pg_start = offset >> PAGE_CACHE_SHIFT;
719 pgoff_t pg_end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
720
721 retval = invalidate_inode_pages2_range(mapping,
722 pg_start, pg_end);
723 /*
724 * If a page can not be invalidated, fall back
725 * to buffered write.
726 */
727 if (retval) {
728 if (retval == -EBUSY)
729 goto buff_write;
730 goto err_out;
731 }
732 }
733 retval = v9fs_file_write(filp, data, count, offsetp);
734err_out:
735 mutex_unlock(&inode->i_mutex);
736 return retval;
737
738buff_write:
739 mutex_unlock(&inode->i_mutex);
740 return new_sync_write(filp, data, count, offsetp);
741}
742
743/**
744 * v9fs_cached_file_write - write to a file
745 * @filp: file pointer to write
746 * @data: data buffer to write data from
747 * @count: size of buffer
748 * @offset: offset at which to write data
749 *
750 */
751static ssize_t
752v9fs_cached_file_write(struct file *filp, const char __user * data,
753 size_t count, loff_t *offset)
754{
755
756 if (filp->f_flags & O_DIRECT)
757 return v9fs_direct_write(filp, data, count, offset);
758 return new_sync_write(filp, data, count, offset);
759}
760
761
762/** 691/**
763 * v9fs_mmap_file_write - write to a file 692 * v9fs_mmap_file_write - write to a file
764 * @filp: file pointer to write 693 * @filp: file pointer to write
@@ -821,7 +750,7 @@ static const struct vm_operations_struct v9fs_mmap_file_vm_ops = {
821const struct file_operations v9fs_cached_file_operations = { 750const struct file_operations v9fs_cached_file_operations = {
822 .llseek = generic_file_llseek, 751 .llseek = generic_file_llseek,
823 .read = v9fs_cached_file_read, 752 .read = v9fs_cached_file_read,
824 .write = v9fs_cached_file_write, 753 .write = new_sync_write,
825 .read_iter = generic_file_read_iter, 754 .read_iter = generic_file_read_iter,
826 .write_iter = generic_file_write_iter, 755 .write_iter = generic_file_write_iter,
827 .open = v9fs_file_open, 756 .open = v9fs_file_open,
@@ -834,7 +763,7 @@ const struct file_operations v9fs_cached_file_operations = {
834const struct file_operations v9fs_cached_file_operations_dotl = { 763const struct file_operations v9fs_cached_file_operations_dotl = {
835 .llseek = generic_file_llseek, 764 .llseek = generic_file_llseek,
836 .read = v9fs_cached_file_read, 765 .read = v9fs_cached_file_read,
837 .write = v9fs_cached_file_write, 766 .write = new_sync_write,
838 .read_iter = generic_file_read_iter, 767 .read_iter = generic_file_read_iter,
839 .write_iter = generic_file_write_iter, 768 .write_iter = generic_file_write_iter,
840 .open = v9fs_file_open, 769 .open = v9fs_file_open,