Commit a457ac28543cfa5101222b5ef90329c36611107c
1 parent
db671a8ecd
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
hypfs: switch to read_iter/write_iter
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 1 changed file with 24 additions and 27 deletions Side-by-side Diff
arch/s390/hypfs/inode.c
... | ... | @@ -144,36 +144,32 @@ |
144 | 144 | return nonseekable_open(inode, filp); |
145 | 145 | } |
146 | 146 | |
147 | -static ssize_t hypfs_aio_read(struct kiocb *iocb, const struct iovec *iov, | |
148 | - unsigned long nr_segs, loff_t offset) | |
147 | +static ssize_t hypfs_read_iter(struct kiocb *iocb, struct iov_iter *to) | |
149 | 148 | { |
150 | - char *data; | |
151 | - ssize_t ret; | |
152 | - struct file *filp = iocb->ki_filp; | |
153 | - /* XXX: temporary */ | |
154 | - char __user *buf = iov[0].iov_base; | |
155 | - size_t count = iov[0].iov_len; | |
149 | + struct file *file = iocb->ki_filp; | |
150 | + char *data = file->private_data; | |
151 | + size_t available = strlen(data); | |
152 | + loff_t pos = iocb->ki_pos; | |
153 | + size_t count; | |
156 | 154 | |
157 | - if (nr_segs != 1) | |
155 | + if (pos < 0) | |
158 | 156 | 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 | - | |
165 | - iocb->ki_pos += ret; | |
166 | - file_accessed(filp); | |
167 | - | |
168 | - return ret; | |
157 | + if (pos >= available || !iov_iter_count(to)) | |
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, | |
171 | - unsigned long nr_segs, loff_t offset) | |
166 | + | |
167 | +static ssize_t hypfs_write_iter(struct kiocb *iocb, struct iov_iter *from) | |
172 | 168 | { |
173 | 169 | int rc; |
174 | 170 | struct super_block *sb = file_inode(iocb->ki_filp)->i_sb; |
175 | 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 | 175 | * Currently we only allow one update per second for two reasons: |
... | ... | @@ -202,6 +198,7 @@ |
202 | 198 | } |
203 | 199 | hypfs_update_update(sb); |
204 | 200 | rc = count; |
201 | + iov_iter_advance(from, count); | |
205 | 202 | out: |
206 | 203 | mutex_unlock(&fs_info->lock); |
207 | 204 | return rc; |
... | ... | @@ -440,10 +437,10 @@ |
440 | 437 | static const struct file_operations hypfs_file_ops = { |
441 | 438 | .open = hypfs_open, |
442 | 439 | .release = hypfs_release, |
443 | - .read = do_sync_read, | |
444 | - .write = do_sync_write, | |
445 | - .aio_read = hypfs_aio_read, | |
446 | - .aio_write = hypfs_aio_write, | |
440 | + .read = new_sync_read, | |
441 | + .write = new_sync_write, | |
442 | + .read_iter = hypfs_read_iter, | |
443 | + .write_iter = hypfs_write_iter, | |
447 | 444 | .llseek = no_llseek, |
448 | 445 | }; |
449 | 446 |