]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/operation/SnapshotRemoveRequest.h
update sources to ceph Nautilus 14.2.1
[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)
35 * DETACH_CHILD
36 * |
37 * v (skip if disabled/in-use)
38 * REMOVE_OBJECT_MAP
39 * |
40 * v (skip if in-use)
41 * RELEASE_SNAP_ID
42 * |
43 * v (skip if in-use)
44 * REMOVE_SNAP
45 * |
46 * v
47 * <finish>
7c673cae
FG
48 *
49 * @endverbatim
7c673cae 50 */
11fdf7f2
TL
51
52 static SnapshotRemoveRequest *create(
53 ImageCtxT &image_ctx, const cls::rbd::SnapshotNamespace &snap_namespace,
54 const std::string &snap_name, uint64_t snap_id, Context *on_finish) {
55 return new SnapshotRemoveRequest(image_ctx, on_finish, snap_namespace,
56 snap_name, snap_id);
57 }
7c673cae
FG
58
59 SnapshotRemoveRequest(ImageCtxT &image_ctx, Context *on_finish,
60 const cls::rbd::SnapshotNamespace &snap_namespace,
61 const std::string &snap_name,
62 uint64_t snap_id);
63
64protected:
65 void send_op() override;
66 bool should_complete(int r) override;
67
68 journal::Event create_event(uint64_t op_tid) const override {
69 return journal::SnapRemoveEvent(op_tid, m_snap_namespace, m_snap_name);
70 }
71
72private:
73 cls::rbd::SnapshotNamespace m_snap_namespace;
74 std::string m_snap_name;
75 uint64_t m_snap_id;
11fdf7f2
TL
76 bool m_trashed_snapshot = false;
77 bool m_child_attached = false;
7c673cae 78
11fdf7f2
TL
79 ceph::bufferlist m_out_bl;
80
81 void trash_snap();
82 void handle_trash_snap(int r);
83
84 void get_snap();
85 void handle_get_snap(int r);
86
87 void detach_child();
88 void handle_detach_child(int r);
89
90 void remove_object_map();
91 void handle_remove_object_map(int r);
92
93 void release_snap_id();
94 void handle_release_snap_id(int r);
7c673cae 95
11fdf7f2
TL
96 void remove_snap();
97 void handle_remove_snap(int r);
7c673cae
FG
98
99 void remove_snap_context();
11fdf7f2 100 int scan_for_parents(cls::rbd::ParentImageSpec &pspec);
7c673cae
FG
101
102};
103
104} // namespace operation
105} // namespace librbd
106
107extern template class librbd::operation::SnapshotRemoveRequest<librbd::ImageCtx>;
108
109#endif // CEPH_LIBRBD_OPERATION_SNAPSHOT_REMOVE_REQUEST_H