]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/cache/pwl/ShutdownRequest.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / librbd / cache / pwl / ShutdownRequest.h
CommitLineData
f67539c2
TL
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_CACHE_RWL_SHUTDOWN_REQUEST_H
5#define CEPH_LIBRBD_CACHE_RWL_SHUTDOWN_REQUEST_H
6
7class Context;
8
9namespace librbd {
10
11class ImageCtx;
12
13namespace plugin { template <typename> struct Api; }
14
15namespace cache {
16namespace pwl {
17
18template<typename>
19class AbstractWriteLog;
20
21template<typename>
22class ImageCacheState;
23
24template <typename ImageCtxT = ImageCtx>
25class ShutdownRequest {
26public:
27 static ShutdownRequest* create(
28 ImageCtxT &image_ctx,
29 AbstractWriteLog<ImageCtxT> *image_cache,
30 plugin::Api<ImageCtxT>& plugin_api,
31 Context *on_finish);
32
33 void send();
34
35private:
36
37 /**
38 * @verbatim
39 *
40 * Shutdown request goes through the following state machine:
41 *
42 * <start>
43 * |
44 * v
45 * SHUTDOWN_IMAGE_CACHE
46 * |
47 * v
48 * REMOVE_IMAGE_FEATURE_BIT
49 * |
50 * v
51 * REMOVE_IMAGE_CACHE_STATE
52 * |
53 * v
54 * <finish>
55 *
56 * @endverbatim
57 */
58
59 ShutdownRequest(ImageCtxT &image_ctx,
60 AbstractWriteLog<ImageCtxT> *image_cache,
61 plugin::Api<ImageCtxT>& plugin_api,
62 Context *on_finish);
63
64 ImageCtxT &m_image_ctx;
65 AbstractWriteLog<ImageCtxT> *m_image_cache;
66 plugin::Api<ImageCtxT>& m_plugin_api;
67 Context *m_on_finish;
68
69 int m_error_result;
70
71 void send_shutdown_image_cache();
72 void handle_shutdown_image_cache(int r);
73
74 void send_remove_feature_bit();
75 void handle_remove_feature_bit(int r);
76
77 void send_remove_image_cache_state();
78 void handle_remove_image_cache_state(int r);
79
80 void finish();
81
82 void save_result(int result) {
83 if (m_error_result == 0 && result < 0) {
84 m_error_result = result;
85 }
86 }
87};
88
89} // namespace pwl
90} // namespace cache
91} // namespace librbd
92
93extern template class librbd::cache::pwl::ShutdownRequest<librbd::ImageCtx>;
94
95#endif // CEPH_LIBRBD_CACHE_RWL_SHUTDOWN_REQUEST_H