diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-02-04 16:17:45 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-02-20 04:56:28 -0500 |
commit | a457ac28543cfa5101222b5ef90329c36611107c (patch) | |
tree | edeb9abe7bd6cf7610693cfa2cab3c215e12c467 | |
parent | db671a8ecd764baf76a698b8366603a147880734 (diff) |
hypfs: switch to read_iter/write_iter
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | arch/s390/hypfs/inode.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 4c8008dd938e..67a0014ddb63 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c | |||
@@ -144,36 +144,32 @@ static int hypfs_open(struct inode *inode, struct file *filp) | |||
144 | return nonseekable_open(inode, filp); | 144 | return nonseekable_open(inode, filp); |
145 | } | 145 | } |
146 | 146 | ||
147 | static ssize_t hypfs_aio_read(struct kiocb *iocb, const struct iovec *iov, | 147 | static ssize_t hypfs_read_iter(struct kiocb *iocb, struct iov_iter *to) |
148 | unsigned long nr_segs, loff_t offset) | ||
149 | { | 148 | { |
150 | char *data; | 149 | struct file *file = iocb->ki_filp; |
151 | ssize_t ret; | 150 | char *data = file->private_data; |
152 | struct file *filp = iocb->ki_filp; | 151 | size_t available = strlen(data); |
153 | /* XXX: temporary */ | 152 | loff_t pos = iocb->ki_pos; |
154 | char __user *buf = iov[0].iov_base; | 153 | size_t count; |
155 | size_t count = iov[0].iov_len; | ||
156 | |||
157 | if (nr_segs != 1) | ||
158 | return -EINVAL; | ||
159 | |||
160 | data = filp->private_data; | ||
161 | ret = simple_read_from_buffer(buf, count, &offset, data, strlen(data)); | ||
162 | if (ret <= 0) | ||
163 | return ret; | ||
164 | 154 | ||
165 | iocb->ki_pos += ret; | 155 | if (pos < 0) |
166 | file_accessed(filp); | 156 | return -EINVAL; |
167 | 157 | if (pos >= available || !iov_iter_count(to)) | |
168 | return ret; | 158 | return 0; |
159 | count = copy_to_iter(data + pos, available - pos, to); | ||
160 | if (!count) | ||
161 | return -EFAULT; | ||
162 | iocb->ki_pos = pos + count; | ||
163 | file_accessed(file); | ||
164 | return count; | ||
169 | } | 165 | } |
170 | static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov, | 166 | |
171 | unsigned long nr_segs, loff_t offset) | 167 | static ssize_t hypfs_write_iter(struct kiocb *iocb, struct iov_iter *from) |
172 | { | 168 | { |
173 | int rc; | 169 | int rc; |
174 | struct super_block *sb = file_inode(iocb->ki_filp)->i_sb; | 170 | struct super_block *sb = file_inode(iocb->ki_filp)->i_sb; |
175 | struct hypfs_sb_info *fs_info = sb->s_fs_info; | 171 | struct hypfs_sb_info *fs_info = sb->s_fs_info; |
176 | size_t count = iov_length(iov, nr_segs); | 172 | size_t count = iov_iter_count(from); |
177 | 173 | ||
178 | /* | 174 | /* |
179 | * Currently we only allow one update per second for two reasons: | 175 | * Currently we only allow one update per second for two reasons: |
@@ -202,6 +198,7 @@ static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
202 | } | 198 | } |
203 | hypfs_update_update(sb); | 199 | hypfs_update_update(sb); |
204 | rc = count; | 200 | rc = count; |
201 | iov_iter_advance(from, count); | ||
205 | out: | 202 | out: |
206 | mutex_unlock(&fs_info->lock); | 203 | mutex_unlock(&fs_info->lock); |
207 | return rc; | 204 | return rc; |
@@ -440,10 +437,10 @@ struct dentry *hypfs_create_str(struct dentry *dir, | |||
440 | static const struct file_operations hypfs_file_ops = { | 437 | static const struct file_operations hypfs_file_ops = { |
441 | .open = hypfs_open, | 438 | .open = hypfs_open, |
442 | .release = hypfs_release, | 439 | .release = hypfs_release, |
443 | .read = do_sync_read, | 440 | .read = new_sync_read, |
444 | .write = do_sync_write, | 441 | .write = new_sync_write, |
445 | .aio_read = hypfs_aio_read, | 442 | .read_iter = hypfs_read_iter, |
446 | .aio_write = hypfs_aio_write, | 443 | .write_iter = hypfs_write_iter, |
447 | .llseek = no_llseek, | 444 | .llseek = no_llseek, |
448 | }; | 445 | }; |
449 | 446 | ||