[PATCH 100/437] zram: convert to read/write iterators

Jens Axboe posted 437 patches 1 year, 8 months ago
[PATCH 100/437] zram: convert to read/write iterators
Posted by Jens Axboe 1 year, 8 months ago
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/block/zram/zram_drv.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index f0639df6cd18..eac46889b4b2 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -850,13 +850,13 @@ static void zram_debugfs_destroy(void)
 	debugfs_remove_recursive(zram_debugfs_root);
 }
 
-static ssize_t read_block_state(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t read_block_state(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *kbuf;
 	ssize_t index, written = 0;
-	struct zram *zram = file->private_data;
+	struct zram *zram = iocb->ki_filp->private_data;
 	unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
+	size_t count = iov_iter_count(to);
 	struct timespec64 ts;
 
 	kbuf = kvmalloc(count, GFP_KERNEL);
@@ -870,7 +870,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
 		return -EINVAL;
 	}
 
-	for (index = *ppos; index < nr_pages; index++) {
+	for (index = iocb->ki_pos; index < nr_pages; index++) {
 		int copied;
 
 		zram_slot_lock(zram, index);
@@ -898,11 +898,11 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
 		count -= copied;
 next:
 		zram_slot_unlock(zram, index);
-		*ppos += 1;
+		iocb->ki_pos++;
 	}
 
 	up_read(&zram->init_lock);
-	if (copy_to_user(buf, kbuf, written))
+	if (!copy_to_iter(kbuf, written, to))
 		written = -EFAULT;
 	kvfree(kbuf);
 
@@ -911,7 +911,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
 
 static const struct file_operations proc_zram_block_state_op = {
 	.open = simple_open,
-	.read = read_block_state,
+	.read_iter = read_block_state,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0