]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/cache: this commit squashes commits for removing CephContext* from
authorPritha Srivastava <prsrivas@redhat.com>
Tue, 12 Dec 2023 11:53:37 +0000 (17:23 +0530)
committerPritha Srivastava <prsrivas@redhat.com>
Tue, 2 Apr 2024 15:54:51 +0000 (21:24 +0530)
ssd, redis driver and related test files.

rgw/cache: removing CephContext* from ssd driver and redis driver.
It can be accessed in every api using dpp->get_cct(), where dpp
is of type DoutPrefixProvider*.
rgw/test: Remove `cct` parameter from cache driver initialization call
redis driver test file.
rgw/qa: removing cct parameter from ssd driver test file.

Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
Signed-off-by: Samarah <samarah.uriarte@ibm.com>
src/rgw/driver/d4n/rgw_sal_d4n.cc
src/rgw/rgw_cache_driver.h
src/rgw/rgw_redis_driver.cc
src/rgw/rgw_redis_driver.h
src/rgw/rgw_ssd_driver.cc
src/rgw/rgw_ssd_driver.h
src/test/rgw/test_d4n_policy.cc
src/test/rgw/test_redis_driver.cc
src/test/rgw/test_ssd_driver.cc

index edb5efcca68b9921a61611f415807d233fd29163..37875ed4e9424627846a6a1b9838f1fec0afdb7f 100644 (file)
@@ -60,7 +60,7 @@ int D4NFilterDriver::initialize(CephContext *cct, const DoutPrefixProvider *dpp)
 {
   FilterDriver::initialize(cct, dpp);
 
-  cacheDriver->initialize(cct, dpp);
+  cacheDriver->initialize(dpp);
 
   objDir->init(cct, dpp);
   blockDir->init(cct, dpp);
index 4495b1d537825ffc568cce2edddaccc058da5c21..e6c0969fd322a4c9968d5e93ad451baa95cab028 100644 (file)
@@ -17,7 +17,7 @@ class CacheDriver {
     CacheDriver() {}
     virtual ~CacheDriver() = default;
 
-    virtual int initialize(CephContext* cct, const DoutPrefixProvider* dpp) = 0;
+    virtual int initialize(const DoutPrefixProvider* dpp) = 0;
     virtual int put(const DoutPrefixProvider* dpp, const std::string& key, bufferlist& bl, uint64_t len, rgw::sal::Attrs& attrs, optional_yield y) = 0;
     virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs, optional_yield y) = 0;
     virtual int del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y) = 0;
index a7b2823276fd00f1def65ac7473b565b936929f0..fd7b44693e3ecb0c9bc222fd1eb40adee1b26aef 100644 (file)
@@ -59,13 +59,13 @@ void redis_exec(std::shared_ptr<connection> conn, boost::system::error_code& ec,
   }
 }
 
