]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: introduce a simpler reset_peer_state() with cleanups
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 31 May 2023 09:21:05 +0000 (17:21 +0800)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 11 Oct 2023 11:38:31 +0000 (11:38 +0000)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
(cherry picked from commit 23c13306776229c237395ccad3b6947a328c2519)

src/crimson/net/ProtocolV2.cc
src/crimson/net/io_handler.cc
src/crimson/net/io_handler.h

index ae532acb08374c047b8e881d175cd678ebce28b7..1ba97617f58aa012823bc0b9090f83d3bc75c71f 100644 (file)
@@ -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<uint64_t>(1, -1ll);
index 9fcccde53c4ce038bc14f3a4eb17e2a67b3c1b47..952158c5d31cd222f7e65bf5b5884a32517cd1ea 100644 (file)
@@ -254,14 +254,22 @@ seastar::future<FrameAssemblerV2Ref> 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) {
index 4fbe33960a368802a1cd619c413cec5117ab4c51..2b48c8ab170128e05e59aa1f2b72c20aafc82c72 100644 (file)
@@ -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<stop_t> try_exit_out_dispatch();
 
   seastar::future<> do_out_dispatch();