Skip to content

Commit 186daf2

Browse files
committed
io_uring/kbuf: rename REQ_F_PARTIAL_IO to REQ_F_BL_NO_RECYCLE
We only use the flag for this purpose, so rename it accordingly. This further prevents various other use cases of it, keeping it clean and consistent. Then we can also check it in one spot, when it's being attempted recycled, and remove some dead code in io_kbuf_recycle_ring(). Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9817ad8 commit 186daf2

File tree

5 files changed

+16
-35
lines changed

5 files changed

+16
-35
lines changed

include/linux/io_uring_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ enum {
470470
REQ_F_SKIP_LINK_CQES_BIT,
471471
REQ_F_SINGLE_POLL_BIT,
472472
REQ_F_DOUBLE_POLL_BIT,
473-
REQ_F_PARTIAL_IO_BIT,
474473
REQ_F_APOLL_MULTISHOT_BIT,
475474
REQ_F_CLEAR_POLLIN_BIT,
476475
REQ_F_HASH_LOCKED_BIT,
@@ -481,6 +480,7 @@ enum {
481480
REQ_F_CANCEL_SEQ_BIT,
482481
REQ_F_CAN_POLL_BIT,
483482
REQ_F_BL_EMPTY_BIT,
483+
REQ_F_BL_NO_RECYCLE_BIT,
484484

485485
/* not a real bit, just to check we're not overflowing the space */
486486
__REQ_F_LAST_BIT,
@@ -543,8 +543,6 @@ enum {
543543
REQ_F_SINGLE_POLL = IO_REQ_FLAG(REQ_F_SINGLE_POLL_BIT),
544544
/* double poll may active */
545545
REQ_F_DOUBLE_POLL = IO_REQ_FLAG(REQ_F_DOUBLE_POLL_BIT),
546-
/* request has already done partial IO */
547-
REQ_F_PARTIAL_IO = IO_REQ_FLAG(REQ_F_PARTIAL_IO_BIT),
548546
/* fast poll multishot mode */
549547
REQ_F_APOLL_MULTISHOT = IO_REQ_FLAG(REQ_F_APOLL_MULTISHOT_BIT),
550548
/* recvmsg special flag, clear EPOLLIN */
@@ -559,6 +557,8 @@ enum {
559557
REQ_F_CAN_POLL = IO_REQ_FLAG(REQ_F_CAN_POLL_BIT),
560558
/* buffer list was empty after selection of buffer */
561559
REQ_F_BL_EMPTY = IO_REQ_FLAG(REQ_F_BL_EMPTY_BIT),
560+
/* don't recycle provided buffers for this request */
561+
REQ_F_BL_NO_RECYCLE = IO_REQ_FLAG(REQ_F_BL_NO_RECYCLE_BIT),
562562
};
563563

564564
typedef void (*io_req_tw_func_t)(struct io_kiocb *req, struct io_tw_state *ts);

io_uring/kbuf.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ bool io_kbuf_recycle_legacy(struct io_kiocb *req, unsigned issue_flags)
8181
struct io_buffer_list *bl;
8282
struct io_buffer *buf;
8383

84-
/*
85-
* For legacy provided buffer mode, don't recycle if we already did
86-
* IO to this buffer. For ring-mapped provided buffer mode, we should
87-
* increment ring->head to explicitly monopolize the buffer to avoid
88-
* multiple use.
89-
*/
90-
if (req->flags & REQ_F_PARTIAL_IO)
91-
return false;
92-
9384
io_ring_submit_lock(ctx, issue_flags);
9485

9586
buf = req->kbuf;

io_uring/kbuf.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,9 @@ static inline bool io_kbuf_recycle_ring(struct io_kiocb *req)
7373
* to monopolize the buffer.
7474
*/
7575
if (req->buf_list) {
76-
if (req->flags & REQ_F_PARTIAL_IO) {
77-
/*
78-
* If we end up here, then the io_uring_lock has
79-
* been kept held since we retrieved the buffer.
80-
* For the io-wq case, we already cleared
81-
* req->buf_list when the buffer was retrieved,
82-
* hence it cannot be set here for that case.
83-
*/
84-
req->buf_list->head++;
85-
req->buf_list = NULL;
86-
} else {
87-
req->buf_index = req->buf_list->bgid;
88-
req->flags &= ~REQ_F_BUFFER_RING;
89-
return true;
90-
}
76+
req->buf_index = req->buf_list->bgid;
77+
req->flags &= ~REQ_F_BUFFER_RING;
78+
return true;
9179
}
9280
return false;
9381
}
@@ -101,6 +89,8 @@ static inline bool io_do_buffer_select(struct io_kiocb *req)
10189

10290
static inline bool io_kbuf_recycle(struct io_kiocb *req, unsigned issue_flags)
10391
{
92+
if (req->flags & REQ_F_BL_NO_RECYCLE)
93+
return false;
10494
if (req->flags & REQ_F_BUFFER_SELECTED)
10595
return io_kbuf_recycle_legacy(req, issue_flags);
10696
if (req->flags & REQ_F_BUFFER_RING)

io_uring/net.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
456456
kmsg->msg.msg_controllen = 0;
457457
kmsg->msg.msg_control = NULL;
458458
sr->done_io += ret;
459-
req->flags |= REQ_F_PARTIAL_IO;
459+
req->flags |= REQ_F_BL_NO_RECYCLE;
460460
return io_setup_async_msg(req, kmsg, issue_flags);
461461
}
462462
if (ret == -ERESTARTSYS)
@@ -535,7 +535,7 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
535535
sr->len -= ret;
536536
sr->buf += ret;
537537
sr->done_io += ret;
538-
req->flags |= REQ_F_PARTIAL_IO;
538+
req->flags |= REQ_F_BL_NO_RECYCLE;
539539
return io_setup_async_addr(req, &__address, issue_flags);
540540
}
541541
if (ret == -ERESTARTSYS)
@@ -907,7 +907,7 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
907907
}
908908
if (ret > 0 && io_net_retry(sock, flags)) {
909909
sr->done_io += ret;
910-
req->flags |= REQ_F_PARTIAL_IO;
910+
req->flags |= REQ_F_BL_NO_RECYCLE;
911911
return io_setup_async_msg(req, kmsg, issue_flags);
912912
}
913913
if (ret == -ERESTARTSYS)
@@ -1007,7 +1007,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
10071007
sr->len -= ret;
10081008
sr->buf += ret;
10091009
sr->done_io += ret;
1010-
req->flags |= REQ_F_PARTIAL_IO;
1010+
req->flags |= REQ_F_BL_NO_RECYCLE;
10111011
return -EAGAIN;
10121012
}
10131013
if (ret == -ERESTARTSYS)
@@ -1250,7 +1250,7 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
12501250
zc->len -= ret;
12511251
zc->buf += ret;
12521252
zc->done_io += ret;
1253-
req->flags |= REQ_F_PARTIAL_IO;
1253+
req->flags |= REQ_F_BL_NO_RECYCLE;
12541254
return io_setup_async_addr(req, &__address, issue_flags);
12551255
}
12561256
if (ret == -ERESTARTSYS)
@@ -1320,7 +1320,7 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
13201320

