]>
Commit | Line | Data |
---|---|---|
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_OBJECT_MAP_SNAPSHOT_REMOVE_REQUEST_H | |
5 | #define CEPH_LIBRBD_OBJECT_MAP_SNAPSHOT_REMOVE_REQUEST_H | |
6 | ||
7 | #include "include/int_types.h" | |
8 | #include "include/buffer.h" | |
9 | #include "common/bit_vector.hpp" | |
10 | #include "librbd/AsyncRequest.h" | |
11 | ||
12 | namespace librbd { | |
13 | namespace object_map { | |
14 | ||
15 | class SnapshotRemoveRequest : public AsyncRequest<> { | |
16 | public: | |
17 | /** | |
18 | * Snapshot rollback goes through the following state machine: | |
19 | * | |
20 | * @verbatim | |
21 | * | |
22 | * <start> -----------> STATE_LOAD_MAP ----\ | |
23 | * . * | | |
24 | * . * (error) | | |
25 | * . (invalid object map) v | | |
26 | * . . . > STATE_INVALIDATE_NEXT_MAP | | |
27 | * . | | | |
28 | * . | | | |
29 | * . (fast diff disabled) v v | |
30 | * . . . . . . . . . . > STATE_REMOVE_MAP | |
31 | * | | |
32 | * v | |
33 | * <finish> | |
34 | * | |
35 | * @endverbatim | |
36 | * | |
37 | * The _LOAD_MAP state is skipped if the fast diff feature is disabled. | |
38 | * If the fast diff feature is enabled and the snapshot is flagged as | |
39 | * invalid, the next snapshot / HEAD object mapis flagged as invalid; | |
40 | * otherwise, the state machine proceeds to remove the object map. | |
41 | */ | |
7c673cae FG |
42 | |
43 | SnapshotRemoveRequest(ImageCtx &image_ctx, ceph::BitVector<2> *object_map, | |
44 | uint64_t snap_id, Context *on_finish) | |
45 | : AsyncRequest(image_ctx, on_finish), m_object_map(*object_map), | |
46 | m_snap_id(snap_id), m_next_snap_id(CEPH_NOSNAP) { | |
47 | } | |
48 | ||
49 | void send() override; | |
50 | ||
51 | protected: | |
91327a77 AA |
52 | bool should_complete(int r) override { |
53 | return true; | |
7c673cae FG |
54 | } |
55 | ||
56 | private: | |
7c673cae FG |
57 | ceph::BitVector<2> &m_object_map; |
58 | uint64_t m_snap_id; | |
59 | uint64_t m_next_snap_id; | |
60 | ||
91327a77 AA |
61 | uint64_t m_flags = 0; |
62 | ||
7c673cae FG |
63 | ceph::BitVector<2> m_snap_object_map; |
64 | bufferlist m_out_bl; | |
65 | ||
91327a77 AA |
66 | void load_map(); |
67 | void handle_load_map(int r); | |
68 | ||
69 | void remove_snapshot(); | |
70 | void handle_remove_snapshot(int r); | |
71 | ||
72 | void invalidate_next_map(); | |
73 | void handle_invalidate_next_map(int r); | |
74 | ||
75 | void remove_map(); | |
76 | void handle_remove_map(int r); | |
7c673cae FG |
77 | |
78 | void compute_next_snap_id(); | |
79 | void update_object_map(); | |
80 | }; | |
81 | ||
82 | } // namespace object_map | |
83 | } // namespace librbd | |
84 | ||
85 | #endif // CEPH_LIBRBD_OBJECT_MAP_SNAPSHOT_REMOVE_REQUEST_H |