From 04063715b596a4b2f07c5fdf65c3b58e89fe400b Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 6 May 2020 17:43:05 +0800 Subject: [PATCH] crimson: s/reactor::cpu_id/seastar::this_shard_id/ the former was deprecated since seastar 02956fd436b413d6bbe562cf91533ada36553e54 Signed-off-by: Kefu Chai --- src/crimson/common/config_proxy.cc | 2 +- src/crimson/net/Socket.h | 14 +++++++------- src/crimson/net/SocketConnection.cc | 12 ++++++------ src/crimson/net/SocketMessenger.cc | 16 ++++++++-------- src/crimson/net/SocketMessenger.h | 4 ++-- src/crimson/os/alienstore/alien_store.cc | 4 ++-- src/test/crimson/test_config.cc | 2 +- src/test/crimson/test_perfcounters.cc | 2 +- src/test/crimson/test_socket.cc | 2 +- src/tools/crimson/perf_crimson_msgr.cc | 10 +++++----- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/crimson/common/config_proxy.cc b/src/crimson/common/config_proxy.cc index aa0214bc37acc..18c891f687500 100644 --- a/src/crimson/common/config_proxy.cc +++ b/src/crimson/common/config_proxy.cc @@ -7,7 +7,7 @@ namespace crimson::common { ConfigProxy::ConfigProxy(const EntityName& name, std::string_view cluster) { - if (seastar::engine().cpu_id() != 0) { + if (seastar::this_shard_id() != 0) { return; } // set the initial value on CPU#0 diff --git a/src/crimson/net/Socket.h b/src/crimson/net/Socket.h index a9989650c9d42..f3d8bd8b6d719 100644 --- a/src/crimson/net/Socket.h +++ b/src/crimson/net/Socket.h @@ -36,7 +36,7 @@ class Socket }; Socket(seastar::connected_socket&& _socket, side_t _side, uint16_t e_port, construct_tag) - : sid{seastar::engine().cpu_id()}, + : sid{seastar::this_shard_id()}, socket(std::move(_socket)), in(socket.input()), // the default buffer size 8192 is too small that may impact our write @@ -198,7 +198,7 @@ public: FixedCPUServerSocket& operator=(const FixedCPUServerSocket&) = delete; seastar::future<> listen(entity_addr_t addr) { - assert(seastar::engine().cpu_id() == cpu); + assert(seastar::this_shard_id() == cpu); logger().trace("FixedCPUServerSocket::listen({})...", addr); return container().invoke_on_all([addr] (auto& ss) { ss.addr = addr; @@ -223,7 +223,7 @@ public: // seastar::future<>(SocketRef, entity_addr_t) template seastar::future<> accept(Func&& fn_accept) { - assert(seastar::engine().cpu_id() == cpu); + assert(seastar::this_shard_id() == cpu); logger().trace("FixedCPUServerSocket({})::accept()...", addr); return container().invoke_on_all( [fn_accept = std::move(fn_accept)] (auto& ss) mutable { @@ -238,7 +238,7 @@ public: [&ss, fn_accept = std::move(fn_accept)] (seastar::accept_result accept_result) mutable { // assert seastar::listen_options::set_fixed_cpu() works - assert(seastar::engine().cpu_id() == ss.cpu); + assert(seastar::this_shard_id() == ss.cpu); auto [socket, paddr] = std::move(accept_result); entity_addr_t peer_addr; peer_addr.set_sockaddr(&paddr.as_posix_sockaddr()); @@ -278,7 +278,7 @@ public: } seastar::future<> shutdown() { - assert(seastar::engine().cpu_id() == cpu); + assert(seastar::this_shard_id() == cpu); logger().trace("FixedCPUServerSocket({})::shutdown()...", addr); return container().invoke_on_all([] (auto& ss) { if (ss.listener) { @@ -291,7 +291,7 @@ public: } seastar::future<> destroy() { - assert(seastar::engine().cpu_id() == cpu); + assert(seastar::this_shard_id() == cpu); return shutdown().then([this] { // we should only construct/stop shards on #0 return container().invoke_on(0, [] (auto& ss) { @@ -302,7 +302,7 @@ public: } static seastar::future create() { - auto cpu = seastar::engine().cpu_id(); + auto cpu = seastar::this_shard_id(); // we should only construct/stop shards on #0 return seastar::smp::submit_to(0, [cpu] { auto service = std::make_unique(); diff --git a/src/crimson/net/SocketConnection.cc b/src/crimson/net/SocketConnection.cc index 1595b75148de8..ca4c63b9f3008 100644 --- a/src/crimson/net/SocketConnection.cc +++ b/src/crimson/net/SocketConnection.cc @@ -52,20 +52,20 @@ SocketConnection::get_messenger() const { bool SocketConnection::is_connected() const { - assert(seastar::engine().cpu_id() == shard_id()); + assert(seastar::this_shard_id() == shard_id()); return protocol->is_connected(); } #ifdef UNIT_TESTS_BUILT bool SocketConnection::is_closed() const { - assert(seastar::engine().cpu_id() == shard_id()); + assert(seastar::this_shard_id() == shard_id()); return protocol->is_closed(); } bool SocketConnection::is_closed_clean() const { - assert(seastar::engine().cpu_id() == shard_id()); + assert(seastar::this_shard_id() == shard_id()); return protocol->is_closed_clean; } @@ -77,19 +77,19 @@ bool SocketConnection::peer_wins() const seastar::future<> SocketConnection::send(MessageRef msg) { - assert(seastar::engine().cpu_id() == shard_id()); + assert(seastar::this_shard_id() == shard_id()); return protocol->send(std::move(msg)); } seastar::future<> SocketConnection::keepalive() { - assert(seastar::engine().cpu_id() == shard_id()); + assert(seastar::this_shard_id() == shard_id()); return protocol->keepalive(); } void SocketConnection::mark_down() { - assert(seastar::engine().cpu_id() == shard_id()); + assert(seastar::this_shard_id() == shard_id()); protocol->close(false); } diff --git a/src/crimson/net/SocketMessenger.cc b/src/crimson/net/SocketMessenger.cc index 294b4cc9a8544..9535917f18f6d 100644 --- a/src/crimson/net/SocketMessenger.cc +++ b/src/crimson/net/SocketMessenger.cc @@ -34,14 +34,14 @@ SocketMessenger::SocketMessenger(const entity_name_t& myname, const std::string& logic_name, uint32_t nonce) : Messenger{myname}, - master_sid{seastar::engine().cpu_id()}, + master_sid{seastar::this_shard_id()}, logic_name{logic_name}, nonce{nonce} {} seastar::future<> SocketMessenger::set_myaddrs(const entity_addrvec_t& addrs) { - assert(seastar::engine().cpu_id() == master_sid); + assert(seastar::this_shard_id() == master_sid); auto my_addrs = addrs; for (auto& addr : my_addrs.v) { addr.nonce = nonce; @@ -51,7 +51,7 @@ seastar::future<> SocketMessenger::set_myaddrs(const entity_addrvec_t& addrs) seastar::future<> SocketMessenger::do_bind(const entity_addrvec_t& addrs) { - assert(seastar::engine().cpu_id() == master_sid); + assert(seastar::this_shard_id() == master_sid); ceph_assert(addrs.front().get_family() == AF_INET); return set_myaddrs(addrs).then([this] { if (!listener) { @@ -112,7 +112,7 @@ SocketMessenger::try_bind(const entity_addrvec_t& addrs, } seastar::future<> SocketMessenger::start(Dispatcher *disp) { - assert(seastar::engine().cpu_id() == master_sid); + assert(seastar::this_shard_id() == master_sid); dispatcher = disp; if (listener) { @@ -121,7 +121,7 @@ seastar::future<> SocketMessenger::start(Dispatcher *disp) { ceph_assert(get_myaddr().get_port() > 0); return listener->accept([this] (SocketRef socket, entity_addr_t peer_addr) { - assert(seastar::engine().cpu_id() == master_sid); + assert(seastar::this_shard_id() == master_sid); SocketConnectionRef conn = seastar::make_shared( *this, *dispatcher, get_myaddr().is_msgr2()); conn->start_accept(std::move(socket), peer_addr); @@ -134,7 +134,7 @@ seastar::future<> SocketMessenger::start(Dispatcher *disp) { crimson::net::ConnectionRef SocketMessenger::connect(const entity_addr_t& peer_addr, const entity_name_t& peer_name) { - assert(seastar::engine().cpu_id() == master_sid); + assert(seastar::this_shard_id() == master_sid); // make sure we connect to a valid peer_addr ceph_assert(peer_addr.is_legacy() || peer_addr.is_msgr2()); @@ -152,7 +152,7 @@ SocketMessenger::connect(const entity_addr_t& peer_addr, const entity_name_t& pe seastar::future<> SocketMessenger::shutdown() { - assert(seastar::engine().cpu_id() == master_sid); + assert(seastar::this_shard_id() == master_sid); return seastar::futurize_invoke([this] { if (listener) { auto d_listener = listener; @@ -179,7 +179,7 @@ seastar::future<> SocketMessenger::shutdown() seastar::future<> SocketMessenger::learned_addr(const entity_addr_t &peer_addr_for_me, const SocketConnection& conn) { - assert(seastar::engine().cpu_id() == master_sid); + assert(seastar::this_shard_id() == master_sid); if (!need_addr) { if ((!get_myaddr().is_any() && get_myaddr().get_type() != peer_addr_for_me.get_type()) || diff --git a/src/crimson/net/SocketMessenger.h b/src/crimson/net/SocketMessenger.h index 9419e0a15c3d8..5f1c02ce1ee2b 100644 --- a/src/crimson/net/SocketMessenger.h +++ b/src/crimson/net/SocketMessenger.h @@ -69,7 +69,7 @@ class SocketMessenger final : public Messenger { const entity_name_t& peer_name) override; // can only wait once seastar::future<> wait() override { - assert(seastar::engine().cpu_id() == master_sid); + assert(seastar::this_shard_id() == master_sid); return shutdown_promise.get_future(); } @@ -102,7 +102,7 @@ class SocketMessenger final : public Messenger { void register_conn(SocketConnectionRef); void unregister_conn(SocketConnectionRef); seastar::shard_id shard_id() const { - assert(seastar::engine().cpu_id() == master_sid); + assert(seastar::this_shard_id() == master_sid); return master_sid; } }; diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index fb8dad487fbf3..baca9ec78756d 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -63,7 +63,7 @@ AlienStore::AlienStore(const std::string& path, const ConfigValues& values) g_ceph_context = cct.get(); cct->_conf.set_config_values(values); store = std::make_unique(cct.get(), path); - tp = std::make_unique(1, 128, seastar::engine().cpu_id() + 10); + tp = std::make_unique(1, 128, seastar::this_shard_id() + 10); } seastar::future<> AlienStore::start() @@ -327,7 +327,7 @@ seastar::future<> AlienStore::do_transaction(CollectionRef ch, ceph::os::Transaction&& txn) { logger().debug("{}", __func__); - auto id = seastar::engine().cpu_id(); + auto id = seastar::this_shard_id(); auto done = seastar::promise<>(); return seastar::do_with( std::move(txn), diff --git a/src/test/crimson/test_config.cc b/src/test/crimson/test_config.cc index 29f6f9a7f3f55..6735d27841e12 100644 --- a/src/test/crimson/test_config.cc +++ b/src/test/crimson/test_config.cc @@ -65,7 +65,7 @@ static seastar::future<> test_config() }).then([] { return crimson::common::sharded_conf().invoke_on_all([](Config& config) { return config.set_val(test_uint_option, - std::to_string(seastar::engine().cpu_id())); + std::to_string(seastar::this_shard_id())); }); }).then([] { auto expected = crimson::common::local_conf().get_val(test_uint_option); diff --git a/src/test/crimson/test_perfcounters.cc b/src/test/crimson/test_perfcounters.cc index bd261dc1dadfb..8aecbf911cc90 100644 --- a/src/test/crimson/test_perfcounters.cc +++ b/src/test/crimson/test_perfcounters.cc @@ -21,7 +21,7 @@ static constexpr uint64_t PERF_VAL = 42; static seastar::future<> test_perfcounters(){ return crimson::common::sharded_perf_coll().start().then([] { return crimson::common::sharded_perf_coll().invoke_on_all([] (auto& s){ - std::string name =fmt::format("seastar-osd::shard-{}",seastar::engine().cpu_id()); + std::string name =fmt::format("seastar-osd::shard-{}",seastar::this_shard_id()); PerfCountersBuilder plb(NULL, name, PERFTEST_FIRST,PERFTEST_LAST); plb.add_u64_counter(PERFTEST_INDEX, "perftest_count", "count perftest"); auto perf_logger = plb.create_perf_counters(); diff --git a/src/test/crimson/test_socket.cc b/src/test/crimson/test_socket.cc index 5d1458ba4a2e3..2c7faccb34173 100644 --- a/src/test/crimson/test_socket.cc +++ b/src/test/crimson/test_socket.cc @@ -129,7 +129,7 @@ class SocketFactory { // cb_client() on CPU#0, cb_server() on CPU#1 template static future<> dispatch_sockets(FuncC&& cb_client, FuncS&& cb_server) { - assert(engine().cpu_id() == 0u); + assert(seastar::this_shard_id() == 0u); auto owner = std::make_unique(); auto psf = owner.get(); return seastar::smp::submit_to(1u, [psf] { diff --git a/src/tools/crimson/perf_crimson_msgr.cc b/src/tools/crimson/perf_crimson_msgr.cc index a47fa87441246..7ed27dd744c79 100644 --- a/src/tools/crimson/perf_crimson_msgr.cc +++ b/src/tools/crimson/perf_crimson_msgr.cc @@ -145,7 +145,7 @@ static seastar::future<> run( bufferlist msg_data; Server(unsigned msg_len) - : msgr_sid{seastar::engine().cpu_id()}, + : msgr_sid{seastar::this_shard_id()}, msg_len{msg_len} { lname = "server#"; lname += std::to_string(msgr_sid); @@ -281,7 +281,7 @@ static seastar::future<> run( seastar::promise<> stopped_send_promise; Client(unsigned jobs, unsigned msg_len, unsigned depth) - : sid{seastar::engine().cpu_id()}, + : sid{seastar::this_shard_id()}, jobs{jobs}, msg_len{msg_len}, nr_depth{depth/jobs}, @@ -326,7 +326,7 @@ static seastar::future<> run( // should start messenger at this shard? bool is_active() { - ceph_assert(seastar::engine().cpu_id() == sid); + ceph_assert(seastar::this_shard_id() == sid); return sid != 0 && sid <= jobs; } @@ -569,7 +569,7 @@ static seastar::future<> run( private: seastar::future<> send_msg(crimson::net::Connection* conn) { - ceph_assert(seastar::engine().cpu_id() == sid); + ceph_assert(seastar::this_shard_id() == sid); return depth.wait(1).then([this, conn] { const static pg_t pgid; const static object_locator_t oloc; @@ -602,7 +602,7 @@ static seastar::future<> run( } void do_dispatch_messages(crimson::net::Connection* conn) { - ceph_assert(seastar::engine().cpu_id() == sid); + ceph_assert(seastar::this_shard_id() == sid); ceph_assert(sent_count == 0); conn_stats.start_time = mono_clock::now(); // forwarded to stopped_send_promise -- 2.39.5