From 16dfce46c6d16658f75be79ce11506c4bf96149f Mon Sep 17 00:00:00 2001 From: Pritha Srivastava Date: Tue, 12 Dec 2023 09:31:28 +0530 Subject: [PATCH] rgw/cache: removing interface related to Partition. Signed-off-by: Pritha Srivastava --- src/rgw/rgw_redis_driver.cc | 37 ------------------------------- src/rgw/rgw_redis_driver.h | 13 +---------- src/rgw/rgw_ssd_driver.cc | 43 ------------------------------------- src/rgw/rgw_ssd_driver.h | 10 ++------- 4 files changed, 3 insertions(+), 100 deletions(-) diff --git a/src/rgw/rgw_redis_driver.cc b/src/rgw/rgw_redis_driver.cc index f981e74502d56..fb2d6bcd9873c 100644 --- a/src/rgw/rgw_redis_driver.cc +++ b/src/rgw/rgw_redis_driver.cc @@ -7,8 +7,6 @@ namespace rgw { namespace cache { -std::unordered_map RedisDriver::partitions; - std::list build_attrs(rgw::sal::Attrs* binary) { std::list values; @@ -61,41 +59,6 @@ void redis_exec(std::shared_ptr conn, boost::system::error_code& ec, } } -int RedisDriver::add_partition_info(Partition& info) -{ - std::string key = info.name + info.type; - auto ret = partitions.emplace(key, info); - - return ret.second; -} - -int RedisDriver::remove_partition_info(Partition& info) -{ - std::string key = info.name + info.type; - return partitions.erase(key); -} - -std::optional RedisDriver::get_partition_info(const DoutPrefixProvider* dpp, const std::string& name, const std::string& type) -{ - std::string key = name + type; - - auto iter = partitions.find(key); - if (iter != partitions.end()) - return iter->second; - - return std::nullopt; -} - -std::vector RedisDriver::list_partitions(const DoutPrefixProvider* dpp) -{ - std::vector partitions_v; - - for (auto& it : partitions) - partitions_v.emplace_back(it.second); - - return partitions_v; -} - int RedisDriver::initialize(CephContext* cct, const DoutPrefixProvider* dpp) { if (partition_info.location.back() != '/') { diff --git a/src/rgw/rgw_redis_driver.h b/src/rgw/rgw_redis_driver.h index 87815fb98dcd1..b0b69522bdd2a 100644 --- a/src/rgw/rgw_redis_driver.h +++ b/src/rgw/rgw_redis_driver.h @@ -25,18 +25,12 @@ class RedisDriver : public CacheDriver { outstanding_write_size(0) { conn = std::make_shared(boost::asio::make_strand(io_context)); - add_partition_info(_partition_info); - } - virtual ~RedisDriver() - { - remove_partition_info(partition_info); } + virtual ~RedisDriver() {} /* Partition */ 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; } - static std::optional get_partition_info(const DoutPrefixProvider* dpp, const std::string& name, const std::string& type); - static std::vector list_partitions(const DoutPrefixProvider* dpp); virtual int initialize(CephContext* cct, 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; @@ -73,14 +67,9 @@ class RedisDriver : public CacheDriver { protected: std::shared_ptr conn; - - static std::unordered_map partitions; Partition partition_info; uint64_t free_space; uint64_t outstanding_write_size; - - int add_partition_info(Partition& info); - int remove_partition_info(Partition& info); }; } } // namespace rgw::cache diff --git a/src/rgw/rgw_ssd_driver.cc b/src/rgw/rgw_ssd_driver.cc index 56a9fb1a5e0bd..56b58b151effd 100644 --- a/src/rgw/rgw_ssd_driver.cc +++ b/src/rgw/rgw_ssd_driver.cc @@ -18,49 +18,6 @@ namespace rgw { namespace cache { constexpr std::string_view ATTR_PREFIX = "user.rgw."; -std::optional SSDDriver::get_partition_info(const DoutPrefixProvider* dpp, const std::string& name, const std::string& type) -{ - std::string key = name + type; - auto iter = partitions.find(key); - if (iter != partitions.end()) { - return iter->second; - } - - return std::nullopt; -} - -std::vector SSDDriver::list_partitions(const DoutPrefixProvider* dpp) -{ - std::vector partitions_v; - for (auto& it : SSDDriver::partitions) { - partitions_v.emplace_back(it.second); - } - return partitions_v; -} - -int SSDDriver::add_partition_info(Partition& info) -{ - std::string key = info.name + info.type; - auto ret = partitions.emplace(key, info); - return ret.second; -} - -int SSDDriver::remove_partition_info(Partition& info) -{ - std::string key = info.name + info.type; - return partitions.erase(key); -} - -SSDDriver::SSDDriver(Partition& partition_info) : partition_info(partition_info) -{ - add_partition_info(partition_info); -} - -SSDDriver::~SSDDriver() -{ - remove_partition_info(partition_info); -} - int SSDDriver::initialize(CephContext* cct, const DoutPrefixProvider* dpp) { this->cct = cct; diff --git a/src/rgw/rgw_ssd_driver.h b/src/rgw/rgw_ssd_driver.h index 962b5834e146d..4084a0aaa456b 100644 --- a/src/rgw/rgw_ssd_driver.h +++ b/src/rgw/rgw_ssd_driver.h @@ -8,8 +8,8 @@ namespace rgw { namespace cache { class SSDDriver : public CacheDriver { public: - SSDDriver(Partition& partition_info); - virtual ~SSDDriver(); + SSDDriver(Partition& partition_info) : partition_info(partition_info) {} + virtual ~SSDDriver() {} virtual int initialize(CephContext* cct, 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; @@ -30,8 +30,6 @@ public: /* Partition */ 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; } - static std::optional get_partition_info(const DoutPrefixProvider* dpp, const std::string& name, const std::string& type); - static std::vector list_partitions(const DoutPrefixProvider* dpp); struct libaio_handler { rgw::Aio* throttle = nullptr; @@ -45,14 +43,10 @@ public: }; protected: - inline static std::unordered_map partitions; Partition partition_info; uint64_t free_space; CephContext* cct; - int add_partition_info(Partition& info); - int remove_partition_info(Partition& info); - private: // unique_ptr with custom deleter for struct aiocb -- 2.39.5