]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: replaced ImageCtx::get_thread_pool_instance
authorJason Dillaman <dillaman@redhat.com>
Thu, 11 Jun 2020 20:26:55 +0000 (16:26 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 11 Jun 2020 23:57:36 +0000 (19:57 -0400)
Callers have never needed the actual ThreadPool which is being
removed. Refactored into ImageCtx::get_work_queue method.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
17 files changed:
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/ImageState.cc
src/librbd/Journal.cc
src/librbd/api/Image.cc
src/librbd/api/Migration.cc
src/librbd/api/Mirror.cc
src/librbd/api/Pool.cc
src/librbd/api/Trash.cc
src/librbd/internal.cc
src/test/librbd/deep_copy/test_mock_ImageCopyRequest.cc
src/test/librbd/deep_copy/test_mock_MetadataCopyRequest.cc
src/test/librbd/deep_copy/test_mock_ObjectCopyRequest.cc
src/test/librbd/deep_copy/test_mock_SetHeadRequest.cc
src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc
src/test/librbd/deep_copy/test_mock_SnapshotCreateRequest.cc
src/test/librbd/test_mock_DeepCopyRequest.cc

index f8564005d889dbb7aa02984123f2cf03409b409d..07e96a053c90f87e585d1584a7957006025098a2 100644 (file)
@@ -96,6 +96,15 @@ boost::asio::io_context& get_asio_engine_io_context(CephContext* cct) {
   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_";
@@ -925,14 +934,11 @@ boost::asio::io_context& get_asio_engine_io_context(CephContext* cct) {
       "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,
index d25f80464ac6dc33e2540c362cb16964903d43ad..45b80423b93e4d834046d0d284c13a1d58b6faf1 100644 (file)
@@ -347,9 +347,7 @@ namespace librbd {
     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);
   };
index 889a36609dac192c7055607172ad9cbc86028551..d1d73e80b0be653c45aea81247f4aa1c053a0d69 100644 (file)
@@ -236,8 +236,7 @@ public:
     : 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() {
index 143ca21bc9cc47c1c381b433a7b10bba09bde605..3910b18735750b817395a3ec9ee5b2e35650f8be 100644 (file)
@@ -373,9 +373,8 @@ int Journal<I>::create(librados::IoCtx &io_ctx, const std::string &image_id,
   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);
@@ -392,9 +391,8 @@ int Journal<I>::remove(librados::IoCtx &io_ctx, const std::string &image_id) {
   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(
@@ -409,9 +407,8 @@ int Journal<I>::reset(librados::IoCtx &io_ctx, const std::string &image_id) {
   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,
index 6b95ac696bcb97a09d7ba1d1bd8151c39d292c85..977a4894eaa33dfd8573b25415675e75a1e0538e 100644 (file)
@@ -674,9 +674,8 @@ int Image<I>::deep_copy(I *src, I *dest, bool flatten,
     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;
@@ -825,9 +824,8 @@ int Image<I>::remove(IoCtx& io_ctx, const std::string &image_name,
     // 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
index dce8c2a280d5dee9e1da6c3c4495bdf3d5e33498..e097bad4a9278bb6f685a2a3a42f587608db61bc 100644 (file)
@@ -835,9 +835,8 @@ int Migration<I>::abort() {
 
     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,
@@ -1219,9 +1218,8 @@ int Migration<I>::create_dst_image() {
     }
   }
 
-  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);
@@ -1761,9 +1759,8 @@ int Migration<I>::remove_src_image() {
 
   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,
index 2855ae329889595fbd3d5ee7dfb1b44086e5b4d4..ec125d2c4994ce0a37924189519952405a97b739 100644 (file)
@@ -1940,9 +1940,8 @@ int Mirror<I>::image_info_list(
       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;
index 708f797ec698e943a997584fbfc22a4cfb56083a..9a2ef379ff97d7111f5164c0a669e5de8f48e630 100644 (file)
@@ -251,9 +251,8 @@ int Pool<I>::init(librados::IoCtx& io_ctx, bool force) {
     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);
index df1277b5f82ae64479a0a714643ca459e6ce22f3..a5ba23306e923c3314c81ba5086572bbdd3f51ac 100644 (file)
@@ -90,9 +90,8 @@ int enable_mirroring(IoCtx &io_ctx, const std::string &image_id) {
 
   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,
@@ -535,9 +534,8 @@ int Trash<I>::remove(IoCtx &io_ctx, const std::string &image_id, bool force,
     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(
index e37be4784728c3c73b16f04cc65f36e206b6c3c1..31edcc57b600038d6e9a7c95ba293d5c2548b7af 100644 (file)
@@ -684,9 +684,8 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
       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);
@@ -790,9 +789,8 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     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(
index 4ee6320f3e5c9fdc6f6a6cfb113d7951db406a78..a7d68a624e2df985e43e4630fda4d1c9563ebac7 100644 (file)
@@ -174,7 +174,6 @@ public:
 
   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;
@@ -189,8 +188,7 @@ public:
     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,
index 7018f58ce139fd065371e3e6af1a0522c533626b..8d6fcd3ad8d3239d2843fe980e7d8d41cf58ff64 100644 (file)
@@ -79,7 +79,6 @@ public:
 
   librbd::ImageCtx *m_src_image_ctx;
   librbd::ImageCtx *m_dst_image_ctx;
-  ThreadPool *m_thread_pool;
   ContextWQ *m_work_queue;
 
   void SetUp() override {
@@ -92,8 +91,7 @@ public:
     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,
index ba7966c9a38875d486d055fa283315782ab0a8b5..7d61bb84716d48284d64361a129e367e3e48ce19 100644 (file)
@@ -112,7 +112,6 @@ public:
 
   librbd::ImageCtx *m_src_image_ctx;
   librbd::ImageCtx *m_dst_image_ctx;
-  ThreadPool *m_thread_pool;
   ContextWQ *m_work_queue;
 
   SnapMap m_snap_map;
@@ -133,8 +132,7 @@ public:
     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) {
index f0714f9d303308e60a86be7ca97f03371f649e8e..3eceb4daff20d2dee14400767a07ce041320c17b 100644 (file)
@@ -97,7 +97,6 @@ public:
   typedef image::DetachParentRequest<MockTestImageCtx> MockDetachParentRequest;
 
   librbd::ImageCtx *m_image_ctx;
-  ThreadPool *m_thread_pool;
   ContextWQ *m_work_queue;
 
   void SetUp() override {
@@ -105,8 +104,7 @@ public:
 
     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) {
index 40c282cd4cd70911f443901b83bfae0e53d37a01..e17782c189f30f89e6c14bbf0215b08f14fedd75 100644 (file)
@@ -106,7 +106,6 @@ public:
 
   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;
@@ -121,8 +120,7 @@ public:
     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,
index 975aea937d86c4dddaf05e48b7666ac51cd14f85..571820edad894420f26b376430316f3aec141054 100644 (file)
@@ -76,7 +76,6 @@ public:
   typedef SnapshotCreateRequest<librbd::MockTestImageCtx> MockSnapshotCreateRequest;
 
   librbd::ImageCtx *m_image_ctx;
-  ThreadPool *m_thread_pool;
   ContextWQ *m_work_queue;
 
   void SetUp() override {
@@ -84,8 +83,7 @@ public:
 
     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) {
index 340fe1e2a4d67bbe34537a690aaa8dbd60fafa5f..c6ec8d6ace892cad23c0663548338d1dade15af1 100644 (file)
@@ -149,7 +149,6 @@ public:
 
   librbd::ImageCtx *m_src_image_ctx;
   librbd::ImageCtx *m_dst_image_ctx;
-  ThreadPool *m_thread_pool;
   ContextWQ *m_work_queue;
 
   void SetUp() override {
@@ -160,8 +159,7 @@ public:
 
     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 {