]>
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_JOURNAL_DEMOTE_REQUEST_H | |
5 | #define CEPH_LIBRBD_JOURNAL_DEMOTE_REQUEST_H | |
6 | ||
9f95a23c | 7 | #include "common/ceph_mutex.h" |
7c673cae FG |
8 | #include "cls/journal/cls_journal_types.h" |
9 | #include "journal/Future.h" | |
10 | #include "librbd/journal/Types.h" | |
11 | #include "librbd/journal/TypeTraits.h" | |
12 | ||
13 | struct Context; | |
14 | ||
15 | namespace librbd { | |
16 | ||
17 | struct ImageCtx; | |
18 | ||
19 | namespace journal { | |
20 | ||
21 | template <typename ImageCtxT = librbd::ImageCtx> | |
22 | class DemoteRequest { | |
23 | public: | |
24 | static DemoteRequest *create(ImageCtxT &image_ctx, Context *on_finish) { | |
25 | return new DemoteRequest(image_ctx, on_finish); | |
26 | } | |
27 | ||
28 | DemoteRequest(ImageCtxT &image_ctx, Context *on_finish); | |
29 | ~DemoteRequest(); | |
30 | ||
31 | void send(); | |
32 | ||
33 | private: | |
34 | /** | |
35 | * @verbatim | |
36 | * | |
37 | * <start> | |
38 | * | | |
39 | * v | |
40 | * OPEN_JOURNALER * * * * * | |
41 | * | * | |
42 | * v * | |
43 | * ALLOCATE_TAG * * * * * * | |
44 | * | * | |
45 | * v * | |
46 | * APPEND_EVENT * * * * | |
47 | * | * * | |
48 | * v * * | |
49 | * COMMIT_EVENT * * | |
50 | * | * * | |
51 | * v * * | |
52 | * STOP_APPEND <* * * * | |
53 | * | * | |
54 | * v * | |
55 | * SHUT_DOWN_JOURNALER <* * | |
56 | * | | |
57 | * v | |
58 | * <finish> | |
59 | * | |
60 | * @endverbatim | |
61 | */ | |
62 | ||
63 | typedef typename TypeTraits<ImageCtxT>::Journaler Journaler; | |
64 | typedef typename TypeTraits<ImageCtxT>::Future Future; | |
65 | ||
66 | ImageCtxT &m_image_ctx; | |
67 | Context *m_on_finish; | |
68 | ||
69 | Journaler *m_journaler = nullptr; | |
70 | int m_ret_val = 0; | |
71 | ||
9f95a23c | 72 | ceph::mutex m_lock; |
7c673cae FG |
73 | ImageClientMeta m_client_meta; |
74 | uint64_t m_tag_tid = 0; | |
75 | TagData m_tag_data; | |
76 | ||
77 | cls::journal::Tag m_tag; | |
78 | Future m_future; | |
79 | ||
80 | void open_journaler(); | |
81 | void handle_open_journaler(int r); | |
82 | ||
83 | void allocate_tag(); | |
84 | void handle_allocate_tag(int r); | |
85 | ||
86 | void append_event(); | |
87 | void handle_append_event(int r); | |
88 | ||
89 | void commit_event(); | |
90 | void handle_commit_event(int r); | |
91 | ||
92 | void stop_append(); | |
93 | void handle_stop_append(int r); | |
94 | ||
95 | void shut_down_journaler(); | |
96 | void handle_shut_down_journaler(int r); | |
97 | ||
98 | void finish(int r); | |
99 | ||
100 | }; | |
101 | ||
102 | } // namespace journal | |
103 | } // namespace librbd | |
104 | ||
105 | extern template class librbd::journal::DemoteRequest<librbd::ImageCtx>; | |
106 | ||
107 | #endif // CEPH_LIBRBD_JOURNAL_DEMOTE_REQUEST_H |