]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/net: dispatch the initial acceptance from the socket core
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 16 Jun 2023 07:35:22 +0000 (15:35 +0800)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 11 Oct 2023 11:38:33 +0000 (11:38 +0000)
It's meaningless to dispatch the initial acceptance always from the
msgr core.

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
(cherry picked from commit 1e8a39f359d8481bb3038b461063c87384bf3ee8)

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

index 5a9e0c21c5ada80723bf4d173e2cd408e935c5fd..f6a235d4af3fe77039f487c72af77e13255722f4 100644 (file)
@@ -186,6 +186,15 @@ void ProtocolV2::start_accept(SocketFRef&& new_socket,
   logger().info("{} ProtocolV2::start_accept(): target_addr={}", conn, _peer_addr);
   messenger.accept_conn(
     seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()));
+
+  auto cc_seq = crosscore.prepare_submit();
+  gate.dispatch_in_background("set_accepted_sid", conn, [this, cc_seq] {
+    return io_handler.set_accepted_sid(
+        cc_seq,
+        frame_assembler->get_socket_shard_id(),
+        seastar::make_foreign(conn.shared_from_this()));
+  });
+
   execute_accepting();
 }
 
index adcb8611148b92ab94935f6b4456d37ebba6a4c6..b138ed0f26e0efd9b2da0aa30d1cb2805a1bb8fb 100644 (file)
@@ -705,6 +705,32 @@ IOHandler::to_new_sid(
   });
 }
 
+seastar::future<> IOHandler::set_accepted_sid(
+    crosscore_t::seq_t cc_seq,
+    seastar::shard_id sid,
+    ConnectionFRef conn_fref)
+{
+  assert(seastar::this_shard_id() == get_shard_id());
+  assert(get_io_state() == io_state_t::none);
+  ceph_assert_always(conn_ref);
+  conn_ref.reset();
+  assert(maybe_prv_shard_states == nullptr);
+  shard_states.reset();
+  shard_states = shard_states_t::create(sid, io_state_t::none);
+  return seastar::smp::submit_to(sid,
+      [this, cc_seq, conn_fref=std::move(conn_fref)]() mutable {
+    // must be the first to proceed
+    ceph_assert_always(crosscore.proceed_or_wait(cc_seq));
+
+    logger().debug("{} set accepted sid", conn);
+    ceph_assert_always(seastar::this_shard_id() == get_shard_id());
+    ceph_assert_always(get_io_state() == io_state_t::none);
+    assert(maybe_prv_shard_states == nullptr);
+    ceph_assert_always(!conn_ref);
+    conn_ref = make_local_shared_foreign(std::move(conn_fref));
+  });
+}
+
 void IOHandler::dispatch_reset(bool is_replace)
 {
   ceph_assert_always(get_io_state() == io_state_t::drop);
index 108386fc7ae40343a1596a9659213cf74e21ea03..0175d2c522c98f22526cc4f903083e65c0701898 100644 (file)
@@ -218,6 +218,11 @@ public:
   };
   void print_io_stat(std::ostream &out) const;
 
+  seastar::future<> set_accepted_sid(
+      crosscore_t::seq_t cc_seq,
+      seastar::shard_id sid,
+      ConnectionFRef conn_fref);
+
   /*
    * may be called cross-core
    */