From 3757bd7a213484ff39b9aaa138db33bd27b868df Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 11 Jun 2019 12:36:25 -0700 Subject: [PATCH] rgw: svc.bucket: split into svc.bucket, svc.bucket_sobj separate abstraction and implementation for clearer intention Signed-off-by: Yehuda Sadeh --- src/rgw/CMakeLists.txt | 1 + src/rgw/rgw_service.cc | 5 +- src/rgw/rgw_service.h | 4 +- .../{svc_bucket.cc => svc_bucket_sobj.cc} | 186 ++++++++---------- .../{svc_bucket.h => svc_bucket_sobj.h} | 36 ++-- src/rgw/services/svc_bucket_types.h | 1 + 6 files changed, 109 insertions(+), 124 deletions(-) rename src/rgw/services/{svc_bucket.cc => svc_bucket_sobj.cc} (70%) rename src/rgw/services/{svc_bucket.h => svc_bucket_sobj.h} (87%) diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index c0a8336aa85..c3134104592 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -23,6 +23,7 @@ set(librgw_common_srcs services/svc_finisher.cc services/svc_bi_rados.cc services/svc_bucket.cc + services/svc_bucket_sobj.cc services/svc_cls.cc services/svc_mdlog.cc services/svc_meta.cc diff --git a/src/rgw/rgw_service.cc b/src/rgw/rgw_service.cc index 5dd88ce0399..533eb4047b7 100644 --- a/src/rgw/rgw_service.cc +++ b/src/rgw/rgw_service.cc @@ -5,7 +5,7 @@ #include "services/svc_finisher.h" #include "services/svc_bi_rados.h" -#include "services/svc_bucket.h" +#include "services/svc_bucket_sobj.h" #include "services/svc_cls.h" #include "services/svc_mdlog.h" #include "services/svc_meta.h" @@ -45,7 +45,7 @@ int RGWServices_Def::init(CephContext *cct, bool raw) { finisher = std::make_unique(cct); - bucket = std::make_unique(cct); + bucket_sobj = std::make_unique(cct); bi_rados = std::make_unique(cct); cls = std::make_unique(cct); mdlog = std::make_unique(cct); @@ -249,6 +249,7 @@ int RGWServices::do_init(CephContext *_cct, bool have_cache, bool raw) finisher = _svc.finisher.get(); bi_rados = _svc.bi_rados.get(); bi = bi_rados; + bucket_sobj = _svc.bucket_sobj.get(); bucket = _svc.bucket.get(); cls = _svc.cls.get(); mdlog = _svc.mdlog.get(); diff --git a/src/rgw/rgw_service.h b/src/rgw/rgw_service.h index aea750b8948..c2b99a83a6f 100644 --- a/src/rgw/rgw_service.h +++ b/src/rgw/rgw_service.h @@ -46,6 +46,7 @@ public: class RGWSI_Finisher; class RGWSI_Bucket; +class RGWSI_Bucket_SObj; class RGWSI_BucketIndex; class RGWSI_BucketIndex_RADOS; class RGWSI_Cls; @@ -73,7 +74,7 @@ struct RGWServices_Def bool has_shutdown{false}; std::unique_ptr finisher; - std::unique_ptr bucket; + std::unique_ptr bucket_sobj; std::unique_ptr bi_rados; std::unique_ptr cls; std::unique_ptr mdlog; @@ -108,6 +109,7 @@ struct RGWServices RGWSI_Finisher *finisher{nullptr}; RGWSI_Bucket *bucket{nullptr}; + RGWSI_Bucket_SObj *bucket_sobj{nullptr}; RGWSI_BucketIndex *bi{nullptr}; RGWSI_BucketIndex_RADOS *bi_rados{nullptr}; RGWSI_Cls *cls{nullptr}; diff --git a/src/rgw/services/svc_bucket.cc b/src/rgw/services/svc_bucket_sobj.cc similarity index 70% rename from src/rgw/services/svc_bucket.cc rename to src/rgw/services/svc_bucket_sobj.cc index 210263657b4..07cb7e9d69c 100644 --- a/src/rgw/services/svc_bucket.cc +++ b/src/rgw/services/svc_bucket_sobj.cc @@ -1,6 +1,6 @@ -#include "svc_bucket.h" +#include "svc_bucket_sobj.h" #include "svc_zone.h" #include "svc_sys_obj.h" #include "svc_sys_obj_cache.h" @@ -17,12 +17,12 @@ #define RGW_BUCKET_INSTANCE_MD_PREFIX ".bucket.meta." -class RGWSI_Bucket_Module : public RGWSI_MBSObj_Handler_Module { - RGWSI_Bucket::Svc& svc; +class RGWSI_Bucket_SObj_Module : public RGWSI_MBSObj_Handler_Module { + RGWSI_Bucket_SObj::Svc& svc; const string prefix; public: - RGWSI_Bucket_Module(RGWSI_Bucket::Svc& _svc) : RGWSI_MBSObj_Handler_Module("bucket"), + RGWSI_Bucket_SObj_Module(RGWSI_Bucket_SObj::Svc& _svc) : RGWSI_MBSObj_Handler_Module("bucket"), svc(_svc) {} void get_pool_and_oid(const string& key, rgw_pool *pool, string *oid) override { @@ -53,13 +53,13 @@ public: } }; -class RGWSI_BucketInstance_Module : public RGWSI_MBSObj_Handler_Module { - RGWSI_Bucket::Svc& svc; +class RGWSI_BucketInstance_SObj_Module : public RGWSI_MBSObj_Handler_Module { + RGWSI_Bucket_SObj::Svc& svc; const string prefix; public: - RGWSI_BucketInstance_Module(RGWSI_Bucket::Svc& _svc) : RGWSI_MBSObj_Handler_Module("bucket.instance"), - svc(_svc), prefix(RGW_BUCKET_INSTANCE_MD_PREFIX) {} + RGWSI_BucketInstance_SObj_Module(RGWSI_Bucket_SObj::Svc& _svc) : RGWSI_MBSObj_Handler_Module("bucket.instance"), + svc(_svc), prefix(RGW_BUCKET_INSTANCE_MD_PREFIX) {} void get_pool_and_oid(const string& key, rgw_pool *pool, string *oid) override { if (pool) { @@ -134,16 +134,16 @@ public: } }; -RGWSI_Bucket::RGWSI_Bucket(CephContext *cct): RGWServiceInstance(cct) { +RGWSI_Bucket_SObj::RGWSI_Bucket_SObj(CephContext *cct): RGWSI_Bucket(cct) { } -RGWSI_Bucket::~RGWSI_Bucket() { +RGWSI_Bucket_SObj::~RGWSI_Bucket_SObj() { } -void RGWSI_Bucket::init(RGWSI_Zone *_zone_svc, RGWSI_SysObj *_sysobj_svc, - RGWSI_SysObj_Cache *_cache_svc, RGWSI_BucketIndex *_bi, - RGWSI_Meta *_meta_svc, RGWSI_MetaBackend *_meta_be_svc, - RGWSI_SyncModules *_sync_modules_svc) +void RGWSI_Bucket_SObj::init(RGWSI_Zone *_zone_svc, RGWSI_SysObj *_sysobj_svc, + RGWSI_SysObj_Cache *_cache_svc, RGWSI_BucketIndex *_bi, + RGWSI_Meta *_meta_svc, RGWSI_MetaBackend *_meta_be_svc, + RGWSI_SyncModules *_sync_modules_svc) { svc.bucket = this; svc.zone = _zone_svc; @@ -155,24 +155,7 @@ void RGWSI_Bucket::init(RGWSI_Zone *_zone_svc, RGWSI_SysObj *_sysobj_svc, svc.sync_modules = _sync_modules_svc; } -string RGWSI_Bucket::get_entrypoint_meta_key(const rgw_bucket& bucket) -{ - if (bucket.bucket_id.empty()) { - return bucket.get_key(); - } - - rgw_bucket b(bucket); - b.bucket_id.clear(); - - return b.get_key(); -} - -string RGWSI_Bucket::get_bi_meta_key(const rgw_bucket& bucket) -{ - return bucket.get_key(); -} - -int RGWSI_Bucket::do_start() +int RGWSI_Bucket_SObj::do_start() { binfo_cache.reset(new RGWChainedCacheImpl); binfo_cache->init(svc.cache); @@ -191,7 +174,7 @@ int RGWSI_Bucket::do_start() RGWSI_MetaBackend_Handler_SObj *ep_bh = static_cast(ep_handler); - auto ep_module = new RGWSI_Bucket_Module(svc); + auto ep_module = new RGWSI_Bucket_SObj_Module(svc); ep_be_module.reset(ep_module); ep_bh->set_module(ep_module); @@ -209,22 +192,22 @@ int RGWSI_Bucket::do_start() RGWSI_MetaBackend_Handler_SObj *bi_bh = static_cast(bi_handler); - auto bi_module = new RGWSI_BucketInstance_Module(svc); + auto bi_module = new RGWSI_BucketInstance_SObj_Module(svc); bi_be_module.reset(bi_module); bi_bh->set_module(bi_module); return 0; } -int RGWSI_Bucket::read_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, - const string& key, - RGWBucketEntryPoint *entry_point, - RGWObjVersionTracker *objv_tracker, - real_time *pmtime, - map *pattrs, - optional_yield y, - rgw_cache_entry_info *cache_info, - boost::optional refresh_version) +int RGWSI_Bucket_SObj::read_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, + const string& key, + RGWBucketEntryPoint *entry_point, + RGWObjVersionTracker *objv_tracker, + real_time *pmtime, + map *pattrs, + optional_yield y, + rgw_cache_entry_info *cache_info, + boost::optional refresh_version) { bufferlist bl; @@ -246,14 +229,14 @@ int RGWSI_Bucket::read_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, return 0; } -int RGWSI_Bucket::store_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, - const string& key, - RGWBucketEntryPoint& info, - bool exclusive, - real_time mtime, - map *pattrs, - RGWObjVersionTracker *objv_tracker, - optional_yield y) +int RGWSI_Bucket_SObj::store_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, + const string& key, + RGWBucketEntryPoint& info, + bool exclusive, + real_time mtime, + map *pattrs, + RGWObjVersionTracker *objv_tracker, + optional_yield y) { bufferlist bl; encode(info, bl); @@ -280,21 +263,22 @@ int RGWSI_Bucket::store_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, return ret; } -int RGWSI_Bucket::remove_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, - const string& key, - optional_yield y) +int RGWSI_Bucket_SObj::remove_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, + const string& key, + RGWObjVersionTracker *objv_tracker, + optional_yield y) { RGWSI_MBSObj_RemoveParams params; return svc.meta_be->remove(ctx.get(), key, params, objv_tracker, y); } -int RGWSI_Bucket::read_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, - const string& key, - RGWBucketInfo *info, - real_time *pmtime, map *pattrs, - optional_yield y, - rgw_cache_entry_info *cache_info, - boost::optional refresh_version) +int RGWSI_Bucket_SObj::read_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, + const string& key, + RGWBucketInfo *info, + real_time *pmtime, map *pattrs, + optional_yield y, + rgw_cache_entry_info *cache_info, + boost::optional refresh_version) { #warning cache set/get is a mess if (auto e = binfo_cache->find(key)) { @@ -323,13 +307,13 @@ int RGWSI_Bucket::read_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, return 0; } -int RGWSI_Bucket::do_read_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, - const string& key, - RGWBucketInfo *info, - real_time *pmtime, map *pattrs, - rgw_cache_entry_info *cache_info, - boost::optional refresh_version, - optional_yield y) +int RGWSI_Bucket_SObj::do_read_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, + const string& key, + RGWBucketInfo *info, + real_time *pmtime, map *pattrs, + rgw_cache_entry_info *cache_info, + boost::optional refresh_version, + optional_yield y) { bufferlist bl; RGWObjVersionTracker ot; @@ -357,13 +341,13 @@ int RGWSI_Bucket::do_read_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, return 0; } -int RGWSI_Bucket::read_bucket_info(RGWSI_Bucket_X_Ctx& ctx, - const rgw_bucket& bucket, - RGWBucketInfo *info, - real_time *pmtime, - map *pattrs, - boost::optional refresh_version, - optional_yield y) +int RGWSI_Bucket_SObj::read_bucket_info(RGWSI_Bucket_X_Ctx& ctx, + const rgw_bucket& bucket, + RGWBucketInfo *info, + real_time *pmtime, + map *pattrs, + boost::optional refresh_version, + optional_yield y) { rgw_cache_entry_info cache_info; @@ -467,14 +451,14 @@ int RGWSI_Bucket::read_bucket_info(RGWSI_Bucket_X_Ctx& ctx, } -int RGWSI_Bucket::store_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, - const string& key, - RGWBucketInfo& info, - std::optional orig_info, - bool exclusive, - real_time mtime, - map *pattrs, - optional_yield y) +int RGWSI_Bucket_SObj::store_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, + const string& key, + RGWBucketInfo& info, + std::optional orig_info, + bool exclusive, + real_time mtime, + map *pattrs, + optional_yield y) { bufferlist bl; encode(info, bl); @@ -536,10 +520,10 @@ int RGWSI_Bucket::store_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, return ret; } -int RGWSI_Bucket::handle_bucket_overwrite(RGWSI_Bucket_BI_Ctx& ctx, - const string& key, - const RGWBucketInfo& info, - const RGWBucketInfo& orig_info) +int RGWSI_Bucket_SObj::handle_bucket_overwrite(RGWSI_Bucket_BI_Ctx& ctx, + const string& key, + const RGWBucketInfo& info, + const RGWBucketInfo& orig_info) { if (orig_info.datasync_flag_enabled() != info.datasync_flag_enabled()) { int shards_num = info.num_shards? info.num_shards : 1; @@ -568,18 +552,18 @@ int RGWSI_Bucket::handle_bucket_overwrite(RGWSI_Bucket_BI_Ctx& ctx, return 0; } -int RGWSI_Bucket::remove_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, - const string& key, - RGWObjVersionTracker *objv_tracker, - optional_yield y) +int RGWSI_Bucket_SObj::remove_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, + const string& key, + RGWObjVersionTracker *objv_tracker, + optional_yield y) { RGWSI_MBSObj_RemoveParams params; return svc.meta_be->remove_entry(ctx.get(), key, params, objv_tracker, y); } -int RGWSI_Bucket::read_bucket_stats(const RGWBucketInfo& bucket_info, - RGWBucketEnt *ent, - optional_yield y) +int RGWSI_Bucket_SObj::read_bucket_stats(const RGWBucketInfo& bucket_info, + RGWBucketEnt *ent, + optional_yield y) { ent->count = 0; ent->size = 0; @@ -596,10 +580,10 @@ int RGWSI_Bucket::read_bucket_stats(const RGWBucketInfo& bucket_info, return 0; } -int RGWSI_Bucket::read_bucket_stats(RGWSI_Bucket_X_Ctx& ctx, - const rgw_bucket& bucket, - RGWBucketEnt *ent, - optional_yield y) +int RGWSI_Bucket_SObj::read_bucket_stats(RGWSI_Bucket_X_Ctx& ctx, + const rgw_bucket& bucket, + RGWBucketEnt *ent, + optional_yield y) { RGWBucketInfo bucket_info; int ret = read_bucket_info(ctx, bucket, &bucket_info, nullptr, nullptr, boost::none, y); @@ -610,9 +594,9 @@ int RGWSI_Bucket::read_bucket_stats(RGWSI_Bucket_X_Ctx& ctx, return read_bucket_stats(bucket_info, ent, y); } -int RGWSI_Bucket::read_buckets_stats(RGWSI_Bucket_X_Ctx& ctx, - map& m, - optional_yield y) +int RGWSI_Bucket_SObj::read_buckets_stats(RGWSI_Bucket_X_Ctx& ctx, + map& m, + optional_yield y) { map::iterator iter; for (iter = m.begin(); iter != m.end(); ++iter) { diff --git a/src/rgw/services/svc_bucket.h b/src/rgw/services/svc_bucket_sobj.h similarity index 87% rename from src/rgw/services/svc_bucket.h rename to src/rgw/services/svc_bucket_sobj.h index 1aa6fe2579a..02a96106847 100644 --- a/src/rgw/services/svc_bucket.h +++ b/src/rgw/services/svc_bucket_sobj.h @@ -21,6 +21,7 @@ #include "svc_meta_be.h" #include "svc_bucket_types.h" +#include "svc_bucket.h" class RGWSI_Zone; class RGWSI_SysObj; @@ -33,10 +34,8 @@ struct rgw_cache_entry_info; template class RGWChainedCacheImpl; -class RGWSI_Bucket : public RGWServiceInstance +class RGWSI_Bucket_SObj : public RGWSI_Bucket { - friend class Instance; - struct bucket_info_cache_entry { RGWBucketInfo info; real_time mtime; @@ -71,7 +70,7 @@ class RGWSI_Bucket : public RGWServiceInstance const RGWBucketInfo& orig_info); public: struct Svc { - RGWSI_Bucket *bucket{nullptr}; + RGWSI_Bucket_SObj *bucket{nullptr}; RGWSI_BucketIndex *bi{nullptr}; RGWSI_Zone *zone{nullptr}; RGWSI_SysObj *sysobj{nullptr}; @@ -81,17 +80,14 @@ public: RGWSI_SyncModules *sync_modules{nullptr}; } svc; - RGWSI_Bucket(CephContext *cct); - ~RGWSI_Bucket(); - - static string get_entrypoint_meta_key(const rgw_bucket& bucket); - static string get_bi_meta_key(const rgw_bucket& bucket); + RGWSI_Bucket_SObj(CephContext *cct); + ~RGWSI_Bucket_SObj(); - RGWSI_Bucket_BE_Handler& get_ep_be_handler() { + RGWSI_Bucket_BE_Handler& get_ep_be_handler() override { return ep_be_handler; } - RGWSI_BucketInstance_BE_Handler& get_bi_be_handler() { + RGWSI_BucketInstance_BE_Handler& get_bi_be_handler() override { return bi_be_handler; } @@ -112,7 +108,7 @@ public: map *pattrs, optional_yield y, rgw_cache_entry_info *cache_info = nullptr, - boost::optional refresh_version = boost::none); + boost::optional refresh_version = boost::none) override; int store_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, const string& key, @@ -121,12 +117,12 @@ public: real_time mtime, map *pattrs, RGWObjVersionTracker *objv_tracker, - optional_yield y); + optional_yield y) override; int remove_bucket_entrypoint_info(RGWSI_Bucket_EP_Ctx& ctx, const string& key, RGWObjVersionTracker *objv_tracker, - optional_yield y); + optional_yield y) override; int read_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, const string& key, @@ -135,7 +131,7 @@ public: map *pattrs, optional_yield y, rgw_cache_entry_info *cache_info = nullptr, - boost::optional refresh_version = boost::none); + boost::optional refresh_version = boost::none) override; int read_bucket_info(RGWSI_Bucket_X_Ctx& ep_ctx, const rgw_bucket& bucket, @@ -143,7 +139,7 @@ public: real_time *pmtime, map *pattrs, boost::optional refresh_version, - optional_yield y); + optional_yield y) override; int store_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, const string& key, @@ -153,20 +149,20 @@ public: bool exclusive, real_time mtime, map *pattrs, - optional_yield y); + optional_yield y) override; int remove_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, const string& key, RGWObjVersionTracker *objv_tracker, - optional_yield y); + optional_yield y) override; int read_bucket_stats(RGWSI_Bucket_X_Ctx& ctx, const rgw_bucket& bucket, RGWBucketEnt *ent, - optional_yield y); + optional_yield y) override; int read_buckets_stats(RGWSI_Bucket_X_Ctx& ctx, map& m, - optional_yield y); + optional_yield y) override; }; diff --git a/src/rgw/services/svc_bucket_types.h b/src/rgw/services/svc_bucket_types.h index 8cb677ca30e..11e1e972cc3 100644 --- a/src/rgw/services/svc_bucket_types.h +++ b/src/rgw/services/svc_bucket_types.h @@ -16,6 +16,7 @@ #include "common/ptr_wrapper.h" +#include "svc_meta_be.h" #include "svc_meta_be_types.h" class RGWSI_MetaBackend_Handler; -- 2.39.5