]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/image/CloseRequest.h
update sources to v12.1.0
[ceph.git] / ceph / src / librbd / image / CloseRequest.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_IMAGE_CLOSE_REQUEST_H
5 #define CEPH_LIBRBD_IMAGE_CLOSE_REQUEST_H
6
7 #include "librbd/ImageCtx.h"
8
9 class Context;
10
11 namespace librbd {
12
13 class ImageCtx;
14
15 namespace image {
16
17 template <typename ImageCtxT = ImageCtx>
18 class CloseRequest {
19 public:
20 static CloseRequest *create(ImageCtxT *image_ctx, Context *on_finish) {
21 return new CloseRequest(image_ctx, on_finish);
22 }
23
24 void send();
25
26 private:
27 /**
28 * @verbatim
29 *
30 * <start>
31 * |
32 * v
33 * BLOCK_IMAGE_WATCHER (skip if R/O)
34 * |
35 * v
36 * SHUT_DOWN_UPDATE_WATCHERS
37 * |
38 * v
39 * SHUT_DOWN_AIO_WORK_QUEUE . . .
40 * | . (exclusive lock disabled)
41 * v v
42 * SHUT_DOWN_EXCLUSIVE_LOCK FLUSH
43 * | .
44 * | . . . . . . . . . . .
45 * | .
46 * v v
47 * UNREGISTER_IMAGE_WATCHER (skip if R/O)
48 * |
49 * v
50 * FLUSH_READAHEAD
51 * |
52 * v
53 * SHUTDOWN_CACHE
54 * |
55 * v
56 * FLUSH_OP_WORK_QUEUE . . . . .
57 * | .
58 * v .
59 * CLOSE_PARENT . (no parent)
60 * | .
61 * v .
62 * FLUSH_IMAGE_WATCHER < . . . .
63 * |
64 * v
65 * <finish>
66 *
67 * @endverbatim
68 */
69
70 CloseRequest(ImageCtxT *image_ctx, Context *on_finish);
71
72 ImageCtxT *m_image_ctx;
73 Context *m_on_finish;
74
75 int m_error_result;
76
77 decltype(m_image_ctx->exclusive_lock) m_exclusive_lock;
78
79 void send_block_image_watcher();
80 void handle_block_image_watcher(int r);
81
82 void send_shut_down_update_watchers();
83 void handle_shut_down_update_watchers(int r);
84
85 void send_shut_down_io_queue();
86 void handle_shut_down_io_queue(int r);
87
88 void send_shut_down_exclusive_lock();
89 void handle_shut_down_exclusive_lock(int r);
90
91 void send_flush();
92 void handle_flush(int r);
93
94 void send_unregister_image_watcher();
95 void handle_unregister_image_watcher(int r);
96
97 void send_flush_readahead();
98 void handle_flush_readahead(int r);
99
100 void send_shut_down_cache();
101 void handle_shut_down_cache(int r);
102
103 void send_flush_op_work_queue();
104 void handle_flush_op_work_queue(int r);
105
106 void send_close_parent();
107 void handle_close_parent(int r);
108
109 void send_flush_image_watcher();
110 void handle_flush_image_watcher(int r);
111
112 void finish();
113
114 void save_result(int result) {
115 if (m_error_result == 0 && result < 0) {
116 m_error_result = result;
117 }
118 }
119 };
120
121 } // namespace image
122 } // namespace librbd
123
124 extern template class librbd::image::CloseRequest<librbd::ImageCtx>;
125
126 #endif // CEPH_LIBRBD_IMAGE_CLOSE_REQUEST_H