History

io_uring: allow submissions to continue on error

By default, io_uring will stop submitting a batch of requests if we run into an error submitting a request. This isn't strictly necessary, as the error result is passed out-of-band via a CQE anyway. And it can be a bit confusing for some applications. Provide a way to setup a ring that will continue submitting on error, when the error CQE has been posted. There's still one case that will break out of submission. If we fail allocating a request, then we'll still return -ENOMEM. We could in theory post a CQE for that condition too even if we never got a request. Leave that for a potential followup.

Jens Axboe committed 4 years ago

Commit bcbb7bf1 parent b1c62642 files · +10 −3Browse files

Unified · Split

2 files
  1. fs/io_uring.c +9 −3
  2. include/uapi/linux/io_uring.h +1 −0
fs/io_uring.c+9−3
@@ -7801,8 +7801,14 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr) · 7800 unmodified lines
7801 }7801 }
7802 /* will complete beyond this point, count as submitted */7802 /* will complete beyond this point, count as submitted */
7803 submitted++;7803 submitted++;
7804 if (io_submit_sqe(ctx, req, sqe))7804 if (io_submit_sqe(ctx, req, sqe)) {
7805 break;7805 /*
7806 * Continue submitting even for sqe failure if the
7807 * ring was setup with IORING_SETUP_SUBMIT_ALL
7808 */
7809 if (!(ctx->flags & IORING_SETUP_SUBMIT_ALL))
7810 break;
7811 }
7806 } while (submitted < nr);7812 } while (submitted < nr);
7807 7813
7808 if (unlikely(submitted != nr)) {7814 if (unlikely(submitted != nr)) {
@@ -11265,7 +11271,7 @@ static long io_uring_setup(u32 entries, struct io_uring_params __user *params) · 3456 unmodified lines
11265 if (p.flags & ~(IORING_SETUP_IOPOLL | IORING_SETUP_SQPOLL |11271 if (p.flags & ~(IORING_SETUP_IOPOLL | IORING_SETUP_SQPOLL |
11266 IORING_SETUP_SQ_AFF | IORING_SETUP_CQSIZE |11272 IORING_SETUP_SQ_AFF | IORING_SETUP_CQSIZE |
11267 IORING_SETUP_CLAMP | IORING_SETUP_ATTACH_WQ |11273 IORING_SETUP_CLAMP | IORING_SETUP_ATTACH_WQ |
11268 IORING_SETUP_R_DISABLED))11274 IORING_SETUP_R_DISABLED | IORING_SETUP_SUBMIT_ALL))
11269 return -EINVAL;11275 return -EINVAL;
11270 11276
11271 return io_uring_create(entries, &p, params);11277 return io_uring_create(entries, &p, params);
include/uapi/linux/io_uring.h+1−0
@@ -101,6 +101,7 @@ enum { · 100 unmodified lines
101#define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */101#define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */
102#define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */102#define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */
103#define IORING_SETUP_R_DISABLED (1U << 6) /* start with ring disabled */103#define IORING_SETUP_R_DISABLED (1U << 6) /* start with ring disabled */
104#define IORING_SETUP_SUBMIT_ALL (1U << 7) /* continue submit on error */
104 105
105enum {106enum {
106 IORING_OP_NOP,107 IORING_OP_NOP,