1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include <iostream>
#include <seastar/core/future.hh>
#include "crimson/osd/osdmap_gate.h"
#include "crimson/osd/osd_operation.h"
#include "osd/osd_types.h"
#include "osd/PGPeeringEvent.h"
#include "osd/PeeringState.h"
namespace ceph {
class Formatter;
}
namespace crimson::osd {
class OSD;
class ShardServices;
class PG;
class BackfillRecovery;
class PGPeeringPipeline {
struct AwaitMap : OrderedExclusivePhaseT<AwaitMap> {
static constexpr auto type_name = "PeeringEvent::PGPipeline::await_map";
} await_map;
struct Process : OrderedExclusivePhaseT<Process> {
static constexpr auto type_name = "PeeringEvent::PGPipeline::process";
} process;
template <class T>
friend class PeeringEvent;
friend class LocalPeeringEvent;
friend class RemotePeeringEvent;
friend class PGAdvanceMap;
friend class BackfillRecovery;
};
template <class T>
class PeeringEvent : public PhasedOperationT<T> {
T* that() {
return static_cast<T*>(this);
}
const T* that() const {
return static_cast<const T*>(this);
}
public:
static constexpr OperationTypeCode type = OperationTypeCode::peering_event;
protected:
PGPeeringPipeline &peering_pp(PG &pg);
PeeringCtx ctx;
pg_shard_t from;
spg_t pgid;
float delay = 0;
PGPeeringEvent evt;
const pg_shard_t get_from() const {
return from;
}
const spg_t get_pgid() const {
return pgid;
}
const PGPeeringEvent &get_event() const {
return evt;
}
virtual void on_pg_absent(ShardServices &);
virtual typename PeeringEvent::template interruptible_future<>
complete_rctx(ShardServices &, Ref<PG>);
virtual seastar::future<> complete_rctx_no_pg(
ShardServices &shard_services
) { return seastar::now();}
public:
template <typename... Args>
PeeringEvent(
const pg_shard_t &from, const spg_t &pgid,
Args&&... args) :
from(from),
pgid(pgid),
evt(std::forward<Args>(args)...)
{}
template <typename... Args>
PeeringEvent(
const pg_shard_t &from, const spg_t &pgid,
float delay, Args&&... args) :
from(from),
pgid(pgid),
delay(delay),
evt(std::forward<Args>(args)...)
{}
void print(std::ostream &) const final;
void dump_detail(ceph::Formatter* f) const final;
seastar::future<> with_pg(
ShardServices &shard_services, Ref<PG> pg);
};
class RemotePeeringEvent : public PeeringEvent<RemotePeeringEvent> {
protected:
crimson::net::ConnectionRef conn;
// must be after conn due to ConnectionPipeline's life-time
PipelineHandle handle;
void on_pg_absent(ShardServices &) final;
PeeringEvent::interruptible_future<> complete_rctx(
ShardServices &shard_services,
Ref<PG> pg) override;
seastar::future<> complete_rctx_no_pg(
ShardServices &shard_services
) override;
public:
class OSDPipeline {
struct AwaitActive : OrderedExclusivePhaseT<AwaitActive> {
static constexpr auto type_name =
"PeeringRequest::OSDPipeline::await_active";
} await_active;
friend class RemotePeeringEvent;
};
template <typename... Args>
RemotePeeringEvent(crimson::net::ConnectionRef conn, Args&&... args) :
PeeringEvent(std::forward<Args>(args)...),
conn(conn)
{}
std::tuple<
StartEvent,
ConnectionPipeline::AwaitActive::BlockingEvent,
ConnectionPipeline::AwaitMap::BlockingEvent,
OSD_OSDMapGate::OSDMapBlocker::BlockingEvent,
ConnectionPipeline::GetPG::BlockingEvent,
PGMap::PGCreationBlockingEvent,
PGPeeringPipeline::AwaitMap::BlockingEvent,
PG_OSDMapGate::OSDMapBlocker::BlockingEvent,
PGPeeringPipeline::Process::BlockingEvent,
OSDPipeline::AwaitActive::BlockingEvent,
CompletionEvent
> tracking_events;
static constexpr bool can_create() { return true; }
auto get_create_info() { return std::move(evt.create_info); }
spg_t get_pgid() const {
return pgid;
}
PipelineHandle &get_handle() { return handle; }
epoch_t get_epoch() const { return evt.get_epoch_sent(); }
ConnectionPipeline &get_connection_pipeline();
seastar::future<crimson::net::ConnectionFRef> prepare_remote_submission() {
assert(conn);
return conn.get_foreign(
).then([this](auto f_conn) {
conn.reset();
return f_conn;
});
}
void finish_remote_submission(crimson::net::ConnectionFRef _conn) {
assert(!conn);
conn = make_local_shared_foreign(std::move(_conn));
}
};
class LocalPeeringEvent final : public PeeringEvent<LocalPeeringEvent> {
protected:
Ref<PG> pg;
PipelineHandle handle;
public:
template <typename... Args>
LocalPeeringEvent(Ref<PG> pg, Args&&... args) :
PeeringEvent(std::forward<Args>(args)...),
pg(pg)
{}
seastar::future<> start();
virtual ~LocalPeeringEvent();
PipelineHandle &get_handle() { return handle; }
std::tuple<
StartEvent,
PGPeeringPipeline::AwaitMap::BlockingEvent,
PG_OSDMapGate::OSDMapBlocker::BlockingEvent,
PGPeeringPipeline::Process::BlockingEvent,
CompletionEvent
> tracking_events;
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::LocalPeeringEvent> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::osd::RemotePeeringEvent> : fmt::ostream_formatter {};
template <class T> struct fmt::formatter<crimson::osd::PeeringEvent<T>> : fmt::ostream_formatter {};
#endif
|