-int RedisDriver::initialize(CephContext* cct, const DoutPrefixProvider* dpp) 
+int RedisDriver::initialize(const DoutPrefixProvider* dpp)
 {
   if (partition_info.location.back() != '/') {
     partition_info.location += "/";
   }
 
-  std::string address = cct->_conf->rgw_local_cache_address;
+  std::string address = dpp->get_cct()->_conf->rgw_local_cache_address;
 
   config cfg;
   cfg.addr.host = address.substr(0, address.find(":"));
index cf9714b1cd676c9693b72057fffd19cfc2d6acb7..a219f7f9b289d1e69eae66fc85de3f508f193a30 100644 (file)
@@ -32,7 +32,7 @@ class RedisDriver : public CacheDriver {
     virtual Partition get_current_partition_info(const DoutPrefixProvider* dpp) override { return partition_info; }
     virtual uint64_t get_free_space(const DoutPrefixProvider* dpp) override { return free_space; }
 
-    virtual int initialize(CephContext* cct, const DoutPrefixProvider* dpp) override;
+    virtual int initialize(const DoutPrefixProvider* dpp) override;
     virtual int put(const DoutPrefixProvider* dpp, const std::string& key, bufferlist& bl, uint64_t len, rgw::sal::Attrs& attrs, optional_yield y) override;
     virtual int put_async(const DoutPrefixProvider* dpp, const std::string& key, bufferlist& bl, uint64_t len, rgw::sal::Attrs& attrs) override;
     virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs, optional_yield y) override;
index 3475563004245d1d2a1fd4ac77f9e4b757bd0fd4..85a929c69fee3051965f17f8d5bc1fa2e39464ca 100644 (file)
@@ -13,16 +13,14 @@ namespace rgw { namespace cache {
 
 constexpr std::string_view ATTR_PREFIX = "user.rgw.";
 
-int SSDDriver::initialize(CephContext* cct, const DoutPrefixProvider* dpp)
+int SSDDriver::initialize(const DoutPrefixProvider* dpp)
 {
-    this->cct = cct;
-
     if(partition_info.location.back() != '/') {
       partition_info.location += "/";
     }
     try {
         if (efs::exists(partition_info.location)) {
-            if (cct->_conf->rgw_d4n_l1_evict_cache_on_start) {
+            if (dpp->get_cct()->_conf->rgw_d4n_l1_evict_cache_on_start) {
                 ldpp_dout(dpp, 5) << "initialize: evicting the persistent storage directory on start" << dendl;
                 for (auto& p : efs::directory_iterator(partition_info.location)) {
                     efs::remove_all(p.path());
@@ -41,8 +39,8 @@ int SSDDriver::initialize(CephContext* cct, const DoutPrefixProvider* dpp)
     #if defined(HAVE_LIBAIO) && defined(__GLIBC__)
     // libaio setup
     struct aioinit ainit{0};
-    ainit.aio_threads = cct->_conf.get_val<int64_t>("rgw_d4n_libaio_aio_threads");
-    ainit.aio_num = cct->_conf.get_val<int64_t>("rgw_d4n_libaio_aio_num");
+    ainit.aio_threads = dpp->get_cct()->_conf.get_val<int64_t>("rgw_d4n_libaio_aio_threads");
+    ainit.aio_num = dpp->get_cct()->_conf.get_val<int64_t>("rgw_d4n_libaio_aio_num");
     ainit.aio_idle_time = 120;
     aio_init(&ainit);
     #endif
@@ -190,7 +188,7 @@ auto SSDDriver::get_async(const DoutPrefixProvider *dpp, ExecutionContext& ctx,
     auto p = Op::create(ctx.get_executor(), init.completion_handler);
     auto& op = p->user_data;
 
-    int ret = op.init(dpp, cct, location, read_ofs, read_len, p.get());
+    int ret = op.init(dpp, location, read_ofs, read_len, p.get());
     if(0 == ret) {
         ret = ::aio_read(op.aio_cb.get());
     }
@@ -308,7 +306,7 @@ void SSDDriver::AsyncWriteRequest::libaio_write_cb(sigval sigval)
   c->priv_data->libaio_write_completion_cb(c);
 }
 
-int SSDDriver::AsyncReadOp::init(const DoutPrefixProvider *dpp, CephContext* cct, const std::string& file_path, off_t read_ofs, off_t read_len, void* arg)
+int SSDDriver::AsyncReadOp::init(const DoutPrefixProvider *dpp, const std::string& file_path, off_t read_ofs, off_t read_len, void* arg)
 {
     ldpp_dout(dpp, 20) << "SSDCache: " << __func__ << "(): file_path=" << file_path << dendl;
     aio_cb.reset(new struct aiocb);
@@ -319,7 +317,7 @@ int SSDDriver::AsyncReadOp::init(const DoutPrefixProvider *dpp, CephContext* cct
         ldpp_dout(dpp, 1) << "ERROR: SSDCache: " << __func__ << "(): can't open " << file_path << " : " << " error: " << err << dendl;
         return -err;
     }
-    if (cct->_conf->rgw_d4n_l1_fadvise != POSIX_FADV_NORMAL) {
+    if (dpp->get_cct()->_conf->rgw_d4n_l1_fadvise != POSIX_FADV_NORMAL) {
         posix_fadvise(aio_cb->aio_fildes, 0, 0, g_conf()->rgw_d4n_l1_fadvise);
     }
 
index 11dfdb077e34ba23ebd677994fcc509ba89c3b4c..370204a2f93ba44dbe40f434cb4653657c617c39 100644 (file)
@@ -11,7 +11,7 @@ public:
   SSDDriver(Partition& partition_info) : partition_info(partition_info) {}
   virtual ~SSDDriver() {}
 
-  virtual int initialize(CephContext* cct, const DoutPrefixProvider* dpp) override;
+  virtual int initialize(const DoutPrefixProvider* dpp) override;
   virtual int put(const DoutPrefixProvider* dpp, const std::string& key, bufferlist& bl, uint64_t len, rgw::sal::Attrs& attrs, optional_yield y) override;
   virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs, optional_yield y) override;
   virtual int del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y) override { return -1; } // TODO: implement
@@ -45,7 +45,6 @@ public:
 protected:
   Partition partition_info;
   uint64_t free_space;
-  CephContext* cct;
 
 private:
 
@@ -75,7 +74,7 @@ struct AsyncReadOp {
   using Signature = void(boost::system::error_code, bufferlist);
   using Completion = ceph::async::Completion<Signature, AsyncReadOp>;
 
-  int init(const DoutPrefixProvider *dpp, CephContext* cct, const std::string& file_path, off_t read_ofs, off_t read_len, void* arg);
+  int init(const DoutPrefixProvider *dpp, const std::string& file_path, off_t read_ofs, off_t read_len, void* arg);
   static void libaio_cb_aio_dispatch(sigval sigval);
 
   template <typename Executor1, typename CompletionHandler>
index 5aff9b26a2a6ab33804a0ed0611565012599f67f..12df73a17e7f78eb851e5c6e491b965f994445c7 100644 (file)
@@ -70,7 +70,7 @@ class LFUDAPolicyFixture : public ::testing::Test {
       ASSERT_NE(conn, nullptr);
 
       dir->init(env->cct, env->dpp);
-      cacheDriver->initialize(env->cct, env->dpp);
+      cacheDriver->initialize(env->dpp);
       policyDriver->get_cache_policy()->init(env->cct, env->dpp);
 
       bl.append("test data");
index e06ae124cdfec14e178e9e9535a1d04610dd4573..e6a9c7c67fc2b9201b679a09c2d1dc81b6c18936 100644 (file)
@@ -52,7 +52,7 @@ class RedisDriverFixture: public ::testing::Test {
       ASSERT_NE(cacheDriver, nullptr);
       ASSERT_NE(conn, nullptr);
 
-      cacheDriver->initialize(env->cct, env->dpp);
+      cacheDriver->initialize(env->dpp);
 
       bl.append("test data");
       bufferlist attrVal;
index 04019f0f2b6b157457c65e8a896bca09cf3f84c9..dc5354030d505a24a1ae81c0cbe90c43e3af72e7 100644 (file)
@@ -43,7 +43,7 @@ class SSDDriverFixture: public ::testing::Test {
 
         ASSERT_NE(cacheDriver, nullptr);
 
-        cacheDriver->initialize(env->cct, env->dpp);
+        cacheDriver->initialize(env->dpp);
 
         bl.append("This is testdata");
         attrVal.append("attrVal");