]>
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) 2004-2006 Sage Weil <sage@newdream.net> | |
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 | #ifndef CEPH_MOSDSCRUBRESERVE_H | |
16 | #define CEPH_MOSDSCRUBRESERVE_H | |
17 | ||
18 | #include "MOSDFastDispatchOp.h" | |
19 | ||
9f95a23c | 20 | class MOSDScrubReserve : public MOSDFastDispatchOp { |
11fdf7f2 TL |
21 | private: |
22 | static constexpr int HEAD_VERSION = 1; | |
23 | static constexpr int COMPAT_VERSION = 1; | |
7c673cae FG |
24 | public: |
25 | spg_t pgid; | |
26 | epoch_t map_epoch; | |
27 | enum { | |
28 | REQUEST = 0, | |
29 | GRANT = 1, | |
30 | RELEASE = 2, | |
31 | REJECT = 3, | |
32 | }; | |
33 | int32_t type; | |
34 | pg_shard_t from; | |
35 | ||
36 | epoch_t get_map_epoch() const override { | |
37 | return map_epoch; | |
38 | } | |
39 | spg_t get_spg() const override { | |
40 | return pgid; | |
41 | } | |
42 | ||
43 | MOSDScrubReserve() | |
9f95a23c | 44 | : MOSDFastDispatchOp{MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
45 | map_epoch(0), type(-1) {} |
46 | MOSDScrubReserve(spg_t pgid, | |
47 | epoch_t map_epoch, | |
48 | int type, | |
49 | pg_shard_t from) | |
9f95a23c | 50 | : MOSDFastDispatchOp{MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
51 | pgid(pgid), map_epoch(map_epoch), |
52 | type(type), from(from) {} | |
53 | ||
11fdf7f2 | 54 | std::string_view get_type_name() const { |
7c673cae FG |
55 | return "MOSDScrubReserve"; |
56 | } | |
57 | ||
f67539c2 | 58 | void print(std::ostream& out) const { |
7c673cae FG |
59 | out << "MOSDScrubReserve(" << pgid << " "; |
60 | switch (type) { | |
61 | case REQUEST: | |
62 | out << "REQUEST "; | |
63 | break; | |
64 | case GRANT: | |
65 | out << "GRANT "; | |
66 | break; | |
67 | case REJECT: | |
68 | out << "REJECT "; | |
69 | break; | |
70 | case RELEASE: | |
71 | out << "RELEASE "; | |
72 | break; | |
73 | } | |
74 | out << "e" << map_epoch << ")"; | |
75 | return; | |
76 | } | |
77 | ||
78 | void decode_payload() { | |
f67539c2 | 79 | using ceph::decode; |
11fdf7f2 TL |
80 | auto p = payload.cbegin(); |
81 | decode(pgid, p); | |
82 | decode(map_epoch, p); | |
83 | decode(type, p); | |
84 | decode(from, p); | |
7c673cae FG |
85 | } |
86 | ||
87 | void encode_payload(uint64_t features) { | |
11fdf7f2 TL |
88 | using ceph::encode; |
89 | encode(pgid, payload); | |
90 | encode(map_epoch, payload); | |
91 | encode(type, payload); | |
92 | encode(from, payload); | |
7c673cae | 93 | } |
9f95a23c TL |
94 | private: |
95 | template<class T, typename... Args> | |
96 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
97 | }; |
98 | ||
99 | #endif |