Skip to content

Commit 0eb920f

Browse files
Merge pull request ceph#59832 from NitzanMordhai/wip-nitzan-crimson-enable-gate-assertions
common/gated: enable ceph_assert on shard id
2 parents 62da54b + a8918f3 commit 0eb920f

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

src/crimson/common/gated.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class Gated {
3131

3232
template <typename Func, typename T>
3333
inline void dispatch_in_background(const char* what, T& who, Func&& func) {
34-
//ceph_assert(seastar::this_shard_id() == sid);
34+
ceph_assert(seastar::this_shard_id() == sid);
3535
(void) dispatch(what, who, std::forward<Func>(func));
3636
}
3737

3838
template <typename Func, typename T>
3939
inline seastar::future<> dispatch(const char* what, T& who, Func&& func) {
40-
//ceph_assert(seastar::this_shard_id() == sid);
40+
ceph_assert(seastar::this_shard_id() == sid);
4141
return seastar::with_gate(pending_dispatch, std::forward<Func>(func)
4242
).handle_exception([what, &who] (std::exception_ptr eptr) {
4343
if (*eptr.__cxa_exception_type() == typeid(system_shutdown_exception)) {
@@ -58,7 +58,7 @@ class Gated {
5858

5959
template <typename Func>
6060
auto simple_dispatch(const char* what, Func&& func) {
61-
//ceph_assert(seastar::this_shard_id() == sid);
61+
ceph_assert(seastar::this_shard_id() == sid);
6262
return seastar::with_gate(pending_dispatch, std::forward<Func>(func));
6363
}
6464

src/crimson/mgr/client.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ seastar::future<> Client::stop()
4141
{
4242
logger().info("{}", __func__);
4343
report_timer.cancel();
44-
auto fut = gate.close();
44+
auto fut = gates.close_all();
4545
if (conn) {
4646
conn->mark_down();
4747
}
@@ -52,7 +52,7 @@ std::optional<seastar::future<>>
5252
Client::ms_dispatch(crimson::net::ConnectionRef conn, MessageRef m)
5353
{
5454
bool dispatched = true;
55-
gate.dispatch_in_background(__func__, *this, [this, conn, &m, &dispatched] {
55+
gates.dispatch_in_background(__func__, *this, [this, conn, &m, &dispatched] {
5656
switch(m->get_type()) {
5757
case MSG_MGR_MAP:
5858
return handle_mgr_map(conn, boost::static_pointer_cast<MMgrMap>(m));
@@ -71,7 +71,7 @@ void Client::ms_handle_connect(
7171
seastar::shard_id prv_shard)
7272
{
7373
ceph_assert_always(prv_shard == seastar::this_shard_id());
74-
gate.dispatch_in_background(__func__, *this, [this, c] {
74+
gates.dispatch_in_background(__func__, *this, [this, c] {
7575
if (conn == c) {
7676
// ask for the mgrconfigure message
7777
auto m = crimson::make_message<MMgrOpen>();
@@ -87,7 +87,7 @@ void Client::ms_handle_connect(
8787

8888
void Client::ms_handle_reset(crimson::net::ConnectionRef c, bool /* is_replace */)
8989
{
90-
gate.dispatch_in_background(__func__, *this, [this, c] {
90+
gates.dispatch_in_background(__func__, *this, [this, c] {
9191
if (conn == c) {
9292
report_timer.cancel();
9393
return reconnect();
@@ -158,7 +158,7 @@ seastar::future<> Client::handle_mgr_conf(crimson::net::ConnectionRef,
158158
void Client::report()
159159
{
160160
_send_report();
161-
gate.dispatch_in_background(__func__, *this, [this] {
161+
gates.dispatch_in_background(__func__, *this, [this] {
162162
if (!conn) {
163163
logger().warn("report: no conn available; report skipped");
164164
return seastar::now();
@@ -178,7 +178,7 @@ void Client::_send_report()
178178
{
179179
// TODO: implement daemon_health_metrics support
180180
// https://tracker.ceph.com/issues/63766
181-
gate.dispatch_in_background(__func__, *this, [this] {
181+
gates.dispatch_in_background(__func__, *this, [this] {
182182
if (!conn) {
183183
logger().warn("cannot send report; no conn available");
184184
return seastar::now();

src/crimson/mgr/client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Client : public crimson::net::Dispatcher {
5555
WithStats& with_stats;
5656
crimson::net::ConnectionRef conn;
5757
seastar::timer<seastar::lowres_clock> report_timer;
58-
crimson::common::Gated gate;
58+
crimson::common::gate_per_shard gates;
5959
uint64_t last_config_bl_version = 0;
6060
std::string service_name, daemon_name;
6161

src/crimson/mon/MonClient.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ seastar::future<> Client::load_keyring()
464464

465465
void Client::tick()
466466
{
467-
gate.dispatch_in_background(__func__, *this, [this] {
467+
gates.dispatch_in_background(__func__, *this, [this] {
468468
if (active_con) {
469469
return seastar::when_all_succeed(wait_for_send_log(),
470470
active_con->get_conn()->send_keepalive(),
@@ -505,7 +505,7 @@ std::optional<seastar::future<>>
505505
Client::ms_dispatch(crimson::net::ConnectionRef conn, MessageRef m)
506506
{
507507
bool dispatched = true;
508-
gate.dispatch_in_background(__func__, *this, [this, conn, &m, &dispatched] {
508+
gates.dispatch_in_background(__func__, *this, [this, conn, &m, &dispatched] {
509509
// we only care about these message types
510510
switch (m->get_type()) {
511511
case CEPH_MSG_MON_MAP:
@@ -538,7 +538,7 @@ Client::ms_dispatch(crimson::net::ConnectionRef conn, MessageRef m)
538538

539539
void Client::ms_handle_reset(crimson::net::ConnectionRef conn, bool /* is_replace */)
540540
{
541-
gate.dispatch_in_background(__func__, *this, [this, conn] {
541+
gates.dispatch_in_background(__func__, *this, [this, conn] {
542542
auto found = std::find_if(pending_conns.begin(), pending_conns.end(),
543543
[peer_addr = conn->get_peer_addr()](auto& mc) {
544544
return mc->is_my_peer(peer_addr);
@@ -941,7 +941,7 @@ seastar::future<> Client::authenticate()
941941
seastar::future<> Client::stop()
942942
{
943943
logger().info("{}", __func__);
944-
auto fut = gate.close();
944+
auto fut = gates.close_all();
945945
timer.cancel();
946946
ready_to_send = false;
947947
for (auto& pending_con : pending_conns) {

src/crimson/mon/MonClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class Client : public crimson::net::Dispatcher,
194194
std::vector<unsigned> get_random_mons(unsigned n) const;
195195
seastar::future<> _add_conn(unsigned rank, uint64_t global_id);
196196
void _finish_auth(const entity_addr_t& peer);
197-
crimson::common::Gated gate;
197+
crimson::common::gate_per_shard gates;
198198

199199
// messages that are waiting for the active_con to be available
200200
struct pending_msg_t {

0 commit comments

Comments
 (0)