13211321
if (ret > 0 && io_net_retry(sock, flags)) {
13221322
sr->done_io += ret;
1323-
req->flags |= REQ_F_PARTIAL_IO;
1323+
req->flags |= REQ_F_BL_NO_RECYCLE;
13241324
return io_setup_async_msg(req, kmsg, issue_flags);
13251325
}
13261326
if (ret == -ERESTARTSYS)

io_uring/rw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static bool __io_complete_rw_common(struct io_kiocb *req, long res)
275275
* current cycle.
276276
*/
277277
io_req_io_end(req);
278-
req->flags |= REQ_F_REISSUE | REQ_F_PARTIAL_IO;
278+
req->flags |= REQ_F_REISSUE | REQ_F_BL_NO_RECYCLE;
279279
return true;
280280
}
281281
req_set_fail(req);
@@ -342,7 +342,7 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res)
342342
io_req_end_write(req);
343343
if (unlikely(res != req->cqe.res)) {
344344
if (res == -EAGAIN && io_rw_should_reissue(req)) {
345-
req->flags |= REQ_F_REISSUE | REQ_F_PARTIAL_IO;
345+
req->flags |= REQ_F_REISSUE | REQ_F_BL_NO_RECYCLE;
346346
return;
347347
}
348348
req->cqe.res = res;

0 commit comments

Comments
 (0)