1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_OPERATION_SNAPSHOT_REMOVE_REQUEST_H
5 #define CEPH_LIBRBD_OPERATION_SNAPSHOT_REMOVE_REQUEST_H
7 #include "librbd/operation/Request.h"
8 #include "librbd/Types.h"
19 template <typename ImageCtxT = ImageCtx>
20 class SnapshotRemoveRequest : public Request<ImageCtxT> {
23 * Snap Remove goes through the following state machine:
30 * . STATE_REMOVE_OBJECT_MAP
33 * . . > STATE_REMOVE_CHILD .
38 * . . > STATE_REMOVE_SNAP
41 * STATE_RELEASE_SNAP_ID
48 * The _REMOVE_OBJECT_MAP state is skipped if the object map is not enabled.
49 * The _REMOVE_CHILD state is skipped if the parent is still in-use.
52 STATE_REMOVE_OBJECT_MAP,
55 STATE_RELEASE_SNAP_ID,
59 SnapshotRemoveRequest(ImageCtxT &image_ctx, Context *on_finish,
60 const cls::rbd::SnapshotNamespace &snap_namespace,
61 const std::string &snap_name,
65 void send_op() override;
66 bool should_complete(int r) override;
68 journal::Event create_event(uint64_t op_tid) const override {
69 return journal::SnapRemoveEvent(op_tid, m_snap_namespace, m_snap_name);
73 cls::rbd::SnapshotNamespace m_snap_namespace;
74 std::string m_snap_name;
78 int filter_state_return_code(int r) const {
79 if (m_state == STATE_REMOVE_CHILD && r == -ENOENT) {
85 void send_remove_object_map();
86 void send_remove_child();
87 void send_remove_snap();
88 void send_release_snap_id();
90 void remove_snap_context();
91 int scan_for_parents(ParentSpec &pspec);
95 } // namespace operation
98 extern template class librbd::operation::SnapshotRemoveRequest<librbd::ImageCtx>;
100 #endif // CEPH_LIBRBD_OPERATION_SNAPSHOT_REMOVE_REQUEST_H