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