From 23c13306776229c237395ccad3b6947a328c2519 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Wed, 31 May 2023 17:21:05 +0800 Subject: [PATCH] crimson/net: introduce a simpler reset_peer_state() with cleanups Signed-off-by: Yingxin Cheng --- src/crimson/net/ProtocolV2.cc | 3 +-- src/crimson/net/io_handler.cc | 28 ++++++++++++++++++++++++---- src/crimson/net/io_handler.h | 6 ++++++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index ae532acb08374..1ba97617f58aa 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -1674,8 +1674,7 @@ ProtocolV2::send_server_ident() logger().debug("{} UPDATE: gs={} for server ident", conn, global_seq); // this is required for the case when this connection is being replaced - io_handler.requeue_out_sent_up_to(0); - io_handler.reset_session(false); + io_handler.reset_peer_state(); if (!conn.policy.lossy) { server_cookie = ceph::util::generate_random_number(1, -1ll); diff --git a/src/crimson/net/io_handler.cc b/src/crimson/net/io_handler.cc index 9fcccde53c4ce..952158c5d31cd 100644 --- a/src/crimson/net/io_handler.cc +++ b/src/crimson/net/io_handler.cc @@ -254,14 +254,22 @@ seastar::future IOHandler::wait_io_exit_dispatching() void IOHandler::reset_session(bool full) { - // reset in - in_seq = 0; + assert(io_state != io_state_t::open); + reset_in(); if (full) { reset_out(); dispatch_remote_reset(); } } +void IOHandler::reset_peer_state() +{ + assert(io_state != io_state_t::open); + reset_in(); + requeue_out_sent_up_to(0); + discard_out_sent(); +} + void IOHandler::requeue_out_sent() { assert(io_state != io_state_t::open); @@ -306,17 +314,29 @@ void IOHandler::requeue_out_sent_up_to(seq_num_t seq) requeue_out_sent(); } +void IOHandler::reset_in() +{ + assert(io_state != io_state_t::open); + in_seq = 0; +} + void IOHandler::reset_out() { assert(io_state != io_state_t::open); - out_seq = 0; + discard_out_sent(); out_pending_msgs.clear(); - out_sent_msgs.clear(); need_keepalive = false; next_keepalive_ack = std::nullopt; ack_left = 0; } +void IOHandler::discard_out_sent() +{ + assert(io_state != io_state_t::open); + out_seq = 0; + out_sent_msgs.clear(); +} + void IOHandler::dispatch_accept() { if (io_state == io_state_t::drop) { diff --git a/src/crimson/net/io_handler.h b/src/crimson/net/io_handler.h index 4fbe33960a368..2b48c8ab17012 100644 --- a/src/crimson/net/io_handler.h +++ b/src/crimson/net/io_handler.h @@ -143,6 +143,8 @@ public: void reset_session(bool full); + void reset_peer_state(); + void requeue_out_sent_up_to(seq_num_t seq); void requeue_out_sent(); @@ -171,8 +173,12 @@ public: next_keepalive_ack.has_value()); } + void reset_in(); + void reset_out(); + void discard_out_sent(); + seastar::future try_exit_out_dispatch(); seastar::future<> do_out_dispatch(); -- 2.39.5