]>
Commit | Line | Data |
---|---|---|
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 | ||
7 | class Context; | |
8 | ||
9 | namespace librbd { | |
10 | ||
11 | class ImageCtx; | |
12 | ||
13 | namespace plugin { template <typename> struct Api; } | |
14 | ||
15 | namespace cache { | |
16 | namespace pwl { | |
17 | ||
18 | template<typename> | |
19 | class AbstractWriteLog; | |
20 | ||
21 | template<typename> | |
22 | class ImageCacheState; | |
23 | ||
24 | template <typename ImageCtxT = ImageCtx> | |
25 | class ShutdownRequest { | |
26 | public: | |
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 | ||
35 | private: | |
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 | ||
93 | extern template class librbd::cache::pwl::ShutdownRequest<librbd::ImageCtx>; | |
94 | ||
95 | #endif // CEPH_LIBRBD_CACHE_RWL_SHUTDOWN_REQUEST_H |