History

io_uring/rw: mark readv/writev as vectored in the opcode definition

This is cleaner than gating on the opcode type, particularly as more read/write type opcodes may be added. Then we can use that for the data import, and for __io_read() on whether or not we need to copy state.

Jens Axboe committed 3 years ago

Commit d2d778f1 parent a08d1953 files · +10 −4Browse files

Unified · Split

3 files
  1. io_uring/opdef.c +2 −0
  2. io_uring/opdef.h +2 −0
  3. io_uring/rw.c +6 −4
io_uring/opdef.c+2−0
@@ -63,6 +63,7 @@ const struct io_issue_def io_issue_defs[] = { · 62 unmodified lines
6363 .ioprio = 1,
6464 .iopoll = 1,
6565 .iopoll_queue = 1,
66+ .vectored = 1,
6667 .prep = io_prep_rw,
6768 .issue = io_read,
6869 },
@@ -76,6 +77,7 @@ const struct io_issue_def io_issue_defs[] = { · 7 unmodified lines
7677 .ioprio = 1,
7778 .iopoll = 1,
7879 .iopoll_queue = 1,
80+ .vectored = 1,
7981 .prep = io_prep_rw,
8082 .issue = io_write,
8183 },
io_uring/opdef.h+2−0
@@ -29,6 +29,8 @@ struct io_issue_def { · 28 unmodified lines
2929 unsigned iopoll_queue : 1;
3030 /* opcode specific path will handle ->async_data allocation if needed */
3131 unsigned manual_alloc : 1;
32+ /* vectored opcode, set if 1) vectored, and 2) handler needs to know */
33+ unsigned vectored : 1;
3234
3335 int (*issue)(struct io_kiocb *, unsigned int);
3436 int (*prep)(struct io_kiocb *, const struct io_uring_sqe *);
io_uring/rw.c+6−4
@@ -388,8 +388,7 @@ static struct iovec *__io_import_iovec(int ddir, struct io_kiocb *req, · 387 unmodified lines
388388 buf = u64_to_user_ptr(rw->addr);
389389 sqe_len = rw->len;
390390
391− if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE ||
392− (req->flags & REQ_F_BUFFER_SELECT)) {
391+ if (!io_issue_defs[opcode].vectored || req->flags & REQ_F_BUFFER_SELECT) {
393392 if (io_do_buffer_select(req)) {
394393 buf = io_buffer_select(req, &sqe_len, issue_flags);
395394 if (!buf)
@@ -776,8 +775,11 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags) · 380 unmodified lines
776775
777776 if (ret == -EAGAIN || (req->flags & REQ_F_REISSUE)) {
778777 req->flags &= ~REQ_F_REISSUE;
779− /* if we can poll, just do that */
780− if (req->opcode == IORING_OP_READ && file_can_poll(req->file))
778+ /*
779+ * If we can poll, just do that. For a vectored read, we'll
780+ * need to copy state first.
781+ */
782+ if (file_can_poll(req->file) && !io_issue_defs[req->opcode].vectored)
781783 return -EAGAIN;
782784 /* IOPOLL retry should happen for io-wq threads */
783785 if (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t