io_uring: have submission side sqe errors post a cqe
authorJens Axboe <axboe@kernel.dk>
Tue, 30 Apr 2019 16:16:07 +0000 (10:16 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 1 May 2019 12:37:55 +0000 (06:37 -0600)
commit5c8b0b54db22c54f2aec991b388f550d3a927f26
tree9e012f2f727a1f404da99b81424deced0cf4fa68
parent62977281a6384d3904c02272a638cc3ac3bac54d
io_uring: have submission side sqe errors post a cqe

Currently we only post a cqe if we get an error OUTSIDE of submission.
For submission, we return the error directly through io_uring_enter().
This is a bit awkward for applications, and it makes more sense to
always post a cqe with an error, if the error happens on behalf of an
sqe.

This changes submission behavior a bit. io_uring_enter() returns -ERROR
for an error, and > 0 for number of sqes submitted. Before this change,
if you wanted to submit 8 entries and had an error on the 5th entry,
io_uring_enter() would return 4 (for number of entries successfully
submitted) and rewind the sqring. The application would then have to
peek at the sqring and figure out what was wrong with the head sqe, and
then skip it itself. With this change, we'll return 5 since we did
consume 5 sqes, and the last sqe (with the error) will result in a cqe
being posted with the error.

This makes the logic easier to handle in the application, and it cleans
up the submission part.

Suggested-by: Stefan Bühler <source@stbuehler.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c