]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/mirror/snapshot/SetImageStateRequest.h
import ceph 15.2.10
[ceph.git] / ceph / src / librbd / mirror / snapshot / SetImageStateRequest.h
CommitLineData
9f95a23c
TL
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
12struct Context;
13
14namespace librbd {
15
16struct ImageCtx;
17
18namespace mirror {
19namespace snapshot {
20
21template <typename ImageCtxT = librbd::ImageCtx>
22class SetImageStateRequest {
23public:
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
36private:
37 /**
38 * @verbatim
39 *
40 * <start>
41 * |
42 * v
cd265ab1
TL
43 * GET_NAME
44 * |
45 * v
9f95a23c
TL
46 * GET_SNAP_LIMIT
47 * |
48 * v
49 * GET_METADATA
50 * |
51 * v
52 * WRITE_IMAGE_STATE
53 * |
54 * v
55 * UPDATE_PRIMARY_SNAPSHOT
56 * |
57 * v
58 * <finish>
59 *
60 * @endverbatim
61 */
62
63 ImageCtxT *m_image_ctx;
64 uint64_t m_snap_id;
65 Context *m_on_finish;
66
67 ImageState m_image_state;
68
69 bufferlist m_bl;
70 bufferlist m_state_bl;
71
cd265ab1
TL
72 void get_name();
73 void handle_get_name(int r);
74
9f95a23c
TL
75 void get_snap_limit();
76 void handle_get_snap_limit(int r);
77
78 void get_metadata();
79 void handle_get_metadata(int r);
80
81 void write_image_state();
82 void handle_write_image_state(int r);
83
84 void update_primary_snapshot();
85 void handle_update_primary_snapshot(int r);
86
87 void finish(int r);
88};
89
90} // namespace snapshot
91} // namespace mirror
92} // namespace librbd
93
94extern template class librbd::mirror::snapshot::SetImageStateRequest<librbd::ImageCtx>;
95
96#endif // CEPH_LIBRBD_MIRROR_SNAPSHOT_SET_IMAGE_STATE_REQUEST_H