]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/mirror/snapshot/RemoveImageStateRequest.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / librbd / mirror / snapshot / RemoveImageStateRequest.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_MIRROR_SNAPSHOT_REMOVE_IMAGE_STATE_REQUEST_H
5 #define CEPH_LIBRBD_MIRROR_SNAPSHOT_REMOVE_IMAGE_STATE_REQUEST_H
6
7 #include "include/buffer.h"
8 #include "include/types.h"
9
10 struct Context;
11
12 namespace librbd {
13
14 struct ImageCtx;
15
16 namespace mirror {
17 namespace snapshot {
18
19 template <typename ImageCtxT = librbd::ImageCtx>
20 class RemoveImageStateRequest {
21 public:
22 static RemoveImageStateRequest *create(ImageCtxT *image_ctx, uint64_t snap_id,
23 Context *on_finish) {
24 return new RemoveImageStateRequest(image_ctx, snap_id, on_finish);
25 }
26
27 RemoveImageStateRequest(ImageCtxT *image_ctx, uint64_t snap_id,
28 Context *on_finish)
29 : m_image_ctx(image_ctx), m_snap_id(snap_id), m_on_finish(on_finish) {
30 }
31
32 void send();
33
34 private:
35 /**
36 * @verbatim
37 *
38 * <start>
39 * |
40 * v
41 * GET_OBJECT_COUNT
42 * |
43 * v
44 * REMOVE_OBJECT (repeat for
45 * | every object)
46 * v
47 * <finish>
48 *
49 * @endverbatim
50 */
51
52 ImageCtxT *m_image_ctx;
53 uint64_t m_snap_id;
54 Context *m_on_finish;
55
56 bufferlist m_bl;
57
58 size_t m_object_count = 0;
59
60 void get_object_count();
61 void handle_get_object_count(int r);
62
63 void remove_object();
64 void handle_remove_object(int r);
65
66 void finish(int r);
67 };
68
69 } // namespace snapshot
70 } // namespace mirror
71 } // namespace librbd
72
73 extern template class librbd::mirror::snapshot::RemoveImageStateRequest<librbd::ImageCtx>;
74
75 #endif // CEPH_LIBRBD_MIRROR_SNAPSHOT_REMOVE_IMAGE_STATE_REQUEST_H