]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: no need to return format from ShutDownCryptoRequest
authorIlya Dryomov <idryomov@gmail.com>
Thu, 15 Sep 2022 08:05:56 +0000 (10:05 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 4 Dec 2022 17:19:19 +0000 (18:19 +0100)
luks::FlattenRequest was the only user of this interface.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/librbd/crypto/FormatRequest.cc
src/librbd/crypto/ShutDownCryptoRequest.cc
src/librbd/crypto/ShutDownCryptoRequest.h
src/test/librbd/crypto/test_mock_FormatRequest.cc
src/test/librbd/crypto/test_mock_ShutDownCryptoRequest.cc

index c4a15790873caf623eb750ce11dce5b8c4c4c3a2..5e90bbb7632aa64ebdc7714138ff935adca53263 100644 (file)
@@ -54,7 +54,7 @@ void FormatRequest<I>::send() {
 
   auto ctx = create_context_callback<
           FormatRequest<I>, &FormatRequest<I>::handle_shutdown_crypto>(this);
-  auto *req = ShutDownCryptoRequest<I>::create(m_image_ctx, nullptr, ctx);
+  auto *req = ShutDownCryptoRequest<I>::create(m_image_ctx, ctx);
   req->send();
 }
 
index 47613f83355784a23635749d33af9ddcaa0dd483..fb1e7747968586ca27a1f287613b9b9033598dc1 100644 (file)
@@ -23,11 +23,9 @@ namespace crypto {
 using librbd::util::create_context_callback;
 
 template <typename I>
-ShutDownCryptoRequest<I>::ShutDownCryptoRequest(
-        I* image_ctx, EncryptionFormat* format,
-        Context* on_finish) : m_image_ctx(image_ctx), m_format(format),
-                              m_on_finish(on_finish) {
-}
+ShutDownCryptoRequest<I>::ShutDownCryptoRequest(I* image_ctx,
+                                                Context* on_finish)
+    : m_image_ctx(image_ctx), m_on_finish(on_finish) {}
 
 template <typename I>
 void ShutDownCryptoRequest<I>::send() {
@@ -97,12 +95,7 @@ void ShutDownCryptoRequest<I>::finish(int r) {
   if (r == 0) {
     {
       std::unique_lock image_locker{m_image_ctx->image_lock};
-      if (m_format != nullptr) {
-        *m_format = std::move(m_image_ctx->encryption_format);
-        m_format = nullptr;
-      } else {
-        m_image_ctx->encryption_format.reset();
-      }
+      m_image_ctx->encryption_format.reset();
     }
     
     if (m_image_ctx->parent != nullptr) {
index e576e9c7748f487b259750ed83647f10c5e64b33..27422857408f109e2a6cec4145c664ad49e3bf75 100644 (file)
@@ -14,20 +14,15 @@ class ImageCtx;
 
 namespace crypto {
 
-template <typename> class EncryptionFormat;
-
 template <typename I>
 class ShutDownCryptoRequest {
 public:
-    using EncryptionFormat = decltype(I::encryption_format);
-
-    static ShutDownCryptoRequest* create(
-            I* image_ctx, EncryptionFormat* format, Context* on_finish) {
-      return new ShutDownCryptoRequest(image_ctx, format, on_finish);
+    static ShutDownCryptoRequest* create(I* image_ctx, Context* on_finish) {
+      return new ShutDownCryptoRequest(image_ctx, on_finish);
     }
 
-    ShutDownCryptoRequest(
-            I* image_ctx, EncryptionFormat* format, Context* on_finish);
+    ShutDownCryptoRequest(I* image_ctx, Context* on_finish);
+
     void send();
     void shut_down_object_dispatch();
     void handle_shut_down_object_dispatch(int r);
@@ -37,7 +32,6 @@ public:
 
 private:
     I* m_image_ctx;
-    EncryptionFormat* m_format;
     Context* m_on_finish;
 };
 
index 9cb0048fb3a209c8d856e33307afcf7ca4e0417a..81b82429d7fddf0326f52d251eb426d55eaacf48 100644 (file)
@@ -55,10 +55,8 @@ template <>
 struct ShutDownCryptoRequest<MockTestImageCtx> {
   Context *on_finish = nullptr;
   static ShutDownCryptoRequest *s_instance;
-  static ShutDownCryptoRequest *create(
-          MockTestImageCtx *image_ctx,
-          std::unique_ptr<MockEncryptionFormat>* format,
-          Context *on_finish) {
+  static ShutDownCryptoRequest *create(MockTestImageCtx *image_ctx,
+                                       Context *on_finish) {
     ceph_assert(s_instance != nullptr);
     s_instance->on_finish = on_finish;
     return s_instance;
index e6a837bb43898fd11bdcede651d2e46ba46f8fe7..7df99b78ac9efdd85ac1638107a9b5ea33eafc4f 100644 (file)
@@ -38,7 +38,6 @@ struct TestMockShutDownCryptoRequest : public TestMockFixture {
   Context *on_finish = &finished_cond;
   MockShutDownCryptoRequest* mock_shutdown_crypto_request;
   MockEncryptionFormat* mock_encryption_format;
-  std::unique_ptr<MockEncryptionFormat> result_format;
   Context* shutdown_object_dispatch_context;
   Context* shutdown_image_dispatch_context;
 
@@ -51,7 +50,7 @@ struct TestMockShutDownCryptoRequest : public TestMockFixture {
     mock_encryption_format = new MockEncryptionFormat();
     mock_image_ctx->encryption_format.reset(mock_encryption_format);
     mock_shutdown_crypto_request = MockShutDownCryptoRequest::create(
-          mock_image_ctx, &result_format, on_finish);
+        mock_image_ctx, on_finish);
   }
 
   void TearDown() override {
@@ -142,7 +141,6 @@ TEST_F(TestMockShutDownCryptoRequest, Success) {
   shutdown_image_dispatch_context->complete(0);
   ASSERT_EQ(0, finished_cond.wait());
   ASSERT_EQ(nullptr, mock_image_ctx->encryption_format.get());
-  ASSERT_EQ(mock_encryption_format, result_format.get());
 }
 
 TEST_F(TestMockShutDownCryptoRequest, ShutdownParent) {
@@ -169,7 +167,6 @@ TEST_F(TestMockShutDownCryptoRequest, ShutdownParent) {
   ASSERT_EQ(0, finished_cond.wait());
   ASSERT_EQ(nullptr, mock_image_ctx->encryption_format.get());
   ASSERT_EQ(nullptr, parent_image_ctx->encryption_format.get());
-  ASSERT_EQ(mock_encryption_format, result_format.get());
   delete parent_image_ctx;
 }