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 "include/buffer.h"
9 #include "librbd/Types.h"
20 template <typename ImageCtxT
= ImageCtx
>
21 class SnapshotRemoveRequest
: public Request
<ImageCtxT
> {
31 * v (skip if unsupported)
34 * v (skip if unnecessary)
35 * LIST_CHILDREN <-------------\
37 * v (skip if unnecessary) | (repeat as needed)
38 * DETACH_STALE_CHILD ---------/
40 * v (skip if unnecessary)
43 * v (skip if disabled/in-use)
46 * v (skip if not mirror snapshot)
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
,
68 SnapshotRemoveRequest(ImageCtxT
&image_ctx
, Context
*on_finish
,
69 const cls::rbd::SnapshotNamespace
&snap_namespace
,
70 const std::string
&snap_name
,
74 void send_op() override
;
75 bool should_complete(int r
) override
;
77 journal::Event
create_event(uint64_t op_tid
) const override
{
78 return journal::SnapRemoveEvent(op_tid
, m_snap_namespace
, m_snap_name
);
82 cls::rbd::SnapshotNamespace m_snap_namespace
;
83 cls::rbd::ChildImageSpecs m_child_images
;
84 std::string m_snap_name
;
86 bool m_trashed_snapshot
= false;
87 bool m_child_attached
= false;
89 ceph::bufferlist m_out_bl
;
92 void handle_trash_snap(int r
);
95 void handle_get_snap(int r
);
98 void handle_list_children(int r
);
100 void detach_stale_child();
101 void handle_detach_stale_child(int r
);
104 void handle_detach_child(int r
);
106 void remove_object_map();
107 void handle_remove_object_map(int r
);
109 void remove_image_state();
110 void handle_remove_image_state(int r
);
112 void release_snap_id();
113 void handle_release_snap_id(int r
);
116 void handle_remove_snap(int r
);
118 void remove_snap_context();
119 int scan_for_parents(cls::rbd::ParentImageSpec
&pspec
);
123 } // namespace operation
124 } // namespace librbd
126 extern template class librbd::operation::SnapshotRemoveRequest
<librbd::ImageCtx
>;
128 #endif // CEPH_LIBRBD_OPERATION_SNAPSHOT_REMOVE_REQUEST_H