io_uring: enforce limit of inflight IO for-5.5/io_uring-test
authorJens Axboe <axboe@kernel.dk>
Fri, 8 Nov 2019 22:28:03 +0000 (15:28 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 11 Nov 2019 23:34:41 +0000 (16:34 -0700)
commita21ce1235cc3118be40e6c4966f40ffeb2442f45
tree2e54bd646457fd378a9f6998f2d0ebca87f4159c
parent76a46e066e2d93bd333599d1c84c605c2c4cc909
io_uring: enforce limit of inflight IO

With unbounded request times, we can potentially have a lot of IO
inflight. As we provide no real backpressure unless
IORING_SETUP_CQ_NODROP is set, and even there there's quite some delay
between overflows and backpressure being applied, let's put some safety
in place to avoid going way overboard.

This limits the maximum number of inflight IO for any given io_ring_ctx
to twice the CQ ring size. This is a losely managed limit, we only check
for every SQ ring size number of events. That should be good enough to
achieve our goal, which is to prevent massively deep queues. If these
are async requests, they would just be waiting for an execution slot
anyway.

We return -EBUSY if we can't queue anymore IO. The caller should reap
some completions and retry the operation after that. Note that this is
a "should never hit this" kind of condition, as driving the depth into
CQ overflow situations is unreliable.

Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c