summaryrefslogtreecommitdiff
path: root/io_uring/rw.c
diff options
context:
space:
mode:
authorKeith Busch <kbusch@kernel.org>2025-02-27 14:39:14 -0800
committerJens Axboe <axboe@kernel.dk>2025-02-28 07:05:36 -0700
commit27cb27b6d5ea401143ca3648983342bb820c4be9 (patch)
tree57e120597af207b8d4d83502d0f6353d3ab6bd34 /io_uring/rw.c
parent99fde895ff56ac2241e7b7b4566731d72f2fdaa7 (diff)
downloadlinux-27cb27b6d5ea401143ca3648983342bb820c4be9.tar.gz
linux-27cb27b6d5ea401143ca3648983342bb820c4be9.tar.bz2
linux-27cb27b6d5ea401143ca3648983342bb820c4be9.zip
io_uring: add support for kernel registered bvecs
Provide an interface for the kernel to leverage the existing pre-registered buffers that io_uring provides. User space can reference these later to achieve zero-copy IO. User space must register an empty fixed buffer table with io_uring in order for the kernel to make use of it. Signed-off-by: Keith Busch <kbusch@kernel.org> Link: https://lore.kernel.org/r/20250227223916.143006-5-kbusch@meta.com Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rw.c')
-rw-r--r--io_uring/rw.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 7bc23802a388..5ee9f8949e8b 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -629,6 +629,7 @@ static inline loff_t *io_kiocb_ppos(struct kiocb *kiocb)
*/
static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter)
{
+ struct io_kiocb *req = cmd_to_io_kiocb(rw);
struct kiocb *kiocb = &rw->kiocb;
struct file *file = kiocb->ki_filp;
ssize_t ret = 0;
@@ -644,6 +645,8 @@ static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter)
if ((kiocb->ki_flags & IOCB_NOWAIT) &&
!(kiocb->ki_filp->f_flags & O_NONBLOCK))
return -EAGAIN;
+ if ((req->flags & REQ_F_BUF_NODE) && req->buf_node->buf->is_kbuf)
+ return -EFAULT;
ppos = io_kiocb_ppos(kiocb);