]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/crypto/luks/FlattenRequest.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / librbd / crypto / luks / FlattenRequest.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_LIBRBD_CRYPTO_LUKS_FLATTEN_REQUEST_H
5 #define CEPH_LIBRBD_CRYPTO_LUKS_FLATTEN_REQUEST_H
6
7 #include "librbd/ImageCtx.h"
8
9 namespace librbd {
10
11 namespace crypto {
12 namespace luks {
13
14 template <typename I>
15 class FlattenRequest {
16 public:
17 using EncryptionFormat = decltype(I::encryption_format);
18
19 static FlattenRequest* create(I* image_ctx, Context* on_finish) {
20 return new FlattenRequest(image_ctx, on_finish);
21 }
22
23 FlattenRequest(I* image_ctx, Context* on_finish);
24 void send();
25
26 private:
27 /**
28 * @verbatim
29 *
30 * <start>
31 * |
32 * v
33 * READ_HEADER
34 * |
35 * v
36 * WRITE_HEADER (replacing magic back from RBDL to LUKS if needed)
37 * |
38 * v
39 * FLUSH
40 * |
41 * v
42 * <finish>
43 *
44 * @endverbatim
45 */
46 I* m_image_ctx;
47 Context* m_on_finish;
48 ceph::bufferlist m_bl;
49
50 void read_header();
51 void handle_read_header(int r);
52 void write_header();
53 void handle_write_header(int r);
54 void flush();
55 void handle_flush(int r);
56 void finish(int r);
57 };
58
59 } // namespace luks
60 } // namespace crypto
61 } // namespace librbd
62
63 extern template class librbd::crypto::luks::FlattenRequest<librbd::ImageCtx>;
64
65 #endif // CEPH_LIBRBD_CRYPTO_LUKS_FLATTEN_REQUEST_H