From dc678bad57a787cb6f92c2e230b79b3eb58b7893 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 25 Oct 2022 12:52:38 -0400 Subject: [PATCH] rgw: frontends share RGWProcessEnv by reference Signed-off-by: Casey Bodley --- src/rgw/rgw_asio_frontend.cc | 8 ++++---- src/rgw/rgw_asio_frontend.h | 2 +- src/rgw/rgw_frontend.h | 4 ++-- src/rgw/rgw_lib.cc | 8 ++++---- src/rgw/rgw_lib_frontend.h | 2 +- src/rgw/rgw_loadgen_process.cc | 24 ++++++++++++------------ src/rgw/rgw_process.h | 25 ++++++++----------------- 7 files changed, 32 insertions(+), 41 deletions(-) diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index 0e5be90b7cddf..31276da64119b 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -375,7 +375,7 @@ class ConnectionList { namespace dmc = rgw::dmclock; class AsioFrontend { - RGWProcessEnv env; + RGWProcessEnv& env; RGWFrontendConfig* conf; boost::asio::io_context context; std::string uri_prefix; @@ -421,7 +421,7 @@ class AsioFrontend { void accept(Listener& listener, boost::system::error_code ec); public: - AsioFrontend(const RGWProcessEnv& env, RGWFrontendConfig* conf, + AsioFrontend(RGWProcessEnv& env, RGWFrontendConfig* conf, dmc::SchedulerCtx& sched_ctx) : env(env), conf(conf), pause_mutex(context.get_executor()), lua_manager(env.driver->get_lua_manager()) @@ -1143,12 +1143,12 @@ void AsioFrontend::unpause(rgw::sal::Driver* const driver, class RGWAsioFrontend::Impl : public AsioFrontend { public: - Impl(const RGWProcessEnv& env, RGWFrontendConfig* conf, + Impl(RGWProcessEnv& env, RGWFrontendConfig* conf, rgw::dmclock::SchedulerCtx& sched_ctx) : AsioFrontend(env, conf, sched_ctx) {} }; -RGWAsioFrontend::RGWAsioFrontend(const RGWProcessEnv& env, +RGWAsioFrontend::RGWAsioFrontend(RGWProcessEnv& env, RGWFrontendConfig* conf, rgw::dmclock::SchedulerCtx& sched_ctx) : impl(new Impl(env, conf, sched_ctx)) diff --git a/src/rgw/rgw_asio_frontend.h b/src/rgw/rgw_asio_frontend.h index 570941ec6533b..85c60f3d191c1 100644 --- a/src/rgw/rgw_asio_frontend.h +++ b/src/rgw/rgw_asio_frontend.h @@ -12,7 +12,7 @@ class RGWAsioFrontend : public RGWFrontend { class Impl; std::unique_ptr impl; public: - RGWAsioFrontend(const RGWProcessEnv& env, RGWFrontendConfig* conf, + RGWAsioFrontend(RGWProcessEnv& env, RGWFrontendConfig* conf, rgw::dmclock::SchedulerCtx& sched_ctx); ~RGWAsioFrontend() override; diff --git a/src/rgw/rgw_frontend.h b/src/rgw/rgw_frontend.h index 3fd5bd01ec7af..cf766024503f5 100644 --- a/src/rgw/rgw_frontend.h +++ b/src/rgw/rgw_frontend.h @@ -92,7 +92,7 @@ class RGWProcessFrontend : public RGWFrontend { protected: RGWFrontendConfig* conf; RGWProcess* pprocess; - RGWProcessEnv env; + RGWProcessEnv& env; RGWProcessControlThread* thread; public: @@ -156,7 +156,7 @@ public: conf->get_val("prefix", "", &uri_prefix); RGWLoadGenProcess *pp = new RGWLoadGenProcess( - g_ceph_context, &env, num_threads, std::move(uri_prefix), conf); + g_ceph_context, env, num_threads, std::move(uri_prefix), conf); pprocess = pp; diff --git a/src/rgw/rgw_lib.cc b/src/rgw/rgw_lib.cc index 5ed976cfd271c..ccf3da47ee8c2 100644 --- a/src/rgw/rgw_lib.cc +++ b/src/rgw/rgw_lib.cc @@ -211,7 +211,7 @@ namespace rgw { s->cio = io; /* XXX and -then- stash req_state pointers everywhere they are needed */ - ret = req->init(rgw_env, driver, io, s); + ret = req->init(rgw_env, env.driver, io, s); if (ret < 0) { ldpp_dout(op, 10) << "failed to initialize request" << dendl; abort_req(s, op, ret); @@ -307,7 +307,7 @@ namespace rgw { << e.what() << dendl; } if (should_log) { - rgw_log_op(nullptr /* !rest */, s, op, olog); + rgw_log_op(nullptr /* !rest */, s, op, env.olog); } int http_ret = s->err.http_ret; @@ -347,7 +347,7 @@ namespace rgw { rgw_env.set("HTTP_HOST", ""); - int ret = req->init(rgw_env, driver, &io_ctx, s); + int ret = req->init(rgw_env, env.driver, &io_ctx, s); if (ret < 0) { ldpp_dout(op, 10) << "failed to initialize request" << dendl; abort_req(s, op, ret); @@ -450,7 +450,7 @@ namespace rgw { int RGWLibFrontend::init() { std::string uri_prefix; // empty - pprocess = new RGWLibProcess(g_ceph_context, &env, + pprocess = new RGWLibProcess(g_ceph_context, env, g_conf()->rgw_thread_pool_size, uri_prefix, conf); return 0; } diff --git a/src/rgw/rgw_lib_frontend.h b/src/rgw/rgw_lib_frontend.h index 4754362a6e31c..57e58c522e596 100644 --- a/src/rgw/rgw_lib_frontend.h +++ b/src/rgw/rgw_lib_frontend.h @@ -25,7 +25,7 @@ namespace rgw { using unique_lock = std::unique_lock; public: - RGWLibProcess(CephContext* cct, RGWProcessEnv* pe, int num_threads, + RGWLibProcess(CephContext* cct, RGWProcessEnv& pe, int num_threads, std::string uri_prefix, RGWFrontendConfig* _conf) : RGWProcess(cct, pe, num_threads, std::move(uri_prefix), _conf), gen(0), shutdown(false) {} diff --git a/src/rgw/rgw_loadgen_process.cc b/src/rgw/rgw_loadgen_process.cc index 4a4c18e75f2d5..d7aa78b578f99 100644 --- a/src/rgw/rgw_loadgen_process.cc +++ b/src/rgw/rgw_loadgen_process.cc @@ -107,7 +107,7 @@ void RGWLoadGenProcess::gen_request(const string& method, int content_length, std::atomic* fail_flag) { RGWLoadGenRequest* req = - new RGWLoadGenRequest(driver->get_new_req_id(), method, resource, + new RGWLoadGenRequest(env.driver->get_new_req_id(), method, resource, content_length, fail_flag); dout(10) << "allocated request req=" << hex << req << dec << dendl; req_throttle.get(1); @@ -118,23 +118,23 @@ void RGWLoadGenProcess::handle_request(const DoutPrefixProvider *dpp, RGWRequest { RGWLoadGenRequest* req = static_cast(r); - RGWLoadGenRequestEnv env; + RGWLoadGenRequestEnv renv; utime_t tm = ceph_clock_now(); - env.port = 80; - env.content_length = req->content_length; - env.content_type = "binary/octet-stream"; - env.request_method = req->method; - env.uri = req->resource; - env.set_date(tm); - env.sign(dpp, access_key); + renv.port = 80; + renv.content_length = req->content_length; + renv.content_type = "binary/octet-stream"; + renv.request_method = req->method; + renv.uri = req->resource; + renv.set_date(tm); + renv.sign(dpp, access_key); - RGWLoadGenIO real_client_io(&env); + RGWLoadGenIO real_client_io(&renv); RGWRestfulIO client_io(cct, &real_client_io); ActiveRateLimiter ratelimit(cct); - int ret = process_request(driver, rest, req, uri_prefix, - *auth_registry, &client_io, olog, + int ret = process_request(env.driver, env.rest, req, uri_prefix, + *env.auth_registry, &client_io, env.olog, null_yield, nullptr, nullptr, nullptr, ratelimit.get_active(), nullptr, diff --git a/src/rgw/rgw_process.h b/src/rgw/rgw_process.h index 4a8a35c77bf1a..4bfe86a3c861d 100644 --- a/src/rgw/rgw_process.h +++ b/src/rgw/rgw_process.h @@ -44,16 +44,12 @@ class RGWProcess { std::deque m_req_queue; protected: CephContext *cct; - rgw::sal::Driver* driver; - rgw_auth_registry_ptr_t auth_registry; - OpsLogSink* olog; + RGWProcessEnv& env; ThreadPool m_tp; Throttle req_throttle; - RGWREST* rest; RGWFrontendConfig* conf; int sock_fd; std::string uri_prefix; - rgw::lua::Background* lua_background; std::unique_ptr lua_manager; struct RGWWQ : public DoutPrefixProvider, public ThreadPool::WorkQueue { @@ -93,22 +89,17 @@ protected: public: RGWProcess(CephContext* const cct, - RGWProcessEnv* const pe, + RGWProcessEnv& env, const int num_threads, std::string uri_prefix, RGWFrontendConfig* const conf) - : cct(cct), - driver(pe->driver), - auth_registry(pe->auth_registry), - olog(pe->olog), + : cct(cct), env(env), m_tp(cct, "RGWProcess::m_tp", "tp_rgw_process", num_threads), req_throttle(cct, "rgw_ops", num_threads * 2), - rest(pe->rest), conf(conf), sock_fd(-1), uri_prefix(std::move(uri_prefix)), - lua_background(pe->lua_background), - lua_manager(driver->get_lua_manager()), + lua_manager(env.driver->get_lua_manager()), req_wq(this, ceph::make_timespan(g_conf()->rgw_op_thread_timeout), ceph::make_timespan(g_conf()->rgw_op_thread_suicide_timeout), @@ -126,8 +117,8 @@ public: void unpause_with_new_config(rgw::sal::Driver* const driver, rgw_auth_registry_ptr_t auth_registry) { - this->driver = driver; - this->auth_registry = std::move(auth_registry); + env.driver = driver; + env.auth_registry = std::move(auth_registry); lua_manager = driver->get_lua_manager(); m_tp.unpause(); } @@ -154,9 +145,9 @@ public: class RGWLoadGenProcess : public RGWProcess { RGWAccessKey access_key; public: - RGWLoadGenProcess(CephContext* cct, RGWProcessEnv* pe, int num_threads, + RGWLoadGenProcess(CephContext* cct, RGWProcessEnv& env, int num_threads, std::string uri_prefix, RGWFrontendConfig* _conf) - : RGWProcess(cct, pe, num_threads, std::move(uri_prefix), _conf) {} + : RGWProcess(cct, env, num_threads, std::move(uri_prefix), _conf) {} void run() override; void checkpoint(); void handle_request(const DoutPrefixProvider *dpp, RGWRequest* req) override; -- 2.39.5