diff --git a/src/io/uring/Queue.hxx b/src/io/uring/Queue.hxx index 2264b9e49..6f88ee516 100644 --- a/src/io/uring/Queue.hxx +++ b/src/io/uring/Queue.hxx @@ -30,6 +30,14 @@ public: return ring.GetFileDescriptor(); } + void SetMaxWorkers(unsigned values[2]) { + ring.SetMaxWorkers(values); + } + + void SetMaxWorkers(unsigned bounded, unsigned unbounded) { + ring.SetMaxWorkers(bounded, unbounded); + } + struct io_uring_sqe *GetSubmitEntry() noexcept { return ring.GetSubmitEntry(); } diff --git a/src/io/uring/Ring.cxx b/src/io/uring/Ring.cxx index 7b171dfb8..222b24363 100644 --- a/src/io/uring/Ring.cxx +++ b/src/io/uring/Ring.cxx @@ -21,6 +21,14 @@ Ring::Ring(unsigned entries, struct io_uring_params ¶ms) throw MakeErrno(-error, "io_uring_queue_init_params() failed"); } +void +Ring::SetMaxWorkers(unsigned values[2]) +{ + if (int error = io_uring_register_iowq_max_workers(&ring, values); + error < 0) + throw MakeErrno(-error, "io_uring_register_iowq_max_workers() failed"); +} + void Ring::Submit() { diff --git a/src/io/uring/Ring.hxx b/src/io/uring/Ring.hxx index aac105fc3..8c1128995 100644 --- a/src/io/uring/Ring.hxx +++ b/src/io/uring/Ring.hxx @@ -50,6 +50,23 @@ public: return FileDescriptor(ring.ring_fd); } + /** + * Wrapper for io_uring_register_iowq_max_workers(). + * + * Throws on error. + */ + void SetMaxWorkers(unsigned values[2]); + + /** + * This overload constructs an array for + * io_uring_register_iowq_max_workers() and discards the + * output values. + */ + void SetMaxWorkers(unsigned bounded, unsigned unbounded) { + unsigned values[2] = {bounded, unbounded}; + SetMaxWorkers(values); + } + /** * Returns a submit queue entry or nullptr if the submit queue * is full.