]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: frontends share RGWProcessEnv by reference
authorCasey Bodley <cbodley@redhat.com>
Tue, 25 Oct 2022 16:52:38 +0000 (12:52 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 9 Dec 2022 20:53:29 +0000 (15:53 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_asio_frontend.cc
src/rgw/rgw_asio_frontend.h
src/rgw/rgw_frontend.h
src/rgw/rgw_lib.cc
src/rgw/rgw_lib_frontend.h
src/rgw/rgw_loadgen_process.cc
src/rgw/rgw_process.h

index 0e5be90b7cddf49a93c627879055a30302617383..31276da64119b21f99926e455c504cd6d83c1cbe 100644 (file)
@@ -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))
index 570941ec6533bd14449dee76944f0190abc96d80..85c60f3d191c11f218b61d1cd25c759bcf752847 100644 (file)
@@ -12,7 +12,7 @@ class RGWAsioFrontend : public RGWFrontend {
   class Impl;
   std::unique_ptr<Impl> impl;
 public:
-  RGWAsioFrontend(const RGWProcessEnv& env, RGWFrontendConfig* conf,
+  RGWAsioFrontend(RGWProcessEnv& env, RGWFrontendConfig* conf,
                  rgw::dmclock::SchedulerCtx& sched_ctx);
   ~RGWAsioFrontend() override;
 
index 3fd5bd01ec7afad4c7951421722f343cec1faf30..cf766024503f54242b07511796ab14f614375021 100644 (file)
@@ -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;
 
index 5ed976cfd271c1438cf7ad091a076a41d6725b8e..ccf3da47ee8c273507fa730d7a3885b8caa343d9 100644 (file)
@@ -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;
   }
index 4754362a6e31c9633e9976f6fb084f20bbb64289..57e58c522e59606d5c68ed1b33fe86099b788190 100644 (file)
@@ -25,7 +25,7 @@ namespace rgw {
     using unique_lock = std::unique_lock<std::mutex>;
 
   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) {}
index 4a4c18e75f2d548833d387063be8d3dbde7028fe..d7aa78b578f990ef013a1fd664b6aae290ef04e3 100644 (file)
@@ -107,7 +107,7 @@ void RGWLoadGenProcess::gen_request(const string& method,
                                    int content_length, std::atomic<bool>* 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<RGWLoadGenRequest*>(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,
index 4a8a35c77bf1a7a9645b824c75a338e8e8ba2ab0..4bfe86a3c861da357ba8c99b26066112c2dc1715 100644 (file)
@@ -44,16 +44,12 @@ class RGWProcess {
   std::deque<RGWRequest*> 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<rgw::sal::LuaManager> lua_manager;
 
   struct RGWWQ : public DoutPrefixProvider, public ThreadPool::WorkQueue<RGWRequest> {
@@ -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;