From d16847e977aeb30096acf7189a9b2a308bad923a Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 10 Feb 2023 10:36:57 -0500 Subject: [PATCH] librbd: use strand template and make_strand() Signed-off-by: Casey Bodley Signed-off-by: Adam C. Emerson --- src/librbd/AsioEngine.cc | 4 ++-- src/librbd/AsioEngine.h | 6 +++--- src/librbd/asio/ContextWQ.cc | 3 ++- src/librbd/asio/ContextWQ.h | 5 +++-- src/librbd/migration/QCOWFormat.cc | 12 +++++++----- src/librbd/migration/QCOWFormat.h | 5 +++-- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/librbd/AsioEngine.cc b/src/librbd/AsioEngine.cc index 8e2beb49cfd91..ad0051efa8e51 100644 --- a/src/librbd/AsioEngine.cc +++ b/src/librbd/AsioEngine.cc @@ -20,8 +20,8 @@ AsioEngine::AsioEngine(std::shared_ptr rados) 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_api_strand(std::make_unique>( + boost::asio::make_strand(m_io_context))), m_context_wq(std::make_unique(m_cct, m_io_context)) { ldout(m_cct, 20) << dendl; diff --git a/src/librbd/AsioEngine.h b/src/librbd/AsioEngine.h index 0f476d80b2a47..6f2f22413c17a 100644 --- a/src/librbd/AsioEngine.h +++ b/src/librbd/AsioEngine.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include struct Context; @@ -45,7 +45,7 @@ public: return m_io_context.get_executor(); } - inline boost::asio::io_context::strand& get_api_strand() { + inline boost::asio::strand& get_api_strand() { // API client callbacks should never fire concurrently return *m_api_strand; } @@ -71,7 +71,7 @@ private: CephContext* m_cct; boost::asio::io_context& m_io_context; - std::unique_ptr m_api_strand; + std::unique_ptr> m_api_strand; std::unique_ptr m_context_wq; }; diff --git a/src/librbd/asio/ContextWQ.cc b/src/librbd/asio/ContextWQ.cc index 4f6c727708062..80c650935d4c1 100644 --- a/src/librbd/asio/ContextWQ.cc +++ b/src/librbd/asio/ContextWQ.cc @@ -16,7 +16,8 @@ namespace asio { ContextWQ::ContextWQ(CephContext* cct, boost::asio::io_context& io_context) : m_cct(cct), m_io_context(io_context), - m_strand(std::make_unique(io_context)), + m_strand(std::make_unique>( + boost::asio::make_strand(io_context))), m_queued_ops(0) { ldout(m_cct, 20) << dendl; } diff --git a/src/librbd/asio/ContextWQ.h b/src/librbd/asio/ContextWQ.h index 85c2541612137..3db5008d40a94 100644 --- a/src/librbd/asio/ContextWQ.h +++ b/src/librbd/asio/ContextWQ.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include namespace librbd { @@ -38,7 +38,8 @@ public: private: CephContext* m_cct; boost::asio::io_context& m_io_context; - std::unique_ptr m_strand; + using executor_type = boost::asio::io_context::executor_type; + std::unique_ptr> m_strand; std::atomic m_queued_ops; diff --git a/src/librbd/migration/QCOWFormat.cc b/src/librbd/migration/QCOWFormat.cc index 300bb712335ee..b2e277ad3762e 100644 --- a/src/librbd/migration/QCOWFormat.cc +++ b/src/librbd/migration/QCOWFormat.cc @@ -125,7 +125,8 @@ class QCOWFormat::ClusterCache { public: ClusterCache(QCOWFormat* qcow_format) : qcow_format(qcow_format), - m_strand(*qcow_format->m_image_ctx->asio_engine) { + m_strand(boost::asio::make_strand( + *qcow_format->m_image_ctx->asio_engine)) { } void get_cluster(uint64_t cluster_offset, uint64_t cluster_length, @@ -149,7 +150,7 @@ private: typedef std::list Completions; QCOWFormat* qcow_format; - boost::asio::io_context::strand m_strand; + boost::asio::strand m_strand; std::shared_ptr cluster; std::unordered_map cluster_completions; @@ -256,7 +257,8 @@ class QCOWFormat::L2TableCache { public: L2TableCache(QCOWFormat* qcow_format) : qcow_format(qcow_format), - m_strand(*qcow_format->m_image_ctx->asio_engine), + m_strand(boost::asio::make_strand( + *qcow_format->m_image_ctx->asio_engine)), l2_cache_entries(QCOW_L2_CACHE_SIZE) { } @@ -316,7 +318,7 @@ public: private: QCOWFormat* qcow_format; - boost::asio::io_context::strand m_strand; + boost::asio::strand m_strand; struct Request { const LookupTable* l1_table; @@ -832,7 +834,7 @@ QCOWFormat::QCOWFormat( const SourceSpecBuilder* source_spec_builder) : m_image_ctx(image_ctx), m_json_object(json_object), m_source_spec_builder(source_spec_builder), - m_strand(*image_ctx->asio_engine) { + m_strand(boost::asio::make_strand(*image_ctx->asio_engine)) { } template diff --git a/src/librbd/migration/QCOWFormat.h b/src/librbd/migration/QCOWFormat.h index b365067165026..3b355628cd2cb 100644 --- a/src/librbd/migration/QCOWFormat.h +++ b/src/librbd/migration/QCOWFormat.h @@ -10,7 +10,8 @@ #include "librbd/migration/QCOW.h" #include "acconfig.h" #include "json_spirit/json_spirit.h" -#include +#include +#include #include #include #include @@ -142,7 +143,7 @@ private: json_spirit::mObject m_json_object; const SourceSpecBuilder* m_source_spec_builder; - boost::asio::io_context::strand m_strand; + boost::asio::strand m_strand; std::shared_ptr m_stream; bufferlist m_bl; -- 2.39.5