diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-01 22:32:23 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-11 22:28:26 -0400 |
commit | 9565a5445240cd441f2c670aa7260ee8eb5dff79 (patch) | |
tree | 4449d982f9476fae8bff8ee9f78c673508b42a4e /fs/9p | |
parent | c711a6b111322941a41bb024dbcc22b9858d5dd6 (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')
-rw-r--r-- | fs/9p/vfs_addr.c | 24 | ||||
-rw-r--r-- | fs/9p/vfs_file.c | 75 |
2 files changed, 17 insertions, 82 deletions
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c index 0e153f07e0fc..402269c108cd 100644 --- a/fs/9p/vfs_addr.c +++ b/fs/9p/vfs_addr.c | |||
@@ -252,15 +252,21 @@ static int v9fs_launder_page(struct page *page) | |||
252 | static ssize_t | 252 | static ssize_t |
253 | v9fs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos) | 253 | v9fs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos) |
254 | { | 254 | { |
255 | /* | 255 | struct file *file = iocb->ki_filp; |
256 | * FIXME | 256 | if (rw == WRITE) { |
257 | * Now that we do caching with cache mode enabled, We need | 257 | ssize_t written; |
258 | * to support direct IO | 258 | int err = 0; |
259 | */ | 259 | |
260 | p9_debug(P9_DEBUG_VFS, "v9fs_direct_IO: v9fs_direct_IO (%pD) off/no(%lld/%lu) EINVAL\n", | 260 | written = p9_client_write(file->private_data, pos, iter, &err); |
261 | iocb->ki_filp, | 261 | if (written) { |
262 | (long long)pos, iter->nr_segs); | 262 | struct inode *inode = file_inode(file); |
263 | 263 | loff_t i_size = i_size_read(inode); | |
264 | if (pos + written > i_size) | ||
265 | inode_add_bytes(inode, pos + written - i_size); | ||
266 | return written; | ||
267 | } | ||
268 | return err; | ||
269 | } | ||
264 | return -EINVAL; | 270 | return -EINVAL; |
265 | } | 271 | } |
266 | 272 | ||
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 | ||
691 | static ssize_t | ||
692 | v9fs_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); | ||
734 | err_out: | ||
735 | mutex_unlock(&inode->i_mutex); | ||
736 | return retval; | ||
737 | |||
738 | buff_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 | */ | ||
751 | static ssize_t | ||
752 | v9fs_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 = { | |||
821 | const struct file_operations v9fs_cached_file_operations = { | 750 | const 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 = { | |||
834 | const struct file_operations v9fs_cached_file_operations_dotl = { | 763 | const 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, |