summaryrefslogtreecommitdiffstats
path: root/fs/9p/vfs_file.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-09 12:55:47 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-11 22:30:21 -0400
commit3309dd04cbcd2cdad168485af5cf3576b5051e49 (patch)
tree3e01f865306dee01b31f34c9e7e819a5f42a4087 /fs/9p/vfs_file.c
parent90320251db0fe3d05f2b10686ec936c7d6ecd99a (diff)
downloadlinux-3309dd04cbcd2cdad168485af5cf3576b5051e49.tar.bz2
switch generic_write_checks() to iocb and iter
... returning -E... upon error and amount of data left in iter after (possible) truncation upon success. Note, that normal case gives a non-zero (positive) return value, so any tests for != 0 _must_ be updated. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Conflicts: fs/ext4/file.c
Diffstat (limited to 'fs/9p/vfs_file.c')
-rw-r--r--fs/9p/vfs_file.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index b5b020ace1b3..2a9dd37dc426 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -404,21 +404,16 @@ static ssize_t
v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *file = iocb->ki_filp;
- ssize_t retval = 0;
- loff_t origin = iocb->ki_pos;
- size_t count = iov_iter_count(from);
+ ssize_t retval;
+ loff_t origin;
int err = 0;
- retval = generic_write_checks(file, &origin, &count);
- if (retval)
+ retval = generic_write_checks(iocb, from);
+ if (retval <= 0)
return retval;
- iov_iter_truncate(from, count);
-
- if (!count)
- return 0;
-
- retval = p9_client_write(file->private_data, origin, from, &err);
+ origin = iocb->ki_pos;
+ retval = p9_client_write(file->private_data, iocb->ki_pos, from, &err);
if (retval > 0) {
struct inode *inode = file_inode(file);
loff_t i_size;
@@ -428,12 +423,11 @@ v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (inode->i_mapping && inode->i_mapping->nrpages)
invalidate_inode_pages2_range(inode->i_mapping,
pg_start, pg_end);
- origin += retval;
+ iocb->ki_pos += retval;
i_size = i_size_read(inode);
- iocb->ki_pos = origin;
- if (origin > i_size) {
- inode_add_bytes(inode, origin - i_size);
- i_size_write(inode, origin);
+ if (iocb->ki_pos > i_size) {
+ inode_add_bytes(inode, iocb->ki_pos - i_size);
+ i_size_write(inode, iocb->ki_pos);
}
return retval;
}