From e7b96331703e929e75d93c574573c9736e34b0c0 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 25 May 2023 12:09:51 +0200 Subject: [PATCH] linux: fs_read to use io_uring if iovcnt > IOV_MAX (#4023) Just cap it to `IOV_MAX` as it's already done when performing reads using the threadpool. --- src/unix/linux.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/unix/linux.c b/src/unix/linux.c index 183e781b..77dac84b 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -914,10 +914,14 @@ int uv__iou_fs_read_or_write(uv_loop_t* loop, struct uv__io_uring_sqe* sqe; struct uv__iou* iou; - /* For the moment, if iovcnt is greater than IOV_MAX, fallback to the - * threadpool. In the future we might take advantage of IOSQE_IO_LINK. */ - if (req->nbufs > IOV_MAX) - return 0; + /* If iovcnt is greater than IOV_MAX, cap it to IOV_MAX on reads and fallback + * to the threadpool on writes */ + if (req->nbufs > IOV_MAX) { + if (is_read) + req->nbufs = IOV_MAX; + else + return 0; + } iou = &uv__get_internal_fields(loop)->iou;