[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-78-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:13:37 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 077/437] relay: convert to read/write iterators
Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
kernel/relay.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/kernel/relay.c b/kernel/relay.c
index a8e90e98bf2c..d34f5b0e4e53 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1030,12 +1030,10 @@ static size_t relay_file_read_end_pos(struct rchan_buf *buf,
return end_pos;
}
-static ssize_t relay_file_read(struct file *filp,
- char __user *buffer,
- size_t count,
- loff_t *ppos)
+static ssize_t relay_file_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct rchan_buf *buf = filp->private_data;
+ struct rchan_buf *buf = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(to);
size_t read_start, avail;
size_t written = 0;
int ret;
@@ -1043,7 +1041,7 @@ static ssize_t relay_file_read(struct file *filp,
if (!count)
return 0;
- inode_lock(file_inode(filp));
+ inode_lock(file_inode(iocb->ki_filp));
do {
void *from;
@@ -1058,27 +1056,25 @@ static ssize_t relay_file_read(struct file *filp,
avail = min(count, avail);
from = buf->start + read_start;
ret = avail;
- if (copy_to_user(buffer, from, avail))
+ if (!copy_to_iter_full(from, avail, to))
break;
- buffer += ret;
written += ret;
count -= ret;
relay_file_read_consume(buf, read_start, ret);
- *ppos = relay_file_read_end_pos(buf, read_start, ret);
+ iocb->ki_pos = relay_file_read_end_pos(buf, read_start, ret);
} while (count);
- inode_unlock(file_inode(filp));
+ inode_unlock(file_inode(iocb->ki_filp));
return written;
}
-
const struct file_operations relay_file_operations = {
.open = relay_file_open,
.poll = relay_file_poll,
.mmap = relay_file_mmap,
- .read = relay_file_read,
+ .read_iter = relay_file_read,
.llseek = no_llseek,
.release = relay_file_release,
};
--
2.43.0
Powered by blists - more mailing lists