]>
Commit | Line | Data |
---|---|---|
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 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2017 Red Hat | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | ||
16 | #ifndef CEPH_MOSDBACKOFF_H | |
17 | #define CEPH_MOSDBACKOFF_H | |
18 | ||
19 | #include "MOSDFastDispatchOp.h" | |
20 | #include "osd/osd_types.h" | |
21 | ||
9f95a23c | 22 | class MOSDBackoff : public MOSDFastDispatchOp { |
7c673cae FG |
23 | public: |
24 | static constexpr int HEAD_VERSION = 1; | |
25 | static constexpr int COMPAT_VERSION = 1; | |
26 | ||
27 | spg_t pgid; | |
28 | epoch_t map_epoch = 0; | |
29 | uint8_t op = 0; ///< CEPH_OSD_BACKOFF_OP_* | |
30 | uint64_t id = 0; ///< unique id within this session | |
31 | hobject_t begin, end; ///< [) range to block, unless ==, block single obj | |
32 | ||
33 | spg_t get_spg() const override { | |
34 | return pgid; | |
35 | } | |
36 | epoch_t get_map_epoch() const override { | |
37 | return map_epoch; | |
38 | } | |
39 | ||
40 | MOSDBackoff() | |
9f95a23c | 41 | : MOSDFastDispatchOp{CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION} {} |
7c673cae FG |
42 | MOSDBackoff(spg_t pgid_, epoch_t ep, uint8_t op_, uint64_t id_, |
43 | hobject_t begin_, hobject_t end_) | |
9f95a23c | 44 | : MOSDFastDispatchOp{CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
45 | pgid(pgid_), |
46 | map_epoch(ep), | |
47 | op(op_), | |
48 | id(id_), | |
49 | begin(begin_), | |
50 | end(end_) { } | |
51 | ||
52 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
53 | using ceph::encode; |
54 | encode(pgid, payload); | |
55 | encode(map_epoch, payload); | |
56 | encode(op, payload); | |
57 | encode(id, payload); | |
58 | encode(begin, payload); | |
59 | encode(end, payload); | |
7c673cae FG |
60 | } |
61 | ||
62 | void decode_payload() override { | |
9f95a23c | 63 | using ceph::decode; |
11fdf7f2 TL |
64 | auto p = payload.cbegin(); |
65 | decode(pgid, p); | |
66 | decode(map_epoch, p); | |
67 | decode(op, p); | |
68 | decode(id, p); | |
69 | decode(begin, p); | |
70 | decode(end, p); | |
7c673cae FG |
71 | } |
72 | ||
11fdf7f2 | 73 | std::string_view get_type_name() const override { return "osd_backoff"; } |
7c673cae | 74 | |
9f95a23c | 75 | void print(std::ostream& out) const override { |
7c673cae FG |
76 | out << "osd_backoff(" << pgid << " " << ceph_osd_backoff_op_name(op) |
77 | << " id " << id | |
78 | << " [" << begin << "," << end << ")" | |
79 | << " e" << map_epoch << ")"; | |
80 | } | |
9f95a23c TL |
81 | private: |
82 | template<class T, typename... Args> | |
83 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
84 | }; |
85 | ||
86 | #endif |