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