Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/zctx: move vec regbuf import into io_send_zc_import

Unify send and sendmsg zerocopy paths for importing registered buffers
and make io_send_zc_import() responsible for that. It's a preparation
patch making the next change simpler.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
2f9965f5 c279fcd9

+25 -16
+25 -16
io_uring/net.c
··· 1441 1441 return ret; 1442 1442 } 1443 1443 1444 - static int io_send_zc_import(struct io_kiocb *req, unsigned int issue_flags) 1444 + static int io_send_zc_import(struct io_kiocb *req, 1445 + struct io_async_msghdr *kmsg, 1446 + unsigned int issue_flags) 1445 1447 { 1446 1448 struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg); 1447 - struct io_async_msghdr *kmsg = req->async_data; 1449 + struct io_kiocb *notif = sr->notif; 1450 + int ret; 1448 1451 1449 1452 WARN_ON_ONCE(!(sr->flags & IORING_RECVSEND_FIXED_BUF)); 1450 1453 1451 - sr->notif->buf_index = req->buf_index; 1452 - return io_import_reg_buf(sr->notif, &kmsg->msg.msg_iter, 1453 - (u64)(uintptr_t)sr->buf, sr->len, 1454 - ITER_SOURCE, issue_flags); 1454 + notif->buf_index = req->buf_index; 1455 + 1456 + if (req->opcode == IORING_OP_SEND_ZC) { 1457 + ret = io_import_reg_buf(notif, &kmsg->msg.msg_iter, 1458 + (u64)(uintptr_t)sr->buf, sr->len, 1459 + ITER_SOURCE, issue_flags); 1460 + } else { 1461 + unsigned uvec_segs = kmsg->msg.msg_iter.nr_segs; 1462 + 1463 + ret = io_import_reg_vec(ITER_SOURCE, &kmsg->msg.msg_iter, 1464 + notif, &kmsg->vec, uvec_segs, 1465 + issue_flags); 1466 + } 1467 + 1468 + if (unlikely(ret)) 1469 + return ret; 1470 + req->flags &= ~REQ_F_IMPORT_BUFFER; 1471 + return 0; 1455 1472 } 1456 1473 1457 1474 int io_send_zc(struct io_kiocb *req, unsigned int issue_flags) ··· 1490 1473 return -EAGAIN; 1491 1474 1492 1475 if (req->flags & REQ_F_IMPORT_BUFFER) { 1493 - req->flags &= ~REQ_F_IMPORT_BUFFER; 1494 - ret = io_send_zc_import(req, issue_flags); 1476 + ret = io_send_zc_import(req, kmsg, issue_flags); 1495 1477 if (unlikely(ret)) 1496 1478 return ret; 1497 1479 } ··· 1546 1530 int ret, min_ret = 0; 1547 1531 1548 1532 if (req->flags & REQ_F_IMPORT_BUFFER) { 1549 - unsigned uvec_segs = kmsg->msg.msg_iter.nr_segs; 1550 - int ret; 1551 - 1552 - sr->notif->buf_index = req->buf_index; 1553 - ret = io_import_reg_vec(ITER_SOURCE, &kmsg->msg.msg_iter, 1554 - sr->notif, &kmsg->vec, uvec_segs, 1555 - issue_flags); 1533 + ret = io_send_zc_import(req, kmsg, issue_flags); 1556 1534 if (unlikely(ret)) 1557 1535 return ret; 1558 - req->flags &= ~REQ_F_IMPORT_BUFFER; 1559 1536 } 1560 1537 1561 1538 sock = sock_from_file(req->file);