From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/librbd/AsioEngine.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/librbd/AsioEngine.cc (limited to 'src/librbd/AsioEngine.cc') diff --git a/src/librbd/AsioEngine.cc b/src/librbd/AsioEngine.cc new file mode 100644 index 000000000..8e2beb49c --- /dev/null +++ b/src/librbd/AsioEngine.cc @@ -0,0 +1,56 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "librbd/AsioEngine.h" +#include "include/Context.h" +#include "include/neorados/RADOS.hpp" +#include "include/rados/librados.hpp" +#include "common/dout.h" +#include "librbd/asio/ContextWQ.h" + +#define dout_subsys ceph_subsys_rbd +#undef dout_prefix +#define dout_prefix *_dout << "librbd::AsioEngine: " \ + << this << " " << __func__ << ": " + +namespace librbd { + +AsioEngine::AsioEngine(std::shared_ptr rados) + : m_rados_api(std::make_shared( + neorados::RADOS::make_with_librados(*rados))), + m_cct(m_rados_api->cct()), + m_io_context(m_rados_api->get_io_context()), + m_api_strand(std::make_unique( + m_io_context)), + m_context_wq(std::make_unique(m_cct, m_io_context)) { + ldout(m_cct, 20) << dendl; + + auto rados_threads = m_cct->_conf.get_val("librados_thread_count"); + auto rbd_threads = m_cct->_conf.get_val("rbd_op_threads"); + if (rbd_threads > rados_threads) { + // inherit the librados thread count -- but increase it if librbd wants to + // utilize more threads + m_cct->_conf.set_val_or_die("librados_thread_count", + std::to_string(rbd_threads)); + m_cct->_conf.apply_changes(nullptr); + } +} + +AsioEngine::AsioEngine(librados::IoCtx& io_ctx) + : AsioEngine(std::make_shared(io_ctx)) { +} + +AsioEngine::~AsioEngine() { + ldout(m_cct, 20) << dendl; + m_api_strand.reset(); +} + +void AsioEngine::dispatch(Context* ctx, int r) { + dispatch([ctx, r]() { ctx->complete(r); }); +} + +void AsioEngine::post(Context* ctx, int r) { + post([ctx, r]() { ctx->complete(r); }); +} + +} // namespace librbd -- cgit v1.2.3