return asio_engine_singleton->get_io_context();
}
+void get_thread_pool_instance(CephContext *cct, ThreadPool **thread_pool,
+ ContextWQ **op_work_queue) {
+ auto thread_pool_singleton =
+ &cct->lookup_or_create_singleton_object<ThreadPoolSingleton>(
+ "librbd::thread_pool", false, cct);
+ *thread_pool = thread_pool_singleton;
+ *op_work_queue = thread_pool_singleton->op_work_queue;
+}
+
} // anonymous namespace
const string ImageCtx::METADATA_CONF_PREFIX = "conf_";
"librbd::AsioEngine", false, cct);
}
- void ImageCtx::get_thread_pool_instance(CephContext *cct,
- ThreadPool **thread_pool,
- ContextWQ **op_work_queue) {
- auto thread_pool_singleton =
- &cct->lookup_or_create_singleton_object<ThreadPoolSingleton>(
- "librbd::thread_pool", false, cct);
- *thread_pool = thread_pool_singleton;
- *op_work_queue = thread_pool_singleton->op_work_queue;
+ void ImageCtx::get_work_queue(CephContext *cct,
+ ContextWQ **op_work_queue) {
+
+ ThreadPool* thread_pool;
+ get_thread_pool_instance(cct, &thread_pool, op_work_queue);
}
void ImageCtx::get_timer_instance(CephContext *cct, SafeTimer **timer,
void set_journal_policy(journal::Policy *policy);
static AsioEngine* get_asio_engine(CephContext* cct);
- static void get_thread_pool_instance(CephContext *cct,
- ThreadPool **thread_pool,
- ContextWQ **op_work_queue);
+ static void get_work_queue(CephContext *cct, ContextWQ **op_work_queue);
static void get_timer_instance(CephContext *cct, SafeTimer **timer,
ceph::mutex **timer_lock);
};
: m_cct(cct),
m_lock(ceph::make_mutex(util::unique_lock_name(
"librbd::QuiesceWatchers::m_lock", this))) {
- ThreadPool *thread_pool;
- ImageCtx::get_thread_pool_instance(m_cct, &thread_pool, &m_work_queue);
+ ImageCtx::get_work_queue(m_cct, &m_work_queue);
}
~QuiesceWatchers() {
CephContext *cct = reinterpret_cast<CephContext *>(io_ctx.cct());
ldout(cct, 5) << __func__ << ": image=" << image_id << dendl;
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
C_SaferCond cond;
journal::TagData tag_data(LOCAL_MIRROR_UUID);
CephContext *cct = reinterpret_cast<CephContext *>(io_ctx.cct());
ldout(cct, 5) << __func__ << ": image=" << image_id << dendl;
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
C_SaferCond cond;
journal::RemoveRequest<I> *req = journal::RemoveRequest<I>::create(
CephContext *cct = reinterpret_cast<CephContext *>(io_ctx.cct());
ldout(cct, 5) << __func__ << ": image=" << image_id << dendl;
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
C_SaferCond cond;
auto req = journal::ResetRequest<I>::create(io_ctx, image_id, IMAGE_CLIENT_ID,
snap_id_end = src->snap_id;
}
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
C_SaferCond cond;
SnapSeqs snap_seqs;
// fall-through if trash isn't supported
}
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
// might be a V1 image format that cannot be moved to the trash
// and would not have been listed in the V2 directory -- or the OSDs
ceph_assert(dst_image_ctx->ignore_migrating);
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(m_cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(m_cct, &op_work_queue);
C_SaferCond on_remove;
auto req = librbd::image::RemoveRequest<>::create(
m_dst_io_ctx, dst_image_ctx, false, false, *m_prog_ctx, op_work_queue,
}
}
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(m_cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(m_cct, &op_work_queue);
ConfigProxy config{m_cct->_conf};
api::Config<I>::apply_pool_overrides(m_dst_io_ctx, &config);
ceph_assert(m_src_image_ctx->ignore_migrating);
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(m_cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(m_cct, &op_work_queue);
C_SaferCond on_remove;
auto req = librbd::image::RemoveRequest<I>::create(
m_src_io_ctx, m_src_image_ctx, false, true, *m_prog_ctx, op_work_queue,
break;
}
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
for (auto &it : images) {
auto &image_id = it.first;
return 0;
}
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
C_SaferCond ctx;
auto req = image::ValidatePoolRequest<I>::create(io_ctx, op_work_queue, &ctx);
ldout(cct, 10) << dendl;
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
C_SaferCond ctx;
auto req = mirror::EnableRequest<I>::create(
io_ctx, image_id, cls::rbd::MIRROR_IMAGE_MODE_JOURNAL, "", false,
return -EBUSY;
}
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
C_SaferCond cond;
auto req = librbd::trash::RemoveRequest<I>::create(
lderr(cct) << "Forced V1 image creation. " << dendl;
r = create_v1(io_ctx, image_name.c_str(), size, order);
} else {
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
ConfigProxy config{cct->_conf};
api::Config<>::apply_pool_overrides(io_ctx, &config);
ConfigProxy config{reinterpret_cast<CephContext *>(c_ioctx.cct())->_conf};
api::Config<>::apply_pool_overrides(c_ioctx, &config);
- ThreadPool *thread_pool;
ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ ImageCtx::get_work_queue(cct, &op_work_queue);
C_SaferCond cond;
auto *req = image::CloneRequest<>::create(
librbd::ImageCtx *m_src_image_ctx;
librbd::ImageCtx *m_dst_image_ctx;
- ThreadPool *m_thread_pool;
ContextWQ *m_work_queue;
librbd::SnapSeqs m_snap_seqs;
SnapMap m_snap_map;
ASSERT_EQ(0, create_image_pp(rbd, m_ioctx, dst_image_name, m_image_size));
ASSERT_EQ(0, open_image(dst_image_name, &m_dst_image_ctx));
- librbd::ImageCtx::get_thread_pool_instance(m_src_image_ctx->cct,
- &m_thread_pool, &m_work_queue);
+ librbd::ImageCtx::get_work_queue(m_src_image_ctx->cct, &m_work_queue);
}
void expect_get_image_size(librbd::MockTestImageCtx &mock_image_ctx,
librbd::ImageCtx *m_src_image_ctx;
librbd::ImageCtx *m_dst_image_ctx;
- ThreadPool *m_thread_pool;
ContextWQ *m_work_queue;
void SetUp() override {
ASSERT_EQ(0, create_image_pp(rbd, m_ioctx, dst_image_name, m_image_size));
ASSERT_EQ(0, open_image(dst_image_name, &m_dst_image_ctx));
- librbd::ImageCtx::get_thread_pool_instance(m_src_image_ctx->cct,
- &m_thread_pool, &m_work_queue);
+ librbd::ImageCtx::get_work_queue(m_src_image_ctx->cct, &m_work_queue);
}
void expect_get_metadata(MockGetMetadataRequest& mock_request,
librbd::ImageCtx *m_src_image_ctx;
librbd::ImageCtx *m_dst_image_ctx;
- ThreadPool *m_thread_pool;
ContextWQ *m_work_queue;
SnapMap m_snap_map;
ASSERT_EQ(0, create_image_pp(rbd, m_ioctx, dst_image_name, m_image_size));
ASSERT_EQ(0, open_image(dst_image_name, &m_dst_image_ctx));
- librbd::ImageCtx::get_thread_pool_instance(m_src_image_ctx->cct,
- &m_thread_pool, &m_work_queue);
+ librbd::ImageCtx::get_work_queue(m_src_image_ctx->cct, &m_work_queue);
}
bool is_fast_diff(librbd::MockImageCtx &mock_image_ctx) {
typedef image::DetachParentRequest<MockTestImageCtx> MockDetachParentRequest;
librbd::ImageCtx *m_image_ctx;
- ThreadPool *m_thread_pool;
ContextWQ *m_work_queue;
void SetUp() override {
ASSERT_EQ(0, open_image(m_image_name, &m_image_ctx));
- librbd::ImageCtx::get_thread_pool_instance(m_image_ctx->cct, &m_thread_pool,
- &m_work_queue);
+ librbd::ImageCtx::get_work_queue(m_image_ctx->cct, &m_work_queue);
}
void expect_start_op(librbd::MockExclusiveLock &mock_exclusive_lock) {
librbd::ImageCtx *m_src_image_ctx;
librbd::ImageCtx *m_dst_image_ctx;
- ThreadPool *m_thread_pool;
ContextWQ *m_work_queue;
librbd::SnapSeqs m_snap_seqs;
ASSERT_EQ(0, create_image_pp(rbd, m_ioctx, dst_image_name, m_image_size));
ASSERT_EQ(0, open_image(dst_image_name, &m_dst_image_ctx));
- librbd::ImageCtx::get_thread_pool_instance(m_src_image_ctx->cct,
- &m_thread_pool, &m_work_queue);
+ librbd::ImageCtx::get_work_queue(m_src_image_ctx->cct, &m_work_queue);
}
void prepare_exclusive_lock(librbd::MockImageCtx &mock_image_ctx,
typedef SnapshotCreateRequest<librbd::MockTestImageCtx> MockSnapshotCreateRequest;
librbd::ImageCtx *m_image_ctx;
- ThreadPool *m_thread_pool;
ContextWQ *m_work_queue;
void SetUp() override {
ASSERT_EQ(0, open_image(m_image_name, &m_image_ctx));
- librbd::ImageCtx::get_thread_pool_instance(m_image_ctx->cct, &m_thread_pool,
- &m_work_queue);
+ librbd::ImageCtx::get_work_queue(m_image_ctx->cct, &m_work_queue);
}
void expect_start_op(librbd::MockExclusiveLock &mock_exclusive_lock) {
librbd::ImageCtx *m_src_image_ctx;
librbd::ImageCtx *m_dst_image_ctx;
- ThreadPool *m_thread_pool;
ContextWQ *m_work_queue;
void SetUp() override {
ASSERT_EQ(0, open_image(m_image_name, &m_dst_image_ctx));
- librbd::ImageCtx::get_thread_pool_instance(m_src_image_ctx->cct,
- &m_thread_pool, &m_work_queue);
+ librbd::ImageCtx::get_work_queue(m_src_image_ctx->cct, &m_work_queue);
}
void TearDown() override {