]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/migration: use shared_ptr for streams
authorJason Dillaman <dillaman@redhat.com>
Mon, 30 Nov 2020 19:33:03 +0000 (14:33 -0500)
committerJason Dillaman <dillaman@redhat.com>
Mon, 30 Nov 2020 19:33:03 +0000 (14:33 -0500)
This will permit proper IO tracking through the stream layer to
ensure streams cannot be closed prematurely.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/migration/RawFormat.h
src/librbd/migration/SourceSpecBuilder.cc
src/librbd/migration/SourceSpecBuilder.h
src/test/librbd/migration/test_mock_RawFormat.cc

index 750ef8561cbdb334e1848f9803a7d278c8beff6e..450fd7d44064a1c520a2b72d9ecd6d8561b7de6f 100644 (file)
@@ -60,7 +60,7 @@ private:
   json_spirit::mObject m_json_object;
   const SourceSpecBuilder<ImageCtxT>* m_source_spec_builder;
 
-  std::unique_ptr<StreamInterface> m_stream;
+  std::shared_ptr<StreamInterface> m_stream;
 
 };
 
index 3500238f886432d7fd7775b8e21e931ce36bfeb7..4565833a93a305ed257bc8f2ab964ee44d0c1271 100644 (file)
@@ -76,7 +76,7 @@ int SourceSpecBuilder<I>::build_format(
 template <typename I>
 int SourceSpecBuilder<I>::build_stream(
     const json_spirit::mObject& source_spec_object,
-    std::unique_ptr<StreamInterface>* stream) const {
+    std::shared_ptr<StreamInterface>* stream) const {
   auto cct = m_image_ctx->cct;
   ldout(cct, 10) << dendl;
 
index 3948ca0300424eb37fac344807c7d73aa5659711..341679e078e6ea7273689974cc7976d3a76a0357 100644 (file)
@@ -34,7 +34,7 @@ public:
                    std::unique_ptr<FormatInterface>* format) const;
 
   int build_stream(const json_spirit::mObject& source_spec_object,
-                   std::unique_ptr<StreamInterface>* stream) const;
+                   std::shared_ptr<StreamInterface>* stream) const;
 
 private:
   ImageCtxT* m_image_ctx;
index aa04f88449b6060a70f8e821b2b815fa5edee7f4..023a50b93f4337a13480f482065e894ade037b01 100644 (file)
@@ -29,7 +29,7 @@ template<>
 struct SourceSpecBuilder<librbd::MockTestImageCtx> {
 
   MOCK_CONST_METHOD2(build_stream, int(const json_spirit::mObject&,
-                                       std::unique_ptr<StreamInterface>*));
+                                       std::shared_ptr<StreamInterface>*));
 
 };
 
@@ -69,7 +69,7 @@ public:
                            MockStreamInterface* mock_stream_interface, int r) {
     EXPECT_CALL(mock_source_spec_builder, build_stream(_, _))
       .WillOnce(WithArgs<1>(Invoke([mock_stream_interface, r]
-        (std::unique_ptr<StreamInterface>* ptr) {
+        (std::shared_ptr<StreamInterface>* ptr) {
           ptr->reset(mock_stream_interface);
           return r;
         })));