]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/mirror/snapshot/SetImageStateRequest.h
df903a279ab878798df30fd40f32e6622d97fe4e
[ceph.git] / ceph / src / librbd / mirror / snapshot / SetImageStateRequest.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_SET_IMAGE_STATE_REQUEST_H
5 #define CEPH_LIBRBD_MIRROR_SNAPSHOT_SET_IMAGE_STATE_REQUEST_H
6
7 #include "librbd/mirror/snapshot/Types.h"
8
9 #include <map>
10 #include <string>
11
12 struct Context;
13
14 namespace librbd {
15
16 struct ImageCtx;
17
18 namespace mirror {
19 namespace snapshot {
20
21 template <typename ImageCtxT = librbd::ImageCtx>
22 class SetImageStateRequest {
23 public:
24 static SetImageStateRequest *create(ImageCtxT *image_ctx, uint64_t snap_id,
25 Context *on_finish) {
26 return new SetImageStateRequest(image_ctx, snap_id, on_finish);
27 }
28
29 SetImageStateRequest(ImageCtxT *image_ctx, uint64_t snap_id,
30 Context *on_finish)
31 : m_image_ctx(image_ctx), m_snap_id(snap_id), m_on_finish(on_finish) {
32 }
33
34 void send();
35
36 private:
37 /**
38 * @verbatim
39 *
40 * <start>
41 * |
42 * v
43 * GET_SNAP_LIMIT
44 * |
45 * v
46 * GET_METADATA
47 * |
48 * v
49 * WRITE_IMAGE_STATE
50 * |
51 * v
52 * UPDATE_PRIMARY_SNAPSHOT
53 * |
54 * v
55 * <finish>
56 *
57 * @endverbatim
58 */
59
60 ImageCtxT *m_image_ctx;
61 uint64_t m_snap_id;
62 Context *m_on_finish;
63
64 ImageState m_image_state;
65
66 bufferlist m_bl;
67 bufferlist m_state_bl;
68
69 void get_snap_limit();
70 void handle_get_snap_limit(int r);
71
72 void get_metadata();
73 void handle_get_metadata(int r);
74
75 void write_image_state();
76 void handle_write_image_state(int r);
77
78 void update_primary_snapshot();
79 void handle_update_primary_snapshot(int r);
80
81 void finish(int r);
82 };
83
84 } // namespace snapshot
85 } // namespace mirror
86 } // namespace librbd
87
88 extern template class librbd::mirror::snapshot::SetImageStateRequest<librbd::ImageCtx>;
89
90 #endif // CEPH_LIBRBD_MIRROR_SNAPSHOT_SET_IMAGE_STATE_REQUEST_H