From 3a4acab5c73448020e9a5d3e54bd462d5a37e090 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 2 Nov 2022 13:56:51 -0400 Subject: [PATCH] rgw: process_request() takes RGWProcessEnv Signed-off-by: Casey Bodley --- src/rgw/rgw_asio_frontend.cc | 9 ++------- src/rgw/rgw_loadgen_process.cc | 9 ++------- src/rgw/rgw_process.cc | 27 ++++++++++++--------------- src/rgw/rgw_process.h | 8 +------- 4 files changed, 17 insertions(+), 36 deletions(-) diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index 659816b654f..71d145ed565 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -270,13 +270,8 @@ void handle_connection(boost::asio::io_context& context, string user = "-"; const auto started = ceph::coarse_real_clock::now(); ceph::coarse_real_clock::duration latency{}; - process_request(env.driver, env.rest, &req, uri_prefix, - *env.auth_registry, &client, env.olog, y, - scheduler, &user, &latency, - env.ratelimiting->get_active(), - env.lua_background, - env.lua_manager, - &http_ret); + process_request(env, &req, uri_prefix, &client, y, + scheduler, &user, &latency, &http_ret); if (cct->_conf->subsys.should_gather(ceph_subsys_rgw_access, 1)) { // access log line elements begin per Apache Combined Log Format with additions following diff --git a/src/rgw/rgw_loadgen_process.cc b/src/rgw/rgw_loadgen_process.cc index c4467cb3146..f8165185db3 100644 --- a/src/rgw/rgw_loadgen_process.cc +++ b/src/rgw/rgw_loadgen_process.cc @@ -132,13 +132,8 @@ void RGWLoadGenProcess::handle_request(const DoutPrefixProvider *dpp, RGWRequest RGWLoadGenIO real_client_io(&renv); RGWRestfulIO client_io(cct, &real_client_io); - ActiveRateLimiter ratelimit(cct); - 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, - env.lua_manager); + int ret = process_request(env, req, uri_prefix, &client_io, + null_yield, nullptr, nullptr, nullptr); if (ret < 0) { /* we don't really care about return code */ dout(20) << "process_request() returned " << ret << dendl; diff --git a/src/rgw/rgw_process.cc b/src/rgw/rgw_process.cc index ffa9bd3354b..e7164243c83 100644 --- a/src/rgw/rgw_process.cc +++ b/src/rgw/rgw_process.cc @@ -261,20 +261,14 @@ int rgw_process_authenticated(RGWHandler_REST * const handler, return 0; } -int process_request(rgw::sal::Driver* const driver, - RGWREST* const rest, +int process_request(const RGWProcessEnv& penv, RGWRequest* const req, const std::string& frontend_prefix, - const rgw_auth_registry_t& auth_registry, RGWRestfulIO* const client_io, - OpsLogSink* const olog, optional_yield yield, rgw::dmclock::Scheduler *scheduler, string* user, ceph::coarse_real_clock::duration* latency, - std::shared_ptr ratelimit, - rgw::lua::Background* lua_background, - std::unique_ptr& lua_manager, int* http_ret) { int ret = client_io->init(g_ceph_context); @@ -287,7 +281,9 @@ int process_request(rgw::sal::Driver* const driver, req_state rstate(g_ceph_context, &rgw_env, req->id); req_state *s = &rstate; - s->ratelimit_data = ratelimit; + s->ratelimit_data = penv.ratelimiting->get_active(); + + rgw::sal::Driver* driver = penv.driver; std::unique_ptr u = driver->get_user(rgw_user()); s->set_user(u); @@ -307,9 +303,10 @@ int process_request(rgw::sal::Driver* const driver, RGWOp* op = nullptr; int init_error = 0; bool should_log = false; + RGWREST* rest = penv.rest; RGWRESTMgr *mgr; RGWHandler_REST *handler = rest->get_handler(driver, s, - auth_registry, + *penv.auth_registry, frontend_prefix, client_io, &mgr, &init_error); rgw::dmclock::SchedulerCompleter c; @@ -328,8 +325,8 @@ int process_request(rgw::sal::Driver* const driver, abort_early(s, NULL, -ERR_METHOD_NOT_ALLOWED, handler, yield); goto done; } - s->lua_background = lua_background; - s->lua_manager = lua_manager.get(); + s->lua_background = penv.lua_background; + s->lua_manager = penv.lua_manager.get(); { s->trace_enabled = tracing::rgw::tracer.is_enabled(); std::string script; @@ -339,7 +336,7 @@ int process_request(rgw::sal::Driver* const driver, } else if (rc < 0) { ldpp_dout(op, 5) << "WARNING: failed to read pre request script. error: " << rc << dendl; } else { - rc = rgw::lua::request::execute(driver, rest, olog, s, op, script); + rc = rgw::lua::request::execute(driver, rest, penv.olog, s, op, script); if (rc < 0) { ldpp_dout(op, 5) << "WARNING: failed to execute pre request script. error: " << rc << dendl; } @@ -360,7 +357,7 @@ int process_request(rgw::sal::Driver* const driver, try { ldpp_dout(op, 2) << "verifying requester" << dendl; - ret = op->verify_requester(auth_registry, yield); + ret = op->verify_requester(*penv.auth_registry, yield); if (ret < 0) { dout(10) << "failed to authorize request" << dendl; abort_early(s, op, ret, handler, yield); @@ -424,7 +421,7 @@ done: } else if (rc < 0) { ldpp_dout(op, 5) << "WARNING: failed to read post request script. error: " << rc << dendl; } else { - rc = rgw::lua::request::execute(driver, rest, olog, s, op, script); + rc = rgw::lua::request::execute(driver, rest, penv.olog, s, op, script); if (rc < 0) { ldpp_dout(op, 5) << "WARNING: failed to execute post request script. error: " << rc << dendl; } @@ -438,7 +435,7 @@ done: << e.what() << dendl; } if (should_log) { - rgw_log_op(rest, s, op, olog); + rgw_log_op(rest, s, op, penv.olog); } if (http_ret != nullptr) { diff --git a/src/rgw/rgw_process.h b/src/rgw/rgw_process.h index 5326c1572c8..fad155c0fa0 100644 --- a/src/rgw/rgw_process.h +++ b/src/rgw/rgw_process.h @@ -155,20 +155,14 @@ public: void set_access_key(RGWAccessKey& key) { access_key = key; } }; /* process stream request */ -extern int process_request(rgw::sal::Driver* driver, - RGWREST* rest, +extern int process_request(const RGWProcessEnv& penv, RGWRequest* req, const std::string& frontend_prefix, - const rgw_auth_registry_t& auth_registry, RGWRestfulIO* client_io, - OpsLogSink* olog, optional_yield y, rgw::dmclock::Scheduler *scheduler, std::string* user, ceph::coarse_real_clock::duration* latency, - std::shared_ptr ratelimit, - rgw::lua::Background* lua_background, - std::unique_ptr& lua_manager, int* http_ret = nullptr); extern int rgw_process_authenticated(RGWHandler_REST* handler, -- 2.39.5