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_OBJECT_MAP_SNAPSHOT_REMOVE_REQUEST_H
5 #define CEPH_LIBRBD_OBJECT_MAP_SNAPSHOT_REMOVE_REQUEST_H
7 #include "include/int_types.h"
8 #include "include/buffer.h"
9 #include "common/bit_vector.hpp"
10 #include "librbd/AsyncRequest.h"
13 namespace object_map {
15 class SnapshotRemoveRequest : public AsyncRequest<> {
18 * Snapshot rollback goes through the following state machine:
22 * <start> -----------> STATE_LOAD_MAP ----\
25 * . (invalid object map) v |
26 * . . . > STATE_INVALIDATE_NEXT_MAP |
29 * . (fast diff disabled) v v
30 * . . . . . . . . . . > STATE_REMOVE_MAP
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.
44 STATE_REMOVE_SNAPSHOT,
45 STATE_INVALIDATE_NEXT_MAP,
49 SnapshotRemoveRequest(ImageCtx &image_ctx, ceph::BitVector<2> *object_map,
50 uint64_t snap_id, Context *on_finish)
51 : AsyncRequest(image_ctx, on_finish), m_object_map(*object_map),
52 m_snap_id(snap_id), m_next_snap_id(CEPH_NOSNAP) {
58 bool should_complete(int r) override;
60 int filter_return_code(int r) const override {
61 if ((m_state == STATE_LOAD_MAP || m_state == STATE_REMOVE_MAP) &&
70 ceph::BitVector<2> &m_object_map;
72 uint64_t m_next_snap_id;
74 ceph::BitVector<2> m_snap_object_map;
78 void send_remove_snapshot();
79 void send_invalidate_next_map();
80 void send_remove_map();
82 void compute_next_snap_id();
83 void update_object_map();
86 } // namespace object_map
89 #endif // CEPH_LIBRBD_OBJECT_MAP_SNAPSHOT_REMOVE_REQUEST_H