]>
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_CREATE_REQUEST_H | |
5 | #define CEPH_LIBRBD_JOURNAL_CREATE_REQUEST_H | |
6 | ||
7 | #include "include/int_types.h" | |
8 | #include "include/buffer.h" | |
9 | #include "include/rados/librados.hpp" | |
10 | #include "include/rbd/librbd.hpp" | |
9f95a23c | 11 | #include "common/ceph_mutex.h" |
a4b75251 | 12 | #include "common/Timer.h" |
7c673cae FG |
13 | #include "librbd/ImageCtx.h" |
14 | #include "journal/Journaler.h" | |
15 | #include "librbd/journal/Types.h" | |
16 | #include "librbd/journal/TypeTraits.h" | |
17 | #include "cls/journal/cls_journal_types.h" | |
18 | ||
19 | using librados::IoCtx; | |
20 | using journal::Journaler; | |
21 | ||
22 | class Context; | |
23 | class ContextWQ; | |
7c673cae FG |
24 | |
25 | namespace journal { | |
26 | class Journaler; | |
27 | } | |
28 | ||
29 | namespace librbd { | |
30 | ||
31 | class ImageCtx; | |
32 | ||
33 | namespace journal { | |
34 | ||
35 | template<typename ImageCtxT = ImageCtx> | |
36 | class CreateRequest { | |
37 | public: | |
38 | static CreateRequest *create(IoCtx &ioctx, const std::string &imageid, | |
39 | uint8_t order, uint8_t splay_width, | |
40 | const std::string &object_pool, | |
41 | uint64_t tag_class, TagData &tag_data, | |
42 | const std::string &client_id, | |
43 | ContextWQ *op_work_queue, Context *on_finish) { | |
44 | return new CreateRequest(ioctx, imageid, order, splay_width, object_pool, | |
45 | tag_class, tag_data, client_id, op_work_queue, | |
46 | on_finish); | |
47 | } | |
48 | ||
49 | void send(); | |
50 | ||
51 | private: | |
52 | typedef typename TypeTraits<ImageCtxT>::Journaler Journaler; | |
53 | ||
54 | CreateRequest(IoCtx &ioctx, const std::string &imageid, uint8_t order, | |
55 | uint8_t splay_width, const std::string &object_pool, | |
56 | uint64_t tag_class, TagData &tag_data, | |
57 | const std::string &client_id, ContextWQ *op_work_queue, | |
58 | Context *on_finish); | |
59 | ||
60 | IoCtx &m_ioctx; | |
61 | std::string m_image_id; | |
62 | uint8_t m_order; | |
63 | uint8_t m_splay_width; | |
64 | std::string m_object_pool; | |
65 | uint64_t m_tag_class; | |
66 | TagData m_tag_data; | |
67 | std::string m_image_client_id; | |
68 | ContextWQ *m_op_work_queue; | |
69 | Context *m_on_finish; | |
70 | ||
71 | CephContext *m_cct; | |
72 | cls::journal::Tag m_tag; | |
73 | bufferlist m_bl; | |
74 | Journaler *m_journaler; | |
75 | SafeTimer *m_timer; | |
9f95a23c | 76 | ceph::mutex *m_timer_lock; |
7c673cae FG |
77 | int m_r_saved; |
78 | ||
79 | int64_t m_pool_id = -1; | |
80 | ||
81 | void get_pool_id(); | |
82 | ||
83 | void create_journal(); | |
84 | Context *handle_create_journal(int *result); | |
85 | ||
86 | void allocate_journal_tag(); | |
87 | Context *handle_journal_tag(int *result); | |
88 | ||
89 | void register_client(); | |
90 | Context *handle_register_client(int *result); | |
91 | ||
92 | void shut_down_journaler(int r); | |
93 | Context *handle_journaler_shutdown(int *result); | |
94 | ||
95 | void remove_journal(); | |
96 | Context *handle_remove_journal(int *result); | |
97 | ||
98 | void complete(int r); | |
99 | }; | |
100 | ||
101 | } // namespace journal | |
102 | } // namespace librbd | |
103 | ||
104 | extern template class librbd::journal::CreateRequest<librbd::ImageCtx>; | |
105 | ||
106 | #endif /* CEPH_LIBRBD_JOURNAL_CREATE_REQUEST_H */ |