]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/object_map/Request.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / librbd / object_map / Request.h
CommitLineData
7c673cae
FG
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_OBJECT_MAP_REQUEST_H
5#define CEPH_LIBRBD_OBJECT_MAP_REQUEST_H
6
7#include "include/int_types.h"
8#include "librbd/AsyncRequest.h"
9
10class Context;
11
12namespace librbd {
13
14class ImageCtx;
15
16namespace object_map {
17
18class Request : public AsyncRequest<> {
19public:
20 Request(ImageCtx &image_ctx, uint64_t snap_id, Context *on_finish)
21 : AsyncRequest(image_ctx, on_finish), m_snap_id(snap_id),
22 m_state(STATE_REQUEST)
23 {
24 }
25
26 void send() override = 0;
27
28protected:
29 const uint64_t m_snap_id;
30
31 bool should_complete(int r) override;
32 int filter_return_code(int r) const override {
11fdf7f2
TL
33 if (m_state == STATE_REQUEST) {
34 // never propagate an error back to the caller
35 return 0;
36 }
37 return r;
7c673cae
FG
38 }
39 virtual void finish_request() {
40 }
41
42private:
43 /**
44 * <start> ---> STATE_REQUEST ---> <finish>
45 * | ^
46 * v |
47 * STATE_INVALIDATE -------/
48 */
49 enum State {
50 STATE_REQUEST,
51 STATE_INVALIDATE
52 };
53
54 State m_state;
55
56 bool invalidate();
57};
58
59} // namespace object_map
60} // namespace librbd
61
62#endif // CEPH_LIBRBD_OBJECT_MAP_REQUEST_H