]>
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_MOSDPGLOG_H | |
17 | #define CEPH_MOSDPGLOG_H | |
18 | ||
11fdf7f2 | 19 | #include "messages/MOSDPeeringOp.h" |
9f95a23c | 20 | #include "osd/PGPeeringEvent.h" |
7c673cae | 21 | |
f67539c2 | 22 | class MOSDPGLog final : public MOSDPeeringOp { |
11fdf7f2 | 23 | private: |
9f95a23c | 24 | static constexpr int HEAD_VERSION = 6; |
20effc67 | 25 | static constexpr int COMPAT_VERSION = 6; |
7c673cae | 26 | |
d2e6a577 | 27 | epoch_t epoch = 0; |
7c673cae FG |
28 | /// query_epoch is the epoch of the query being responded to, or |
29 | /// the current epoch if this is not being sent in response to a | |
30 | /// query. This allows the recipient to disregard responses to old | |
31 | /// queries. | |
d2e6a577 | 32 | epoch_t query_epoch = 0; |
7c673cae FG |
33 | |
34 | public: | |
35 | shard_id_t to; | |
36 | shard_id_t from; | |
37 | pg_info_t info; | |
38 | pg_log_t log; | |
39 | pg_missing_t missing; | |
40 | PastIntervals past_intervals; | |
9f95a23c | 41 | std::optional<pg_lease_t> lease; |
7c673cae FG |
42 | |
43 | epoch_t get_epoch() const { return epoch; } | |
44 | spg_t get_pgid() const { return spg_t(info.pgid.pgid, to); } | |
45 | epoch_t get_query_epoch() const { return query_epoch; } | |
46 | ||
11fdf7f2 TL |
47 | spg_t get_spg() const override { |
48 | return spg_t(info.pgid.pgid, to); | |
7c673cae | 49 | } |
11fdf7f2 TL |
50 | epoch_t get_map_epoch() const override { |
51 | return epoch; | |
52 | } | |
53 | epoch_t get_min_epoch() const override { | |
54 | return query_epoch; | |
55 | } | |
56 | ||
57 | PGPeeringEvent *get_event() override { | |
58 | return new PGPeeringEvent( | |
59 | epoch, query_epoch, | |
60 | MLogRec(pg_shard_t(get_source().num(), from), | |
61 | this), | |
62 | true, | |
63 | new PGCreateInfo( | |
64 | get_spg(), | |
65 | query_epoch, | |
66 | info.history, | |
67 | past_intervals, | |
68 | false)); | |
69 | } | |
70 | ||
9f95a23c | 71 | MOSDPGLog() : MOSDPeeringOp{MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION} { |
7c673cae FG |
72 | set_priority(CEPH_MSG_PRIO_HIGH); |
73 | } | |
74 | MOSDPGLog(shard_id_t to, shard_id_t from, | |
9f95a23c TL |
75 | version_t mv, const pg_info_t& i, epoch_t query_epoch) |
76 | : MOSDPeeringOp{MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION}, | |
7c673cae FG |
77 | epoch(mv), query_epoch(query_epoch), |
78 | to(to), from(from), | |
79 | info(i) { | |
80 | set_priority(CEPH_MSG_PRIO_HIGH); | |
81 | } | |
82 | ||
83 | private: | |
f67539c2 | 84 | ~MOSDPGLog() final {} |
7c673cae FG |
85 | |
86 | public: | |
11fdf7f2 | 87 | std::string_view get_type_name() const override { return "PGlog"; } |
9f95a23c | 88 | void inner_print(std::ostream& out) const override { |
7c673cae FG |
89 | // NOTE: log is not const, but operator<< doesn't touch fields |
90 | // swapped out by OSD code. | |
11fdf7f2 TL |
91 | out << "log " << log |
92 | << " pi " << past_intervals; | |
9f95a23c TL |
93 | if (lease) { |
94 | out << " " << *lease; | |
95 | } | |
7c673cae FG |
96 | } |
97 | ||
98 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
99 | using ceph::encode; |
100 | encode(epoch, payload); | |
101 | encode(info, payload); | |
102 | encode(log, payload); | |
9f95a23c | 103 | encode(missing, payload, features); |
20effc67 TL |
104 | assert(HAVE_FEATURE(features, SERVER_NAUTILUS)); |
105 | encode(query_epoch, payload); | |
11fdf7f2 TL |
106 | encode(past_intervals, payload); |
107 | encode(to, payload); | |
108 | encode(from, payload); | |
9f95a23c | 109 | encode(lease, payload); |
7c673cae FG |
110 | } |
111 | void decode_payload() override { | |
9f95a23c | 112 | using ceph::decode; |
11fdf7f2 TL |
113 | auto p = payload.cbegin(); |
114 | decode(epoch, p); | |
115 | decode(info, p); | |
7c673cae FG |
116 | log.decode(p, info.pgid.pool()); |
117 | missing.decode(p, info.pgid.pool()); | |
11fdf7f2 TL |
118 | decode(query_epoch, p); |
119 | decode(past_intervals, p); | |
120 | decode(to, p); | |
121 | decode(from, p); | |
20effc67 TL |
122 | assert(header.version >= 6); |
123 | decode(lease, p); | |
7c673cae | 124 | } |
9f95a23c TL |
125 | private: |
126 | template<class T, typename... Args> | |
127 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
128 | }; |
129 | ||
130 | #endif |