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