From: Jason Dillaman Date: Thu, 3 Sep 2020 17:33:42 +0000 (-0400) Subject: librbd: helper method to create new data pool IOContext X-Git-Tag: v16.1.0~1032^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6c4785be79cb2320517e543ac970461cfbb1c615;p=ceph.git 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 --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 8d88e03d7b73..c1f19aa209db 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 c8c3caf97aba..cca02cc0125f 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 a2670f896dc7..9c7bf951fc97 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 d7346eb7e794..e8207510a757 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,