From: Pritha Srivastava Date: Fri, 2 Jun 2023 10:16:23 +0000 (+0530) Subject: rgw/cache: This commit squashes modifications to base class. X-Git-Tag: v20.0.0~2219^2~86 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3172b7520c7b7b2449941e2ac4d1d2e36305bf57;p=ceph.git rgw/cache: This commit squashes modifications to base class. 1. Rename namespace from rgw::cal to rgw::cache 2. Remove Partition from the CacheDriver constructor. 3. Removing rgw_cache_driver.cc since all methods are pure virtual in rgw_cache_driver.h. 4. Moving structures Partition and Entry out of class CacheDriver. And modifying the signatures of methods get_current_partition_info() and get_free_space(). 5. modifying the cache driver base class. Signed-off-by: Pritha Srivastava --- diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 43611c8aeff..1bf433cb395 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -116,7 +116,6 @@ set(librgw_common_srcs rgw_role.cc rgw_sal.cc rgw_sal_filter.cc - rgw_cache_driver.cc rgw_string.cc rgw_tag.cc rgw_tag_s3.cc diff --git a/src/rgw/rgw_cache_driver.cc b/src/rgw/rgw_cache_driver.cc deleted file mode 100644 index 859e2eeb4ba..00000000000 --- a/src/rgw/rgw_cache_driver.cc +++ /dev/null @@ -1,57 +0,0 @@ -#include "rgw_cache_driver.h" - -namespace rgw { - -int CacheDriver::initialize(CephContext* cct, const DoutPrefixProvider* dpp) { - return 0; -} - -bool CacheDriver::key_exists(const DoutPrefixProvider* dpp, std::string& key) { - return false; -} - -int CacheDriver::put(const DoutPrefixProvider* dpp, const std::string& key, bufferlist& bl, uint64_t len, rgw::sal::Attrs& attrs) { - return 0; -} - -int CacheDriver::get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs) { - return 0; -} - -/*rgw::AioResultList CacheDriver::get_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, off_t ofs, uint64_t len, uint64_t cost, uint64_t id) { - return nullptr; -} - -rgw::AioResultList CacheDriver::put_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, bufferlist& bl, uint64_t len, uint64_t cost, uint64_t id) { - return nullptr; -}*/ - -int CacheDriver::append_data(const DoutPrefixProvider* dpp, const::std::string& key, bufferlist& bl_data) { - return 0; -} - -int CacheDriver::delete_data(const DoutPrefixProvider* dpp, const::std::string& key) { - return 0; -} - -int CacheDriver::get_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) { - return 0; -} - -int CacheDriver::update_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) { - return 0; -} - -int CacheDriver::delete_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& del_attrs) { - return 0; -} - -std::string CacheDriver::get_attr(const DoutPrefixProvider* dpp, const std::string& key, const std::string& attr_name) { - return {}; -} - -int CacheDriver::set_attr(const DoutPrefixProvider* dpp, const std::string& key, const std::string& attr_name, const std::string& attr_val) { - return 0; -} - -} // namespace rgw::sal diff --git a/src/rgw/rgw_cache_driver.h b/src/rgw/rgw_cache_driver.h index 1cec378eecc..a96b3256100 100644 --- a/src/rgw/rgw_cache_driver.h +++ b/src/rgw/rgw_cache_driver.h @@ -1,85 +1,47 @@ -#ifndef CEPH_CACHEDRIVER_H -#define CEPH_CACHEDRIVER_H +#pragma once -#include -#include #include "rgw_common.h" -namespace rgw { +namespace rgw { namespace cache { -class CacheDriver { - /*struct CacheAioRequest {*/ - /* This will be invoked from rgw_aio.cc, to asynchronously read from / write to the cache backend. We will also need to define ops like the following in rgw_aio.h - Aio::OpFunc Aio::cache_read_op(const DoutPrefixProvider* dpp, optional_yield y, off_t ofs, uint64_t len) - Aio::OpFunc Aio::cache_write_op(const DoutPrefixProvider* dpp, optional_yield y, bufferlist& bl, uint64_t len)*/ - - /*void cache_aio_read_abstract(const DoutPrefixProvider* dpp, boost::asio::io_context& context, yield_context yield, off_t ofs, uint64_t len, rgw::Aio* aio, rgw::AioResult r); - void cache_aio_write_abstract(const DoutPrefixProvider* dpp, boost::asio::io_context& context, yield_context yield, bufferlist& bl, uint64_t len, rgw::Aio* aio, rgw::AioResult r); - };*/ +struct Partition { + std::string name; + std::string type; + std::string location; + uint64_t size; +}; - /* For Write-back cache*/ - /*struct DirtyObjectsState { - std::string key; - ceph::real _time creation_time; - ceph::real lifetime; // time after which it will be written out to the store - - std::queue dirty_obs_queue; - void write_to_store(); - };*/ +struct Entry { + std::string key; + off_t offset; + uint64_t len; +}; +class CacheDriver { public: - struct Entry { - std::string key; - off_t offset; - uint64_t len; - std::string location; //??? - - int insert_entry(const DoutPrefixProvider* dpp, std::string key, off_t offset, uint64_t len); - int remove_entry(const DoutPrefixProvider* dpp, std::string key); - Entry& get_entry(const DoutPrefixProvider* dpp, std::string key); - }; - - struct Partition { - std::string name; - std::string type; - std::string location; - uint64_t size; - - //std::unordered_map list_partitions() { return nullptr; } - //Partition& get_partition_info(const std::string& name, const std::string& type) { return nullptr; } - //Partition& get_current_partition_info() { return nullptr; } - uint64_t get_free_space() { return 0; } - }; - - Partition partition_info; - - CacheDriver(Partition& _partition_info) : partition_info(_partition_info) {} - virtual ~CacheDriver() {} + CacheDriver() {} + virtual ~CacheDriver() = default; virtual int initialize(CephContext* cct, const DoutPrefixProvider* dpp) = 0; - virtual bool key_exists(const DoutPrefixProvider* dpp, std::string& key) = 0; virtual int put(const DoutPrefixProvider* dpp, const std::string& key, bufferlist& bl, uint64_t len, rgw::sal::Attrs& attrs) = 0; virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs) = 0; - //virtual rgw::AioResultList& get_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, off_t ofs, uint64_t len, uint64_t cost, uint64_t id) = 0; - /* Assuming that we want to throttle put requests also */ - //virtual rgw::AioResultList put_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, bufferlist& bl, uint64_t len, uint64_t cost, uint64_t id) = 0; virtual int append_data(const DoutPrefixProvider* dpp, const::std::string& key, bufferlist& bl_data) = 0; virtual int delete_data(const DoutPrefixProvider* dpp, const::std::string& key) = 0; virtual int get_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) = 0; + virtual int set_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) = 0; virtual int update_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) = 0; virtual int delete_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& del_attrs) = 0; virtual std::string get_attr(const DoutPrefixProvider* dpp, const std::string& key, const std::string& attr_name) = 0; virtual int set_attr(const DoutPrefixProvider* dpp, const std::string& key, const std::string& attr_name, const std::string& attr_val) = 0; /* Entry */ - //std::unordered_map& list_entries(const DoutPrefixProvider* dpp); - size_t get_num_entries(const DoutPrefixProvider* dpp) { return 0; } + virtual bool key_exists(const DoutPrefixProvider* dpp, const std::string& key) = 0; + virtual size_t get_num_entries(const DoutPrefixProvider* dpp) = 0; /* Partition */ - //static std::unordered_map partitions() { return nullptr; } - int add_partition_info(const std::string& name, const std::string& type, const std::string& location, uint64_t size) { return 0; } + virtual Partition get_current_partition_info(const DoutPrefixProvider* dpp) = 0; + virtual uint64_t get_free_space(const DoutPrefixProvider* dpp) = 0; }; -} // namespace rgw::sal +} } // namespace rgw::cache -#endif