]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/exclusive_lock/PreReleaseRequest.h
update sources to v12.1.0
[ceph.git] / ceph / src / librbd / exclusive_lock / PreReleaseRequest.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_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
10 class AsyncOpTracker;
11 class Context;
12
13 namespace librbd {
14
15 struct ImageCtx;
16
17 namespace exclusive_lock {
18
19 template <typename ImageCtxT = ImageCtx>
20 class PreReleaseRequest {
21 public:
22 static PreReleaseRequest* create(ImageCtxT &image_ctx, bool shutting_down,
23 AsyncOpTracker &async_op_tracker,
24 Context *on_finish);
25
26 ~PreReleaseRequest();
27 void send();
28
29 private:
30 /**
31 * @verbatim
32 *
33 * <start>
34 * |
35 * v
36 * PREPARE_LOCK
37 * |
38 * v
39 * CANCEL_OP_REQUESTS
40 * |
41 * v
42 * BLOCK_WRITES
43 * |
44 * v
45 * WAIT_FOR_OPS
46 * |
47 * v
48 * INVALIDATE_CACHE
49 * |
50 * v
51 * FLUSH_NOTIFIES . . . . . . . . . . . . . .
52 * | .
53 * v .
54 * CLOSE_JOURNAL .
55 * | (journal disabled, .
56 * v object map enabled) .
57 * CLOSE_OBJECT_MAP < . . . . . . . . . . . .
58 * | .
59 * v (object map disabled) .
60 * <finish> < . . . . . . . . . . . . . . . . .
61 *
62 * @endverbatim
63 */
64
65 PreReleaseRequest(ImageCtxT &image_ctx, bool shutting_down,
66 AsyncOpTracker &async_op_tracker, Context *on_finish);
67
68 ImageCtxT &m_image_ctx;
69 bool m_shutting_down;
70 AsyncOpTracker &m_async_op_tracker;
71 Context *m_on_finish;
72
73 int m_error_result = 0;
74
75 decltype(m_image_ctx.object_map) m_object_map = nullptr;
76 decltype(m_image_ctx.journal) m_journal = nullptr;
77
78 void send_prepare_lock();
79 void handle_prepare_lock(int r);
80
81 void send_cancel_op_requests();
82 void handle_cancel_op_requests(int r);
83
84 void send_block_writes();
85 void handle_block_writes(int r);
86
87 void send_wait_for_ops();
88 void handle_wait_for_ops(int r);
89
90 void send_invalidate_cache(bool purge_on_error);
91 void handle_invalidate_cache(int r);
92
93 void send_flush_notifies();
94 void handle_flush_notifies(int r);
95
96 void send_close_journal();
97 void handle_close_journal(int r);
98
99 void send_close_object_map();
100 void handle_close_object_map(int r);
101
102 void send_unlock();
103
104 void finish();
105
106 void save_result(int result) {
107 if (m_error_result == 0 && result < 0) {
108 m_error_result = result;
109 }
110 }
111
112 };
113
114 } // namespace exclusive_lock
115 } // namespace librbd
116
117 #endif // CEPH_LIBRBD_EXCLUSIVE_LOCK_PRE_RELEASE_REQUEST_H