From 6c4785be79cb2320517e543ac970461cfbb1c615 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 3 Sep 2020 13:33:42 -0400 Subject: [PATCH] librbd: helper method to create new data pool IOContext Deep-copy will require the ability to issue IOs against arbitrary IOContexts via the image-extent IO dispatcher. Signed-off-by: Jason Dillaman --- src/librbd/ImageCtx.cc | 5 +++++ src/librbd/ImageCtx.h | 1 + src/test/librbd/mock/MockImageCtx.cc | 4 ++++ src/test/librbd/mock/MockImageCtx.h | 1 + 4 files changed, 11 insertions(+) diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 8d88e03d7b73b..c1f19aa209db8 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -924,6 +924,11 @@ librados::IoCtx duplicate_io_ctx(librados::IoCtx& io_ctx) { return atomic_load(&data_io_context); } + IOContext ImageCtx::duplicate_data_io_context() const { + auto ctx = get_data_io_context(); + return std::make_shared(*ctx); + } + void ImageCtx::get_timer_instance(CephContext *cct, SafeTimer **timer, ceph::mutex **timer_lock) { auto safe_timer_singleton = diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index c8c3caf97aba5..cca02cc0125f3 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -352,6 +352,7 @@ namespace librbd { void rebuild_data_io_context(); IOContext get_data_io_context() const; + IOContext duplicate_data_io_context() const; static void get_timer_instance(CephContext *cct, SafeTimer **timer, ceph::mutex **timer_lock); diff --git a/src/test/librbd/mock/MockImageCtx.cc b/src/test/librbd/mock/MockImageCtx.cc index a2670f896dc78..9c7bf951fc970 100644 --- a/src/test/librbd/mock/MockImageCtx.cc +++ b/src/test/librbd/mock/MockImageCtx.cc @@ -45,4 +45,8 @@ IOContext MockImageCtx::get_data_io_context() { return ctx; } +IOContext MockImageCtx::duplicate_data_io_context() { + return std::make_shared(*get_data_io_context()); +} + } // namespace librbd diff --git a/src/test/librbd/mock/MockImageCtx.h b/src/test/librbd/mock/MockImageCtx.h index d7346eb7e7942..e8207510a7577 100644 --- a/src/test/librbd/mock/MockImageCtx.h +++ b/src/test/librbd/mock/MockImageCtx.h @@ -222,6 +222,7 @@ struct MockImageCtx { MOCK_METHOD0(rebuild_data_io_context, void()); IOContext get_data_io_context(); + IOContext duplicate_data_io_context(); static void set_timer_instance(MockSafeTimer *timer, ceph::mutex *timer_lock); static void get_timer_instance(CephContext *cct, MockSafeTimer **timer, -- 2.39.5