]>
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 | ||
16 | #ifndef CEPH_MOSDREPSCRUB_H | |
17 | #define CEPH_MOSDREPSCRUB_H | |
18 | ||
19 | #include "MOSDFastDispatchOp.h" | |
20 | ||
21 | /* | |
22 | * instruct an OSD initiate a replica scrub on a specific PG | |
23 | */ | |
24 | ||
f67539c2 | 25 | class MOSDRepScrub final : public MOSDFastDispatchOp { |
11fdf7f2 | 26 | public: |
11fdf7f2 TL |
27 | static constexpr int HEAD_VERSION = 9; |
28 | static constexpr int COMPAT_VERSION = 6; | |
7c673cae FG |
29 | |
30 | spg_t pgid; // PG to scrub | |
31 | eversion_t scrub_from; // only scrub log entries after scrub_from | |
20effc67 | 32 | eversion_t scrub_to; // last_update_applied when message sent (not used) |
d2e6a577 | 33 | epoch_t map_epoch = 0, min_epoch = 0; |
7c673cae FG |
34 | bool chunky; // true for chunky scrubs |
35 | hobject_t start; // lower bound of scrub, inclusive | |
36 | hobject_t end; // upper bound of scrub, exclusive | |
37 | bool deep; // true if scrub should be deep | |
28e407b8 AA |
38 | bool allow_preemption = false; |
39 | int32_t priority = 0; | |
40 | bool high_priority = false; | |
7c673cae FG |
41 | |
42 | epoch_t get_map_epoch() const override { | |
43 | return map_epoch; | |
44 | } | |
45 | epoch_t get_min_epoch() const override { | |
46 | return min_epoch; | |
47 | } | |
48 | spg_t get_spg() const override { | |
49 | return pgid; | |
50 | } | |
51 | ||
52 | MOSDRepScrub() | |
9f95a23c | 53 | : MOSDFastDispatchOp{MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae | 54 | chunky(false), |
28e407b8 | 55 | deep(false) { } |
7c673cae FG |
56 | |
57 | MOSDRepScrub(spg_t pgid, eversion_t scrub_to, epoch_t map_epoch, epoch_t min_epoch, | |
28e407b8 AA |
58 | hobject_t start, hobject_t end, bool deep, |
59 | bool preemption, int prio, bool highprio) | |
9f95a23c | 60 | : MOSDFastDispatchOp{MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
61 | pgid(pgid), |
62 | scrub_to(scrub_to), | |
63 | map_epoch(map_epoch), | |
64 | min_epoch(min_epoch), | |
65 | chunky(true), | |
66 | start(start), | |
67 | end(end), | |
68 | deep(deep), | |
28e407b8 AA |
69 | allow_preemption(preemption), |
70 | priority(prio), | |
71 | high_priority(highprio) { } | |
7c673cae FG |
72 | |
73 | ||
74 | private: | |
f67539c2 | 75 | ~MOSDRepScrub() final {} |
7c673cae FG |
76 | |
77 | public: | |
11fdf7f2 | 78 | std::string_view get_type_name() const override { return "replica scrub"; } |
f67539c2 | 79 | void print(std::ostream& out) const override { |
28e407b8 AA |
80 | out << "replica_scrub(pg: " << pgid |
81 | << ",from:" << scrub_from | |
82 | << ",to:" << scrub_to | |
7c673cae FG |
83 | << ",epoch:" << map_epoch << "/" << min_epoch |
84 | << ",start:" << start << ",end:" << end | |
85 | << ",chunky:" << chunky | |
86 | << ",deep:" << deep | |
28e407b8 AA |
87 | << ",version:" << header.version |
88 | << ",allow_preemption:" << (int)allow_preemption | |
89 | << ",priority=" << priority | |
90 | << (high_priority ? " (high)":"") | |
91 | << ")"; | |
7c673cae FG |
92 | } |
93 | ||
94 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
95 | using ceph::encode; |
96 | encode(pgid.pgid, payload); | |
97 | encode(scrub_from, payload); | |
98 | encode(scrub_to, payload); | |
99 | encode(map_epoch, payload); | |
100 | encode(chunky, payload); | |
101 | encode(start, payload); | |
102 | encode(end, payload); | |
103 | encode(deep, payload); | |
104 | encode(pgid.shard, payload); | |
105 | encode((uint32_t)-1, payload); // seed | |
106 | encode(min_epoch, payload); | |
107 | encode(allow_preemption, payload); | |
108 | encode(priority, payload); | |
109 | encode(high_priority, payload); | |
7c673cae FG |
110 | } |
111 | void decode_payload() override { | |
f67539c2 | 112 | using ceph::decode; |
11fdf7f2 TL |
113 | auto p = payload.cbegin(); |
114 | decode(pgid.pgid, p); | |
115 | decode(scrub_from, p); | |
116 | decode(scrub_to, p); | |
117 | decode(map_epoch, p); | |
118 | decode(chunky, p); | |
119 | decode(start, p); | |
120 | decode(end, p); | |
121 | decode(deep, p); | |
122 | decode(pgid.shard, p); | |
28e407b8 AA |
123 | { |
124 | uint32_t seed; | |
11fdf7f2 | 125 | decode(seed, p); |
28e407b8 | 126 | } |
7c673cae | 127 | if (header.version >= 7) { |
11fdf7f2 | 128 | decode(min_epoch, p); |
7c673cae FG |
129 | } else { |
130 | min_epoch = map_epoch; | |
131 | } | |
28e407b8 | 132 | if (header.version >= 8) { |
11fdf7f2 | 133 | decode(allow_preemption, p); |
28e407b8 AA |
134 | } |
135 | if (header.version >= 9) { | |
11fdf7f2 TL |
136 | decode(priority, p); |
137 | decode(high_priority, p); | |
28e407b8 | 138 | } |
7c673cae FG |
139 | } |
140 | }; | |
141 | ||
142 | #endif |