]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/operation/SnapshotRemoveRequest.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / librbd / operation / SnapshotRemoveRequest.h
CommitLineData
7c673cae
FG
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_REMOVE_REQUEST_H
5#define CEPH_LIBRBD_OPERATION_SNAPSHOT_REMOVE_REQUEST_H
6
7#include "librbd/operation/Request.h"
11fdf7f2 8#include "include/buffer.h"
7c673cae
FG
9#include "librbd/Types.h"
10#include <string>
11
12class Context;
13
14namespace librbd {
15
16class ImageCtx;
17
18namespace operation {
19
20template <typename ImageCtxT = ImageCtx>
21class SnapshotRemoveRequest : public Request<ImageCtxT> {
22public:
23 /**
7c673cae
FG
24 * @verbatim
25 *
11fdf7f2
TL
26 * <start>
27 * |
28 * v
29 * TRASH_SNAP
30 * |
31 * v (skip if unsupported)
32 * GET_SNAP
33 * |
34 * v (skip if unnecessary)
92f5a8d4
TL
35 * LIST_CHILDREN <-------------\
36 * | |
37 * v (skip if unnecessary) | (repeat as needed)
38 * DETACH_STALE_CHILD ---------/
39 * |
40 * v (skip if unnecessary)
11fdf7f2
TL
41 * DETACH_CHILD
42 * |
43 * v (skip if disabled/in-use)
44 * REMOVE_OBJECT_MAP
45 * |
9f95a23c
TL
46 * v (skip if not mirror snpashot)
47 * REMOVE_IMAGE_STATE
48 * |
11fdf7f2
TL
49 * v (skip if in-use)
50 * RELEASE_SNAP_ID
51 * |
52 * v (skip if in-use)
53 * REMOVE_SNAP
54 * |
55 * v
56 * <finish>
7c673cae
FG
57 *
58 * @endverbatim
7c673cae 59 */
11fdf7f2
TL
60
61 static SnapshotRemoveRequest *create(
62 ImageCtxT &image_ctx, const cls::rbd::SnapshotNamespace &snap_namespace,
63 const std::string &snap_name, uint64_t snap_id, Context *on_finish) {
64 return new SnapshotRemoveRequest(image_ctx, on_finish, snap_namespace,
65 snap_name, snap_id);
66 }
7c673cae
FG
67
68 SnapshotRemoveRequest(ImageCtxT &image_ctx, Context *on_finish,
69 const cls::rbd::SnapshotNamespace &snap_namespace,
70 const std::string &snap_name,
71 uint64_t snap_id);
72
73protected:
74 void send_op() override;
75 bool should_complete(int r) override;
76
77 journal::Event create_event(uint64_t op_tid) const override {
78 return journal::SnapRemoveEvent(op_tid, m_snap_namespace, m_snap_name);
79 }
80
81private:
82 cls::rbd::SnapshotNamespace m_snap_namespace;
92f5a8d4 83 cls::rbd::ChildImageSpecs m_child_images;
7c673cae
FG
84 std::string m_snap_name;
85 uint64_t m_snap_id;
11fdf7f2
TL
86 bool m_trashed_snapshot = false;
87 bool m_child_attached = false;
7c673cae 88
11fdf7f2
TL
89 ceph::bufferlist m_out_bl;
90
91 void trash_snap();
92 void handle_trash_snap(int r);
93
94 void get_snap();
95 void handle_get_snap(int r);
96
92f5a8d4
TL
97 void list_children();
98 void handle_list_children(int r);
99
100 void detach_stale_child();
101 void handle_detach_stale_child(int r);
102
11fdf7f2
TL
103 void detach_child();
104 void handle_detach_child(int r);
105
106 void remove_object_map();
107 void handle_remove_object_map(int r);
108
9f95a23c
TL
109 void remove_image_state();
110 void handle_remove_image_state(int r);
111
11fdf7f2
TL
112 void release_snap_id();
113 void handle_release_snap_id(int r);
7c673cae 114
11fdf7f2
TL
115 void remove_snap();
116 void handle_remove_snap(int r);
7c673cae
FG
117
118 void remove_snap_context();
11fdf7f2 119 int scan_for_parents(cls::rbd::ParentImageSpec &pspec);
7c673cae
FG
120
121};
122
123} // namespace operation
124} // namespace librbd
125
126extern template class librbd::operation::SnapshotRemoveRequest<librbd::ImageCtx>;
127
128#endif // CEPH_LIBRBD_OPERATION_SNAPSHOT_REMOVE_REQUEST_H