]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/journal/OpenRequest.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / librbd / journal / OpenRequest.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_JOURNAL_OPEN_REQUEST_H
5 #define CEPH_LIBRBD_JOURNAL_OPEN_REQUEST_H
6
7 #include "common/ceph_mutex.h"
8 #include "include/int_types.h"
9 #include "librbd/journal/TypeTraits.h"
10
11 struct Context;
12
13 namespace librbd {
14
15 struct ImageCtx;
16
17 namespace journal {
18
19 struct ImageClientMeta;
20 struct TagData;
21
22 template <typename ImageCtxT = ImageCtx>
23 class OpenRequest {
24 public:
25 typedef typename TypeTraits<ImageCtxT>::Journaler Journaler;
26
27 static OpenRequest* create(ImageCtxT *image_ctx, Journaler *journaler,
28 ceph::mutex *lock, journal::ImageClientMeta *client_meta,
29 uint64_t *tag_tid, journal::TagData *tag_data,
30 Context *on_finish) {
31 return new OpenRequest(image_ctx, journaler, lock, client_meta, tag_tid,
32 tag_data, on_finish);
33 }
34
35 OpenRequest(ImageCtxT *image_ctx, Journaler *journaler, ceph::mutex *lock,
36 journal::ImageClientMeta *client_meta, uint64_t *tag_tid,
37 journal::TagData *tag_data, Context *on_finish);
38
39 void send();
40
41 private:
42 /**
43 * @verbatim
44 *
45 * <start>
46 * |
47 * v
48 * INIT
49 * |
50 * v
51 * GET_TAGS
52 * |
53 * v
54 * <finish>
55 *
56 * @endverbatim
57 */
58
59
60 ImageCtxT *m_image_ctx;
61 Journaler *m_journaler;
62 ceph::mutex *m_lock;
63 journal::ImageClientMeta *m_client_meta;
64 uint64_t *m_tag_tid;
65 journal::TagData *m_tag_data;
66 Context *m_on_finish;
67
68 uint64_t m_tag_class = 0;
69
70 void send_init();
71 void handle_init(int r);
72
73 void send_get_tags();
74 void handle_get_tags(int r);
75
76 void finish(int r);
77
78 };
79
80 } // namespace journal
81 } // namespace librbd
82
83 extern template class librbd::journal::OpenRequest<librbd::ImageCtx>;
84
85 #endif // CEPH_LIBRBD_JOURNAL_OPEN_REQUEST_H