Re: [PATCH 1/2] io_uring/kbuf: fix not advancing READV kbuf ring

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2022-09-06 at 17:11 +0100, Pavel Begunkov wrote:
> When we don't recycle a selected ring buffer we should advance the
> head
> of the ring, so don't just skip io_kbuf_recycle() for IORING_OP_READV
> but adjust the ring.
> 
> Fixes: 934447a603b22 ("io_uring: do not recycle buffer in READV")
> Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
> ---
>  io_uring/kbuf.h | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/io_uring/kbuf.h b/io_uring/kbuf.h
> index d6af208d109f..746fbf31a703 100644
> --- a/io_uring/kbuf.h
> +++ b/io_uring/kbuf.h
> @@ -91,9 +91,13 @@ static inline void io_kbuf_recycle(struct io_kiocb
> *req, unsigned issue_flags)
>          * buffer data. However if that buffer is recycled the
> original request
>          * data stored in addr is lost. Therefore forbid recycling
> for now.
>          */
> -       if (req->opcode == IORING_OP_READV)
> +       if (req->opcode == IORING_OP_READV) {
> +               if ((req->flags & REQ_F_BUFFER_RING) && req-
> >buf_list) {
> +                       req->buf_list->head++;
> +                       req->buf_list = NULL;
> +               }
>                 return;
> -
> +       }
>         if (req->flags & REQ_F_BUFFER_SELECTED)
>                 io_kbuf_recycle_legacy(req, issue_flags);
>         if (req->flags & REQ_F_BUFFER_RING)


I do not know a good way to test this, but it reads to me likeit is
correct. It should probably be applied before the patch I sent earlier
today to remove this code so that backporting is easier.

Reviewed-by: Dylan Yudaken <dylany@xxxxxx>





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux