]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/operation/SnapshotProtectRequest.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / librbd / operation / SnapshotProtectRequest.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_OPERATION_SNAPSHOT_PROTECT_REQUEST_H
5 #define CEPH_LIBRBD_OPERATION_SNAPSHOT_PROTECT_REQUEST_H
6
7 #include "librbd/operation/Request.h"
8 #include <string>
9
10 class Context;
11
12 namespace librbd {
13
14 class ImageCtx;
15
16 namespace operation {
17
18 template <typename ImageCtxT = ImageCtx>
19 class SnapshotProtectRequest : public Request<ImageCtxT> {
20 public:
21 /**
22 * Snap Protect goes through the following state machine:
23 *
24 * @verbatim
25 *
26 * <start>
27 * |
28 * v
29 * STATE_PROTECT_SNAP
30 * |
31 * v
32 * <finish>
33 *
34 * @endverbatim
35 *
36 */
37 enum State {
38 STATE_PROTECT_SNAP
39 };
40
41 SnapshotProtectRequest(ImageCtxT &image_ctx, Context *on_finish,
42 const cls::rbd::SnapshotNamespace &snap_namespace,
43 const std::string &snap_name);
44
45 protected:
46 void send_op() override;
47 bool should_complete(int r) override;
48
49 journal::Event create_event(uint64_t op_tid) const override {
50 return journal::SnapProtectEvent(op_tid, m_snap_namespace, m_snap_name);
51 }
52
53 private:
54 cls::rbd::SnapshotNamespace m_snap_namespace;
55 std::string m_snap_name;
56 State m_state;
57
58 void send_protect_snap();
59
60 int verify_and_send_protect_snap();
61 };
62
63 } // namespace operation
64 } // namespace librbd
65
66 extern template class librbd::operation::SnapshotProtectRequest<librbd::ImageCtx>;
67
68 #endif // CEPH_LIBRBD_OPERATION_SNAPSHOT_PROTECT_REQUEST_H