21 template <
typename Sched,
typename Alloc, IoHandler Handler>
22 ex::task<void, TaskEnv<Sched, Alloc>>
23 invoke(
int ublkc_fd, uint16_t q_id,
const ublksrv_ctrl_dev_info *info,
25 if (q_id >= info->nr_hw_queues) {
26 throw std::out_of_range(
"q_id out of range");
29 uint64_t flags = info->flags;
30 uint16_t queue_depth = info->queue_depth;
31 uint32_t max_io_buf_bytes = info->max_io_buf_bytes;
33 if (flags & (UBLK_F_SUPPORT_ZERO_COPY | UBLK_F_AUTO_BUF_REG)) {
34 iovec iov = {
nullptr, 0};
35 auto &buffer_table = condy::current_runtime().buffer_table();
36 if (
auto r = buffer_table.update(queue_depth - 1, &iov, 1); r < 0) {
37 throw std::runtime_error(
38 "Buffer table too small, need nr_buffers >= queue_depth");
42 constexpr int UBLKC_FD = 0;
43 auto &fd_table = condy::current_runtime().fd_table();
44 auto r = fd_table.update(UBLKC_FD, &ublkc_fd, 1);
45 auto d = defer([&]()
noexcept {
48 fd_table.update(UBLKC_FD, &fd, 1);
52 auto alloc =
co_await ex::read_env(ex::get_allocator);
53 if (flags & UBLK_F_BATCH_IO) {
55 BatchIoQueue queue(ublkc_fd, ublkc_fd, q_id, flags, queue_depth,
56 max_io_buf_bytes, *handler, alloc);
57 co_await queue.template run<Sched>();
59 BatchIoQueue queue(condy::fixed(UBLKC_FD), ublkc_fd, q_id,
60 flags, queue_depth, max_io_buf_bytes,
62 co_await queue.template run<Sched>();
66 IoQueue queue(ublkc_fd, ublkc_fd, q_id, flags, queue_depth,
67 max_io_buf_bytes, *handler, alloc);
68 co_await queue.template run<Sched>();
70 IoQueue queue(condy::fixed(UBLKC_FD), ublkc_fd, q_id, flags,
71 queue_depth, max_io_buf_bytes, *handler, alloc);
72 co_await queue.template run<Sched>();
The std::execution backend namespace used by ublk-cpp.
Handler concepts for ublk server.
The main namespace of the ublk-cpp library.
I/O queue implementations.