]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/exclusive_lock/PreReleaseRequest.h
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / librbd / exclusive_lock / PreReleaseRequest.h
CommitLineData
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_EXCLUSIVE_LOCK_PRE_RELEASE_REQUEST_H
5#define CEPH_LIBRBD_EXCLUSIVE_LOCK_PRE_RELEASE_REQUEST_H
6
7#include "librbd/ImageCtx.h"
8#include <string>
9
31f18b77 10class AsyncOpTracker;
7c673cae
FG
11class Context;
12
13namespace librbd {
14
15struct ImageCtx;
16
17namespace exclusive_lock {
18
f67539c2
TL
19template <typename> struct ImageDispatch;
20
7c673cae
FG
21template <typename ImageCtxT = ImageCtx>
22class PreReleaseRequest {
23public:
f67539c2
TL
24 static PreReleaseRequest* create(ImageCtxT &image_ctx,
25 ImageDispatch<ImageCtxT>* image_dispatch,
26 bool shutting_down,
31f18b77 27 AsyncOpTracker &async_op_tracker,
7c673cae
FG
28 Context *on_finish);
29
30 ~PreReleaseRequest();
31 void send();
32
33private:
34 /**
35 * @verbatim
36 *
37 * <start>
38 * |
39 * v
7c673cae
FG
40 * CANCEL_OP_REQUESTS
41 * |
42 * v
f67539c2 43 * SET_REQUIRE_LOCK
7c673cae
FG
44 * |
45 * v
31f18b77
FG
46 * WAIT_FOR_OPS
47 * |
48 * v
f67539c2
TL
49 * PREPARE_LOCK
50 * |
51 * v
52 * PROCESS_PLUGIN_RELEASE
53 * |
54 * v
55 * SHUT_DOWN_IMAGE_CACHE
56 * |
57 * v
7c673cae
FG
58 * INVALIDATE_CACHE
59 * |
60 * v
f67539c2
TL
61 * FLUSH_IO
62 * |
63 * v
7c673cae
FG
64 * FLUSH_NOTIFIES . . . . . . . . . . . . . .
65 * | .
66 * v .
67 * CLOSE_JOURNAL .
68 * | (journal disabled, .
69 * v object map enabled) .
70 * CLOSE_OBJECT_MAP < . . . . . . . . . . . .
71 * | .
72 * v (object map disabled) .
73 * <finish> < . . . . . . . . . . . . . . . . .
74 *
75 * @endverbatim
76 */
77
f67539c2
TL
78 PreReleaseRequest(ImageCtxT &image_ctx,
79 ImageDispatch<ImageCtxT>* image_dispatch,
80 bool shutting_down, AsyncOpTracker &async_op_tracker,
81 Context *on_finish);
7c673cae
FG
82
83 ImageCtxT &m_image_ctx;
f67539c2 84 ImageDispatch<ImageCtxT>* m_image_dispatch;
7c673cae 85 bool m_shutting_down;
31f18b77
FG
86 AsyncOpTracker &m_async_op_tracker;
87 Context *m_on_finish;
7c673cae 88
31f18b77 89 int m_error_result = 0;
7c673cae 90
31f18b77
FG
91 decltype(m_image_ctx.object_map) m_object_map = nullptr;
92 decltype(m_image_ctx.journal) m_journal = nullptr;
7c673cae 93
7c673cae
FG
94 void send_cancel_op_requests();
95 void handle_cancel_op_requests(int r);
96
f67539c2
TL
97 void send_set_require_lock();
98 void handle_set_require_lock(int r);
7c673cae 99
31f18b77
FG
100 void send_wait_for_ops();
101 void handle_wait_for_ops(int r);
102
f67539c2
TL
103 void send_prepare_lock();
104 void handle_prepare_lock(int r);
105
106 void send_process_plugin_release_lock();
107 void handle_process_plugin_release_lock(int r);
108
11fdf7f2 109 void send_invalidate_cache();
7c673cae
FG
110 void handle_invalidate_cache(int r);
111
f67539c2
TL
112 void send_flush_io();
113 void handle_flush_io(int r);
114
7c673cae
FG
115 void send_flush_notifies();
116 void handle_flush_notifies(int r);
117
118 void send_close_journal();
119 void handle_close_journal(int r);
120
121 void send_close_object_map();
122 void handle_close_object_map(int r);
123
124 void send_unlock();
125
126 void finish();
127
128 void save_result(int result) {
129 if (m_error_result == 0 && result < 0) {
130 m_error_result = result;
131 }
132 }
133
134};
135
136} // namespace exclusive_lock
137} // namespace librbd
138
139#endif // CEPH_LIBRBD_EXCLUSIVE_LOCK_PRE_RELEASE_REQUEST_H