]>
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_MOSDREPOP_H | |
17 | #define CEPH_MOSDREPOP_H | |
18 | ||
19 | #include "MOSDFastDispatchOp.h" | |
20 | ||
21 | /* | |
22 | * OSD sub op - for internal ops on pobjects between primary and replicas(/stripes/whatever) | |
23 | */ | |
24 | ||
25 | class MOSDRepOp : public MOSDFastDispatchOp { | |
26 | ||
27 | static const int HEAD_VERSION = 2; | |
28 | static const int COMPAT_VERSION = 1; | |
29 | ||
30 | public: | |
31 | epoch_t map_epoch, min_epoch; | |
32 | ||
33 | // metadata from original request | |
34 | osd_reqid_t reqid; | |
35 | ||
36 | spg_t pgid; | |
37 | ||
38 | bufferlist::iterator p; | |
39 | // Decoding flags. Decoding is only needed for messages catched by pipe reader. | |
40 | bool final_decode_needed; | |
41 | ||
42 | // subop | |
43 | pg_shard_t from; | |
44 | hobject_t poid; | |
45 | ||
46 | __u8 acks_wanted; | |
47 | ||
48 | // transaction to exec | |
49 | bufferlist logbl; | |
50 | pg_stat_t pg_stats; | |
51 | ||
52 | // subop metadata | |
53 | eversion_t version; | |
54 | ||
55 | // piggybacked osd/og state | |
56 | eversion_t pg_trim_to; // primary->replica: trim to here | |
57 | eversion_t pg_roll_forward_to; // primary->replica: trim rollback | |
58 | // info to here | |
59 | ||
60 | hobject_t new_temp_oid; ///< new temp object that we must now start tracking | |
61 | hobject_t discard_temp_oid; ///< previously used temp object that we can now stop tracking | |
62 | ||
63 | /// non-empty if this transaction involves a hit_set history update | |
64 | boost::optional<pg_hit_set_history_t> updated_hit_set_history; | |
65 | ||
66 | epoch_t get_map_epoch() const override { | |
67 | return map_epoch; | |
68 | } | |
69 | epoch_t get_min_epoch() const override { | |
70 | return min_epoch; | |
71 | } | |
72 | spg_t get_spg() const override { | |
73 | return pgid; | |
74 | } | |
75 | ||
76 | int get_cost() const override { | |
77 | return data.length(); | |
78 | } | |
79 | ||
80 | void decode_payload() override { | |
81 | p = payload.begin(); | |
82 | // splitted to partial and final | |
83 | ::decode(map_epoch, p); | |
84 | if (header.version >= 2) { | |
85 | ::decode(min_epoch, p); | |
86 | decode_trace(p); | |
87 | } else { | |
88 | min_epoch = map_epoch; | |
89 | } | |
90 | ::decode(reqid, p); | |
91 | ::decode(pgid, p); | |
92 | } | |
93 | ||
94 | void finish_decode() { | |
95 | if (!final_decode_needed) | |
96 | return; // Message is already final decoded | |
97 | ::decode(poid, p); | |
98 | ||
99 | ::decode(acks_wanted, p); | |
100 | ::decode(version, p); | |
101 | ::decode(logbl, p); | |
102 | ::decode(pg_stats, p); | |
103 | ::decode(pg_trim_to, p); | |
104 | ||
105 | ||
106 | ::decode(new_temp_oid, p); | |
107 | ::decode(discard_temp_oid, p); | |
108 | ||
109 | ::decode(from, p); | |
110 | ::decode(updated_hit_set_history, p); | |
111 | ::decode(pg_roll_forward_to, p); | |
112 | final_decode_needed = false; | |
113 | } | |
114 | ||
115 | void encode_payload(uint64_t features) override { | |
116 | ::encode(map_epoch, payload); | |
117 | if (HAVE_FEATURE(features, SERVER_LUMINOUS)) { | |
c07f9fc5 | 118 | header.version = HEAD_VERSION; |
7c673cae FG |
119 | ::encode(min_epoch, payload); |
120 | encode_trace(payload, features); | |
121 | } else { | |
122 | header.version = 1; | |
123 | } | |
124 | ::encode(reqid, payload); | |
125 | ::encode(pgid, payload); | |
126 | ::encode(poid, payload); | |
127 | ||
128 | ::encode(acks_wanted, payload); | |
129 | ::encode(version, payload); | |
130 | ::encode(logbl, payload); | |
131 | ::encode(pg_stats, payload); | |
132 | ::encode(pg_trim_to, payload); | |
133 | ::encode(new_temp_oid, payload); | |
134 | ::encode(discard_temp_oid, payload); | |
135 | ::encode(from, payload); | |
136 | ::encode(updated_hit_set_history, payload); | |
137 | ::encode(pg_roll_forward_to, payload); | |
138 | } | |
139 | ||
140 | MOSDRepOp() | |
141 | : MOSDFastDispatchOp(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION), | |
142 | map_epoch(0), | |
143 | final_decode_needed(true), acks_wanted (0) {} | |
144 | MOSDRepOp(osd_reqid_t r, pg_shard_t from, | |
145 | spg_t p, const hobject_t& po, int aw, | |
146 | epoch_t mape, epoch_t min_epoch, ceph_tid_t rtid, eversion_t v) | |
147 | : MOSDFastDispatchOp(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION), | |
148 | map_epoch(mape), | |
149 | min_epoch(min_epoch), | |
150 | reqid(r), | |
151 | pgid(p), | |
152 | final_decode_needed(false), | |
153 | from(from), | |
154 | poid(po), | |
155 | acks_wanted(aw), | |
156 | version(v) { | |
157 | set_tid(rtid); | |
158 | } | |
159 | private: | |
160 | ~MOSDRepOp() override {} | |
161 | ||
162 | public: | |
163 | const char *get_type_name() const override { return "osd_repop"; } | |
164 | void print(ostream& out) const override { | |
165 | out << "osd_repop(" << reqid | |
166 | << " " << pgid << " e" << map_epoch << "/" << min_epoch; | |
167 | if (!final_decode_needed) { | |
168 | out << " " << poid << " v " << version; | |
169 | if (updated_hit_set_history) | |
170 | out << ", has_updated_hit_set_history"; | |
171 | } | |
172 | out << ")"; | |
173 | } | |
174 | }; | |
175 | ||
176 | ||
177 | #endif |