]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/object_map/SnapshotRollbackRequest.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / librbd / object_map / SnapshotRollbackRequest.h
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_ROLLBACK_REQUEST_H
5 #define CEPH_LIBRBD_OBJECT_MAP_SNAPSHOT_ROLLBACK_REQUEST_H
6
7 #include "include/int_types.h"
8 #include "librbd/object_map/Request.h"
9
10 class Context;
11
12 namespace librbd {
13
14 class ImageCtx;
15
16 namespace object_map {
17
18 class SnapshotRollbackRequest : public Request {
19 public:
20 /**
21 * Snapshot rollback goes through the following state machine:
22 *
23 * @verbatim
24 *
25 * <start>
26 * |
27 * v (error)
28 * STATE_READ_MAP * * * * > STATE_INVALIDATE_MAP
29 * | |
30 * v v
31 * STATE_WRITE_MAP -------> <finish>
32 *
33 * @endverbatim
34 *
35 * If an error occurs within the READ_MAP state, the associated snapshot's
36 * object map will be flagged as invalid. Otherwise, an error from any state
37 * will result in the HEAD object map being flagged as invalid via the base
38 * class.
39 */
40 enum State {
41 STATE_READ_MAP,
42 STATE_INVALIDATE_MAP,
43 STATE_WRITE_MAP
44 };
45
46 SnapshotRollbackRequest(ImageCtx &image_ctx, uint64_t snap_id,
47 Context *on_finish)
48 : Request(image_ctx, CEPH_NOSNAP, on_finish),
49 m_snap_id(snap_id), m_ret_val(0) {
50 assert(snap_id != CEPH_NOSNAP);
51 }
52
53 void send() override;
54
55 protected:
56 bool should_complete(int r) override;
57
58 private:
59 State m_state;
60 uint64_t m_snap_id;
61 int m_ret_val;
62
63 bufferlist m_read_bl;
64
65 void send_read_map();
66 void send_invalidate_map();
67 void send_write_map();
68
69 };
70
71 } // namespace object_map
72 } // namespace librbd
73
74 #endif // CEPH_LIBRBD_OBJECT_MAP_SNAPSHOT_ROLLBACK_REQUEST_H