luks::FlattenRequest was the only user of this interface.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
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();
}
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() {
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) {
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);
private:
I* m_image_ctx;
- EncryptionFormat* m_format;
Context* m_on_finish;
};
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;
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;
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 {
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) {
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;
}