]>
Commit | Line | Data |
---|---|---|
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_MOSDPGLOG_H | |
17 | #define CEPH_MOSDPGLOG_H | |
18 | ||
19 | #include "msg/Message.h" | |
20 | ||
21 | class MOSDPGLog : public Message { | |
22 | ||
23 | static const int HEAD_VERSION = 5; | |
24 | static const int COMPAT_VERSION = 2; | |
25 | ||
26 | epoch_t epoch; | |
27 | /// query_epoch is the epoch of the query being responded to, or | |
28 | /// the current epoch if this is not being sent in response to a | |
29 | /// query. This allows the recipient to disregard responses to old | |
30 | /// queries. | |
31 | epoch_t query_epoch; | |
32 | ||
33 | public: | |
34 | shard_id_t to; | |
35 | shard_id_t from; | |
36 | pg_info_t info; | |
37 | pg_log_t log; | |
38 | pg_missing_t missing; | |
39 | PastIntervals past_intervals; | |
40 | ||
41 | epoch_t get_epoch() const { return epoch; } | |
42 | spg_t get_pgid() const { return spg_t(info.pgid.pgid, to); } | |
43 | epoch_t get_query_epoch() const { return query_epoch; } | |
44 | ||
45 | MOSDPGLog() : Message(MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION) { | |
46 | set_priority(CEPH_MSG_PRIO_HIGH); | |
47 | } | |
48 | MOSDPGLog(shard_id_t to, shard_id_t from, version_t mv, pg_info_t& i) | |
49 | : Message(MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION), | |
50 | epoch(mv), query_epoch(mv), | |
51 | to(to), from(from), | |
52 | info(i) { | |
53 | set_priority(CEPH_MSG_PRIO_HIGH); | |
54 | } | |
55 | MOSDPGLog(shard_id_t to, shard_id_t from, | |
56 | version_t mv, pg_info_t& i, epoch_t query_epoch) | |
57 | : Message(MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION), | |
58 | epoch(mv), query_epoch(query_epoch), | |
59 | to(to), from(from), | |
60 | info(i) { | |
61 | set_priority(CEPH_MSG_PRIO_HIGH); | |
62 | } | |
63 | ||
64 | private: | |
65 | ~MOSDPGLog() override {} | |
66 | ||
67 | public: | |
68 | const char *get_type_name() const override { return "PGlog"; } | |
69 | void print(ostream& out) const override { | |
70 | // NOTE: log is not const, but operator<< doesn't touch fields | |
71 | // swapped out by OSD code. | |
72 | out << "pg_log(" << info.pgid << " epoch " << epoch | |
73 | << " log " << log | |
74 | << " pi " << past_intervals | |
75 | << " query_epoch " << query_epoch << ")"; | |
76 | } | |
77 | ||
78 | void encode_payload(uint64_t features) override { | |
79 | ::encode(epoch, payload); | |
80 | ::encode(info, payload); | |
81 | ::encode(log, payload); | |
82 | ::encode(missing, payload); | |
83 | ::encode(query_epoch, payload); | |
84 | if (HAVE_FEATURE(features, SERVER_LUMINOUS)) { | |
85 | header.version = HEAD_VERSION; | |
86 | ::encode(past_intervals, payload); | |
87 | } else { | |
88 | header.version = 4; | |
89 | past_intervals.encode_classic(payload); | |
90 | } | |
91 | ::encode(to, payload); | |
92 | ::encode(from, payload); | |
93 | } | |
94 | void decode_payload() override { | |
95 | bufferlist::iterator p = payload.begin(); | |
96 | ::decode(epoch, p); | |
97 | ::decode(info, p); | |
98 | log.decode(p, info.pgid.pool()); | |
99 | missing.decode(p, info.pgid.pool()); | |
100 | if (header.version >= 2) { | |
101 | ::decode(query_epoch, p); | |
102 | } | |
103 | if (header.version >= 3) { | |
104 | if (header.version >= 5) { | |
105 | ::decode(past_intervals, p); | |
106 | } else { | |
107 | past_intervals.decode_classic(p); | |
108 | } | |
109 | } | |
110 | if (header.version >= 4) { | |
111 | ::decode(to, p); | |
112 | ::decode(from, p); | |
113 | } else { | |
114 | to = shard_id_t::NO_SHARD; | |
115 | from = shard_id_t::NO_SHARD; | |
116 | } | |
117 | } | |
118 | }; | |
119 | ||
120 | #endif |