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_UNPROTECT_REQUEST_H
5 #define CEPH_LIBRBD_OPERATION_SNAPSHOT_UNPROTECT_REQUEST_H
7 #include "librbd/operation/Request.h"
18 template <typename ImageCtxT = ImageCtx>
19 class SnapshotUnprotectRequest : public Request<ImageCtxT> {
22 * Snap Unprotect goes through the following state machine:
29 * STATE_UNPROTECT_SNAP_START
32 * STATE_SCAN_POOL_CHILDREN * * * * > STATE_UNPROTECT_SNAP_ROLLBACK
35 * STATE_UNPROTECT_SNAP_FINISH |
38 * <finish> <----------------------------/
42 * If the unprotect operation needs to abort, the error path is followed
43 * to rollback the unprotect in-progress status on the image.
46 STATE_UNPROTECT_SNAP_START,
47 STATE_SCAN_POOL_CHILDREN,
48 STATE_UNPROTECT_SNAP_FINISH,
49 STATE_UNPROTECT_SNAP_ROLLBACK
52 SnapshotUnprotectRequest(ImageCtxT &image_ctx, Context *on_finish,
53 const cls::rbd::SnapshotNamespace &snap_namespace,
54 const std::string &snap_name);
57 void send_op() override;
58 bool should_complete(int r) override;
60 int filter_return_code(int r) const override {
67 journal::Event create_event(uint64_t op_tid) const override {
68 return journal::SnapUnprotectEvent(op_tid, m_snap_namespace, m_snap_name);
72 cls::rbd::SnapshotNamespace m_snap_namespace;
73 std::string m_snap_name;
79 bool should_complete_error();
81 void send_unprotect_snap_start();
82 void send_scan_pool_children();
83 void send_unprotect_snap_finish();
84 void send_unprotect_snap_rollback();
86 int verify_and_send_unprotect_snap_start();
89 } // namespace operation
92 extern template class librbd::operation::SnapshotUnprotectRequest<librbd::ImageCtx>;
94 #endif // CEPH_LIBRBD_OPERATION_SNAPSHOT_UNPROTECT_REQUEST_H