diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index cff5f86c01b..410f59aa97d 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -80,6 +80,7 @@ add_library(crimson-common STATIC ${PROJECT_SOURCE_DIR}/src/msg/msg_types.cc ${PROJECT_SOURCE_DIR}/src/msg/Message.cc ${PROJECT_SOURCE_DIR}/src/mon/MonCap.cc + ${PROJECT_SOURCE_DIR}/src/mon/MonMap.cc ${PROJECT_SOURCE_DIR}/src/osd/osd_types.cc ${PROJECT_SOURCE_DIR}/src/osd/ECMsgTypes.cc ${PROJECT_SOURCE_DIR}/src/osd/HitSet.cc @@ -110,7 +111,6 @@ set(crimson_auth_srcs auth/KeyRing.cc) set(crimson_mon_srcs mon/MonClient.cc - ${PROJECT_SOURCE_DIR}/src/mon/MonMap.cc ${PROJECT_SOURCE_DIR}/src/mon/MonSub.cc) set(crimson_net_srcs net/Dispatcher.cc @@ -134,3 +134,4 @@ target_link_libraries(crimson crimson-common crimson::cflags) add_subdirectory(os) +add_subdirectory(osd) diff --git a/src/crimson/osd/CMakeLists.txt b/src/crimson/osd/CMakeLists.txt new file mode 100644 index 00000000000..2c109366460 --- /dev/null +++ b/src/crimson/osd/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(crimson-osd + main.cc + osd.cc) +target_link_libraries(crimson-osd + crimson-common crimson-os crimson) diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc new file mode 100644 index 00000000000..1d7e9297a3f --- /dev/null +++ b/src/crimson/osd/main.cc @@ -0,0 +1,81 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*- +// vim: ts=8 sw=2 smarttab + +#include +#include + +#include + +#include +#include + +#include "common/ceph_argparse.h" +#include "crimson/common/config_proxy.h" + +#include "osd.h" + +using config_t = ceph::common::ConfigProxy; + +void usage(const char* prog) { + std::cout << "usage: " << prog << " -i " << std::endl; + generic_server_usage(); +} + +int main(int argc, char* argv[]) +{ + std::vector args{argv + 1, argv + argc}; + if (ceph_argparse_need_usage(args)) { + usage(argv[0]); + return EXIT_SUCCESS; + } + std::string cluster; + std::string conf_file_list; + // ceph_argparse_early_args() could _exit(), while local_conf() won't ready + // until it's started. so do the boilerplate-settings parsing here. + auto init_params = ceph_argparse_early_args(args, + CEPH_ENTITY_TYPE_OSD, + &cluster, + &conf_file_list); + seastar::app_template app; + seastar::sharded osd; + + using ceph::common::sharded_conf; + using ceph::common::sharded_perf_coll; + using ceph::common::local_conf; + + args.insert(begin(args), argv[0]); + try { + return app.run_deprecated(args.size(), const_cast(args.data()), [&] { + seastar::engine().at_exit([] { + return sharded_conf().stop(); + }); + seastar::engine().at_exit([] { + return sharded_perf_coll().stop(); + }); + seastar::engine().at_exit([&] { + return osd.stop(); + }); + return sharded_conf().start(init_params.name, cluster).then([] { + return sharded_perf_coll().start(); + }).then([&conf_file_list] { + return local_conf().parse_config_files(conf_file_list); + }).then([&] { + return osd.start_single(std::stoi(local_conf()->name.get_id()), + static_cast(getpid())); + }).then([&] { + return osd.invoke_on(0, &OSD::start); + }); + }); + } catch (...) { + seastar::fprint(std::cerr, "FATAL: Exception during startup, aborting: %s\n", std::current_exception()); + return EXIT_FAILURE; + } +} + +/* + * Local Variables: + * compile-command: "make -j4 \ + * -C ../../../build \ + * crimson-osd" + * End: + */ diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc new file mode 100644 index 00000000000..5692edc7a14 --- /dev/null +++ b/src/crimson/osd/osd.cc @@ -0,0 +1,42 @@ +#include "osd.h" + +#include "crimson/net/SocketMessenger.h" + +namespace { + seastar::logger& logger() { + return ceph::get_logger(ceph_subsys_osd); + } +} + +using ceph::common::local_conf; + +OSD::OSD(int id, uint32_t nonce) + : whoami{id}, + cluster_msgr{new ceph::net::SocketMessenger{entity_name_t::OSD(whoami), + "cluster", nonce}}, + client_msgr{new ceph::net::SocketMessenger{entity_name_t::OSD(whoami), + "client", nonce}}, + monc{*client_msgr} +{ + for (auto msgr : {cluster_msgr.get(), client_msgr.get()}) { + if (local_conf()->ms_crc_data) { + msgr->set_crc_data(); + } + if (local_conf()->ms_crc_header) { + msgr->set_crc_header(); + } + } +} + +OSD::~OSD() = default; + +seastar::future<> OSD::start() +{ + logger().info("start"); + return seastar::now(); +} + +seastar::future<> OSD::stop() +{ + return gate.close(); +} diff --git a/src/crimson/osd/osd.h b/src/crimson/osd/osd.h new file mode 100644 index 00000000000..a648f136461 --- /dev/null +++ b/src/crimson/osd/osd.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +#include "crimson/net/Dispatcher.h" + +namespace ceph::net { + class Messenger; +} + +class OSD : public ceph::net::Dispatcher { + seastar::gate gate; + const int whoami; + // talk with osd + std::unique_ptr cluster_msgr; + // talk with mon/mgr + std::unique_ptr client_msgr; + +public: + OSD(int id, uint32_t nonce); + ~OSD(); + + seastar::future<> start(); + seastar::future<> stop(); +};