]> git.baikalelectronics.ru Git - kernel.git/commit
io_uring: maintain drain logic for multishot poll requests
authorHao Xu <haoxu@linux.alibaba.com>
Tue, 13 Apr 2021 07:20:39 +0000 (15:20 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 27 Apr 2021 13:38:58 +0000 (07:38 -0600)
commit742744748e516fad8056b80bec67a50580dd2064
tree5e9b1321046c439869ba6a328d46806150876945
parent1e418aadb1acf9c35f59104bb3c8afbe2b3a5b49
io_uring: maintain drain logic for multishot poll requests

Now that we have multishot poll requests, one SQE can emit multiple
CQEs. given below example:
    sqe0(multishot poll)-->sqe1-->sqe2(drain req)
sqe2 is designed to issue after sqe0 and sqe1 completed, but since sqe0
is a multishot poll request, sqe2 may be issued after sqe0's event
triggered twice before sqe1 completed. This isn't what users leverage
drain requests for.
Here the solution is to wait for multishot poll requests fully
completed.
To achieve this, we should reconsider the req_need_defer equation, the
original one is:

    all_sqes(excluding dropped ones) == all_cqes(including dropped ones)

This means we issue a drain request when all the previous submitted
SQEs have generated their CQEs.
Now we should consider multishot requests, we deduct all the multishot
CQEs except the cancellation one, In this way a multishot poll request
behave like a normal request, so:
    all_sqes == all_cqes - multishot_cqes(except cancellations)

Here we introduce cq_extra for it.

Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
Link: https://lore.kernel.org/r/1618298439-136286-1-git-send-email-haoxu@linux.alibaba.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c