]>
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 | ||
25 | struct MOSDRepScrub : public MOSDFastDispatchOp { | |
26 | ||
27 | static const int HEAD_VERSION = 7; | |
28 | static const int COMPAT_VERSION = 6; | |
29 | ||
30 | spg_t pgid; // PG to scrub | |
31 | eversion_t scrub_from; // only scrub log entries after scrub_from | |
32 | eversion_t scrub_to; // last_update_applied when message sent | |
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 | |
38 | uint32_t seed; // seed value for digest calculation | |
39 | ||
40 | epoch_t get_map_epoch() const override { | |
41 | return map_epoch; | |
42 | } | |
43 | epoch_t get_min_epoch() const override { | |
44 | return min_epoch; | |
45 | } | |
46 | spg_t get_spg() const override { | |
47 | return pgid; | |
48 | } | |
49 | ||
50 | MOSDRepScrub() | |
51 | : MOSDFastDispatchOp(MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION), | |
52 | chunky(false), | |
53 | deep(false), | |
54 | seed(0) { } | |
55 | ||
56 | MOSDRepScrub(spg_t pgid, eversion_t scrub_to, epoch_t map_epoch, epoch_t min_epoch, | |
57 | hobject_t start, hobject_t end, bool deep, uint32_t seed) | |
58 | : MOSDFastDispatchOp(MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION), | |
59 | pgid(pgid), | |
60 | scrub_to(scrub_to), | |
61 | map_epoch(map_epoch), | |
62 | min_epoch(min_epoch), | |
63 | chunky(true), | |
64 | start(start), | |
65 | end(end), | |
66 | deep(deep), | |
67 | seed(seed) { } | |
68 | ||
69 | ||
70 | private: | |
71 | ~MOSDRepScrub() override {} | |
72 | ||
73 | public: | |
74 | const char *get_type_name() const override { return "replica scrub"; } | |
75 | void print(ostream& out) const override { | |
76 | out << "replica scrub(pg: "; | |
77 | out << pgid << ",from:" << scrub_from << ",to:" << scrub_to | |
78 | << ",epoch:" << map_epoch << "/" << min_epoch | |
79 | << ",start:" << start << ",end:" << end | |
80 | << ",chunky:" << chunky | |
81 | << ",deep:" << deep | |
82 | << ",seed:" << seed | |
83 | << ",version:" << header.version; | |
84 | out << ")"; | |
85 | } | |
86 | ||
87 | void encode_payload(uint64_t features) override { | |
88 | ::encode(pgid.pgid, payload); | |
89 | ::encode(scrub_from, payload); | |
90 | ::encode(scrub_to, payload); | |
91 | ::encode(map_epoch, payload); | |
92 | ::encode(chunky, payload); | |
93 | ::encode(start, payload); | |
94 | ::encode(end, payload); | |
95 | ::encode(deep, payload); | |
96 | ::encode(pgid.shard, payload); | |
97 | ::encode(seed, payload); | |
98 | ::encode(min_epoch, payload); | |
99 | } | |
100 | void decode_payload() override { | |
101 | bufferlist::iterator p = payload.begin(); | |
102 | ::decode(pgid.pgid, p); | |
103 | ::decode(scrub_from, p); | |
104 | ::decode(scrub_to, p); | |
105 | ::decode(map_epoch, p); | |
106 | ::decode(chunky, p); | |
107 | ::decode(start, p); | |
108 | ::decode(end, p); | |
109 | ::decode(deep, p); | |
110 | ::decode(pgid.shard, p); | |
111 | ::decode(seed, p); | |
112 | if (header.version >= 7) { | |
113 | ::decode(min_epoch, p); | |
114 | } else { | |
115 | min_epoch = map_epoch; | |
116 | } | |
117 | } | |
118 | }; | |
119 | ||
120 | #endif |