From: Jason Dillaman Date: Mon, 30 Nov 2020 19:33:03 +0000 (-0500) Subject: librbd/migration: use shared_ptr for streams X-Git-Tag: v16.1.0~382^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=898ae631418c3e47f9f8805cf1859c79288ccb90;p=ceph.git librbd/migration: use shared_ptr for streams This will permit proper IO tracking through the stream layer to ensure streams cannot be closed prematurely. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/migration/RawFormat.h b/src/librbd/migration/RawFormat.h index 750ef8561cbd..450fd7d44064 100644 --- a/src/librbd/migration/RawFormat.h +++ b/src/librbd/migration/RawFormat.h @@ -60,7 +60,7 @@ private: json_spirit::mObject m_json_object; const SourceSpecBuilder* m_source_spec_builder; - std::unique_ptr m_stream; + std::shared_ptr m_stream; }; diff --git a/src/librbd/migration/SourceSpecBuilder.cc b/src/librbd/migration/SourceSpecBuilder.cc index 3500238f8864..4565833a93a3 100644 --- a/src/librbd/migration/SourceSpecBuilder.cc +++ b/src/librbd/migration/SourceSpecBuilder.cc @@ -76,7 +76,7 @@ int SourceSpecBuilder::build_format( template int SourceSpecBuilder::build_stream( const json_spirit::mObject& source_spec_object, - std::unique_ptr* stream) const { + std::shared_ptr* stream) const { auto cct = m_image_ctx->cct; ldout(cct, 10) << dendl; diff --git a/src/librbd/migration/SourceSpecBuilder.h b/src/librbd/migration/SourceSpecBuilder.h index 3948ca030042..341679e078e6 100644 --- a/src/librbd/migration/SourceSpecBuilder.h +++ b/src/librbd/migration/SourceSpecBuilder.h @@ -34,7 +34,7 @@ public: std::unique_ptr* format) const; int build_stream(const json_spirit::mObject& source_spec_object, - std::unique_ptr* stream) const; + std::shared_ptr* stream) const; private: ImageCtxT* m_image_ctx; diff --git a/src/test/librbd/migration/test_mock_RawFormat.cc b/src/test/librbd/migration/test_mock_RawFormat.cc index aa04f88449b6..023a50b93f43 100644 --- a/src/test/librbd/migration/test_mock_RawFormat.cc +++ b/src/test/librbd/migration/test_mock_RawFormat.cc @@ -29,7 +29,7 @@ template<> struct SourceSpecBuilder { MOCK_CONST_METHOD2(build_stream, int(const json_spirit::mObject&, - std::unique_ptr*)); + std::shared_ptr*)); }; @@ -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* ptr) { + (std::shared_ptr* ptr) { ptr->reset(mock_stream_interface); return r; })));