Skip to content

Commit

Permalink
io_uring: restore bgid in io_put_kbuf
Browse files Browse the repository at this point in the history
Attempt to restore bgid. This is needed when recycling unused buffers as
the next time around it will want the correct bgid.

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220630091231.1456789-3-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Dylan Yudaken authored and Jens Axboe committed Jul 4, 2022
1 parent 62db83a commit fede7a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions io_uring/kbuf.h
Original file line number Diff line number Diff line change
@@ -96,16 +96,21 @@ static inline void io_kbuf_recycle(struct io_kiocb *req, unsigned issue_flags)
static inline unsigned int __io_put_kbuf_list(struct io_kiocb *req,
struct list_head *list)
{
unsigned int ret = IORING_CQE_F_BUFFER | (req->buf_index << IORING_CQE_BUFFER_SHIFT);

if (req->flags & REQ_F_BUFFER_RING) {
if (req->buf_list)
if (req->buf_list) {
req->buf_index = req->buf_list->bgid;
req->buf_list->head++;
}
req->flags &= ~REQ_F_BUFFER_RING;
} else {
req->buf_index = req->kbuf->bgid;
list_add(&req->kbuf->list, list);
req->flags &= ~REQ_F_BUFFER_SELECTED;
}

return IORING_CQE_F_BUFFER | (req->buf_index << IORING_CQE_BUFFER_SHIFT);
return ret;
}

static inline unsigned int io_put_kbuf_comp(struct io_kiocb *req)

0 comments on commit fede7a7

Please sign in to comment.