From 0736b085a7c22484585e852700ff42b04d14797c Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 7 Sep 2018 03:26:36 -0700 Subject: [PATCH] rgw: svc: more changes, add svc_sync_modules radosgw actually compiles now Signed-off-by: Yehuda Sadeh --- src/rgw/CMakeLists.txt | 1 + src/rgw/rgw_admin.cc | 11 +++++--- src/rgw/rgw_data_sync.cc | 3 ++- src/rgw/rgw_rados.cc | 17 +++++++----- src/rgw/rgw_rados.h | 8 +++--- src/rgw/rgw_rest_realm.cc | 2 +- src/rgw/rgw_service.cc | 2 ++ src/rgw/rgw_zone.cc | 37 +++++++++++---------------- src/rgw/rgw_zone.h | 9 ++++--- src/rgw/services/svc_finisher.cc | 14 +++++++--- src/rgw/services/svc_finisher.h | 5 +++- src/rgw/services/svc_notify.cc | 17 +++++++++--- src/rgw/services/svc_sync_modules.cc | 32 +++++++++++++++++++++++ src/rgw/services/svc_sync_modules.h | 36 ++++++++++++++++++++++++++ src/rgw/services/svc_sys_obj.cc | 13 ++++++++-- src/rgw/services/svc_sys_obj.h | 27 ++++++++++++++----- src/rgw/services/svc_sys_obj_cache.cc | 30 ++++++++++++++++++++++ src/rgw/services/svc_sys_obj_core.cc | 16 ++++++++++++ src/rgw/services/svc_sys_obj_core.h | 5 ++++ src/rgw/services/svc_zone.cc | 24 +++++++++++------ src/rgw/services/svc_zone.h | 2 ++ 21 files changed, 243 insertions(+), 68 deletions(-) create mode 100644 src/rgw/services/svc_sync_modules.cc create mode 100644 src/rgw/services/svc_sync_modules.h diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 9711f45e2ae..d818f857085 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -42,6 +42,7 @@ set(librgw_common_srcs services/svc_finisher.cc services/svc_notify.cc services/svc_quota.cc + services/svc_sync_modules.cc services/svc_rados.cc services/svc_sys_obj.cc services/svc_sys_obj_cache.cc diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 99cfe4c0b79..af05dbe73de 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -3865,7 +3865,8 @@ int main(int argc, const char **argv) (is_read_only_set ? &read_only : NULL), endpoints, ptier_type, psync_from_all, sync_from, sync_from_rm, - predirect_zone); + predirect_zone, + store->svc.sync_modules->get_manager()); if (ret < 0) { cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name() << ": " << cpp_strerror(-ret) << std::endl; @@ -4296,7 +4297,8 @@ int main(int argc, const char **argv) ptier_type, psync_from_all, sync_from, sync_from_rm, - predirect_zone); + predirect_zone, + store->svc.sync_modules->get_manager()); if (ret < 0) { cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name() << ": " << cpp_strerror(-ret) << std::endl; @@ -4578,7 +4580,8 @@ int main(int argc, const char **argv) (is_read_only_set ? &read_only : NULL), endpoints, ptier_type, psync_from_all, sync_from, sync_from_rm, - predirect_zone); + predirect_zone, + store->svc.sync_modules->get_manager()); if (ret < 0) { cerr << "failed to update zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -6908,7 +6911,7 @@ next: } RGWSyncModuleInstanceRef sync_module; - int ret = store->get_sync_modules_manager()->create_instance(g_ceph_context, store->get_zone().tier_type, + int ret = store->svc.sync_modules->get_manager()->create_instance(g_ceph_context, store->get_zone().tier_type, store->get_zone_params().tier_config, &sync_module); if (ret < 0) { lderr(cct) << "ERROR: failed to init sync module instance, ret=" << ret << dendl; diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 13175032f3a..ad8aa1b8774 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -27,6 +27,7 @@ #include "cls/lock/cls_lock_client.h" #include "services/svc_zone.h" +#include "services/svc_sync_modules.h" #include "include/random.h" @@ -1759,7 +1760,7 @@ int RGWDataSyncStatusManager::init() return -EIO; } - if (!store->get_sync_modules_manager()->supports_data_export(zone_def->tier_type)) { + if (!store->svc.sync_modules->get_manager()->supports_data_export(zone_def->tier_type)) { return -ENOTSUP; } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index a367a9963ed..dfb5f9359c0 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -74,6 +74,7 @@ using namespace librados; #include "services/svc_zone.h" #include "services/svc_zone_utils.h" #include "services/svc_quota.h" +#include "services/svc_sync_modules.h" #include "services/svc_sys_obj.h" #include "services/svc_sys_obj_cache.h" @@ -1385,7 +1386,6 @@ void RGWRados::finalize() delete meta_mgr; delete binfo_cache; delete obj_tombstone_cache; - delete sync_modules_manager; if (reshard_wait.get()) { reshard_wait->stop(); @@ -1430,10 +1430,6 @@ int RGWRados::init_rados() } } - sync_modules_manager = new RGWSyncModulesManager(); - - rgw_register_sync_modules(sync_modules_manager); - auto crs = std::unique_ptr{ new RGWCoroutinesManagerRegistry(cct)}; ret = crs->hook_to_admin_command("cr dump"); @@ -1492,13 +1488,13 @@ int RGWRados::init_complete() if (run_sync_thread) { auto& zone_public_config = svc.zone->get_zone(); - ret = sync_modules_manager->create_instance(cct, zone_public_config.tier_type, svc.zone->get_zone_params().tier_config, &sync_module); + ret = svc.sync_modules->get_manager()->create_instance(cct, zone_public_config.tier_type, svc.zone->get_zone_params().tier_config, &sync_module); if (ret < 0) { lderr(cct) << "ERROR: failed to init sync module instance, ret=" << ret << dendl; if (ret == -ENOENT) { lderr(cct) << "ERROR: " << zone_public_config.tier_type << " sync module does not exist. valid sync modules: " - << sync_modules_manager->get_registered_module_names() + << svc.sync_modules->get_manager()->get_registered_module_names() << dendl; } return ret; @@ -1735,6 +1731,13 @@ int RGWRados::initialize() } svc.quota = _svc.quota.get(); + JSONFormattable sync_modules_svc_conf; + ret = svc_registry->get_instance("sync_modules", sync_modules_svc_conf, &_svc.sync_modules); + if (ret < 0) { + return ret; + } + svc.sync_modules = _svc.sync_modules.get(); + if (use_cache) { JSONFormattable cache_svc_conf; ret = svc_registry->get_instance("sys_obj_cache", cache_svc_conf, &_svc.cache); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 184addee780..afee1367a3d 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -49,6 +49,7 @@ class RGWReshardWait; class RGWSI_Zone; class RGWSI_ZoneUtils; class RGWSI_Quota; +class RGWSI_SyncModules; class RGWSI_SysObj; class RGWSI_SysObj_Cache; @@ -1297,7 +1298,6 @@ protected: RGWCoroutinesManagerRegistry *cr_registry; - RGWSyncModulesManager *sync_modules_manager{nullptr}; RGWSyncModuleInstanceRef sync_module; bool writeable_zone{false}; @@ -1342,6 +1342,7 @@ public: std::shared_ptr zone; std::shared_ptr zone_utils; std::shared_ptr quota; + std::shared_ptr sync_modules; std::shared_ptr sysobj; std::shared_ptr cache; } _svc; @@ -1351,6 +1352,7 @@ public: RGWSI_Zone *zone{nullptr}; RGWSI_ZoneUtils *zone_utils{nullptr}; RGWSI_Quota *quota{nullptr}; + RGWSI_SyncModules *sync_modules{nullptr}; RGWSI_SysObj *sysobj{nullptr}; RGWSI_SysObj_Cache *cache{nullptr}; } svc; @@ -1380,10 +1382,6 @@ public: tombstone_cache_t *get_tombstone_cache() { return obj_tombstone_cache; } - - RGWSyncModulesManager *get_sync_modules_manager() { - return sync_modules_manager; - } const RGWSyncModuleInstanceRef& get_sync_module() { return sync_module; } diff --git a/src/rgw/rgw_rest_realm.cc b/src/rgw/rgw_rest_realm.cc index 88eb0b2c563..293599a4174 100644 --- a/src/rgw/rgw_rest_realm.cc +++ b/src/rgw/rgw_rest_realm.cc @@ -122,7 +122,7 @@ void RGWOp_Period_Post::execute() // if period id is empty, handle as 'period commit' if (period.get_id().empty()) { - http_ret = period.commit(realm, current_period, error_stream); + http_ret = period.commit(store, realm, current_period, error_stream); if (http_ret < 0) { lderr(cct) << "master zone failed to commit period" << dendl; } diff --git a/src/rgw/rgw_service.cc b/src/rgw/rgw_service.cc index 09a4079a512..393aa453481 100644 --- a/src/rgw/rgw_service.cc +++ b/src/rgw/rgw_service.cc @@ -6,6 +6,7 @@ #include "services/svc_zone.h" #include "services/svc_zone_utils.h" #include "services/svc_quota.h" +#include "services/svc_sync_modules.h" #include "services/svc_sys_obj.h" #include "services/svc_sys_obj_cache.h" #include "services/svc_sys_obj_core.h" @@ -28,6 +29,7 @@ void RGWServiceRegistry::register_all(CephContext *cct) services["zone"] = make_shared(cct); services["zone_utils"] = make_shared(cct); services["quota"] = make_shared(cct); + services["sync_modules"] = make_shared(cct); services["sys_obj"] = make_shared(cct); services["sys_obj_cache"] = make_shared(cct); services["sys_obj_core"] = make_shared(cct); diff --git a/src/rgw/rgw_zone.cc b/src/rgw/rgw_zone.cc index 7a7061fef4d..ede30e037aa 100644 --- a/src/rgw/rgw_zone.cc +++ b/src/rgw/rgw_zone.cc @@ -3,6 +3,7 @@ #include "rgw_zone.h" #include "rgw_realm_watcher.h" #include "rgw_meta_sync_status.h" +#include "rgw_sync.h" #include "services/svc_zone.h" #include "services/svc_sys_obj.h" @@ -175,7 +176,7 @@ int RGWZoneGroup::equals(const string& other_zonegroup) const int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only, const list& endpoints, const string *ptier_type, bool *psync_from_all, list& sync_from, list& sync_from_rm, - string *predirect_zone) + string *predirect_zone, RGWSyncModulesManager *sync_mgr) { auto& zone_id = zone_params.get_id(); auto& zone_name = zone_params.get_name(); @@ -213,16 +214,13 @@ int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bo } if (ptier_type) { zone.tier_type = *ptier_type; -#warning FIXME -#if 0 - if (!store->get_sync_modules_manager()->get_module(*ptier_type, nullptr)) { + if (!sync_mgr->get_module(*ptier_type, nullptr)) { ldout(cct, 0) << "ERROR: could not found sync module: " << *ptier_type << ", valid sync modules: " - << store->get_sync_modules_manager()->get_registered_module_names() + << sync_mgr->get_registered_module_names() << dendl; return -ENOENT; } -#endif } if (psync_from_all) { @@ -831,19 +829,12 @@ string RGWRealm::get_control_oid() int RGWRealm::notify_zone(bufferlist& bl) { - // open a context on the realm's pool rgw_pool pool{get_pool(cct)}; - librados::IoCtx ctx; - int r = rgw_init_ioctx(store->get_rados_handle(), pool, ctx); - if (r < 0) { - ldout(cct, 0) << "Failed to open pool " << pool << dendl; - return r; - } - // send a notify on the realm object - r = ctx.notify2(get_control_oid(), bl, 0, nullptr); - if (r < 0) { - ldout(cct, 0) << "Realm notify failed with " << r << dendl; - return r; + auto obj_ctx = sysobj_svc->init_obj_ctx(); + auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj{pool, get_control_oid()}); + int ret = sysobj.wn().notify(bl, 0, nullptr); + if (ret < 0) { + return ret; } return 0; } @@ -1351,7 +1342,8 @@ static int read_sync_status(RGWRados *store, rgw_meta_sync_status *sync_status) return r; } -int RGWPeriod::update_sync_status(const RGWPeriod ¤t_period, +int RGWPeriod::update_sync_status(RGWRados *store, /* for now */ + const RGWPeriod ¤t_period, std::ostream& error_stream, bool force_if_stale) { @@ -1400,7 +1392,8 @@ int RGWPeriod::update_sync_status(const RGWPeriod ¤t_period, return 0; } -int RGWPeriod::commit(RGWRealm& realm, const RGWPeriod& current_period, +int RGWPeriod::commit(RGWRados *store, + RGWRealm& realm, const RGWPeriod& current_period, std::ostream& error_stream, bool force_if_stale) { auto zone_svc = sysobj_svc->get_zone_svc(); @@ -1432,7 +1425,7 @@ int RGWPeriod::commit(RGWRealm& realm, const RGWPeriod& current_period, // did the master zone change? if (master_zone != current_period.get_master_zone()) { // store the current metadata sync status in the period - int r = update_sync_status(current_period, error_stream, force_if_stale); + int r = update_sync_status(store, current_period, error_stream, force_if_stale); if (r < 0) { ldout(cct, 0) << "failed to update metadata sync status: " << cpp_strerror(-r) << dendl; @@ -1590,7 +1583,7 @@ int RGWZoneParams::fix_pool_names() } set pools; - r = get_zones_pool_set(cct, zone_svc, zones, id, pools); + r = get_zones_pool_set(cct, sysobj_svc, zones, id, pools); if (r < 0) { ldout(cct, 0) << "Error: get_zones_pool_names" << r << dendl; return r; diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index 7622e9befd2..81a79ae0165 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -27,6 +27,7 @@ extern std::string default_storage_pool_suffix; } class JSONObj; +class RGWSyncModulesManager; struct RGWNameToId { std::string obj_id; @@ -614,7 +615,7 @@ struct RGWZoneGroup : public RGWSystemMetaObj { int add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only, const list& endpoints, const std::string *ptier_type, bool *psync_from_all, list& sync_from, list& sync_from_rm, - std::string *predirect_zone); + std::string *predirect_zone, RGWSyncModulesManager *sync_mgr); int remove_zone(const std::string& zone_id); int rename_zone(const RGWZoneParams& zone_params); rgw_pool get_pool(CephContext *cct) override; @@ -839,7 +840,8 @@ class RGWPeriod const std::string get_period_oid_prefix(); // gather the metadata sync status for each shard; only for use on master zone - int update_sync_status(const RGWPeriod ¤t_period, + int update_sync_status(RGWRados *store, + const RGWPeriod ¤t_period, std::ostream& error_stream, bool force_if_stale); public: @@ -932,7 +934,8 @@ public: int update(); // commit a staging period; only for use on master zone - int commit(RGWRealm& realm, const RGWPeriod ¤t_period, + int commit(RGWRados *store, + RGWRealm& realm, const RGWPeriod ¤t_period, std::ostream& error_stream, bool force_if_stale = false); void encode(bufferlist& bl) const { diff --git a/src/rgw/services/svc_finisher.cc b/src/rgw/services/svc_finisher.cc index c2330fe54fc..dd1150deebe 100644 --- a/src/rgw/services/svc_finisher.cc +++ b/src/rgw/services/svc_finisher.cc @@ -1,9 +1,6 @@ #include "common/Finisher.h" #include "svc_finisher.h" -#include "svc_zone.h" - -#include "rgw/rgw_zone.h" int RGWS_Finisher::create_instance(const string& conf, RGWServiceInstanceRef *instance) { @@ -27,6 +24,10 @@ int RGWSI_Finisher::init() void RGWSI_Finisher::shutdown() { + if (finalized) { + return; + } + if (finisher) { finisher->stop(); @@ -37,6 +38,13 @@ void RGWSI_Finisher::shutdown() } delete finisher; } + + finalized = true; +} + +RGWSI_Finisher::~RGWSI_Finisher() +{ + shutdown(); } void RGWSI_Finisher::register_caller(ShutdownCB *cb, int *phandle) diff --git a/src/rgw/services/svc_finisher.h b/src/rgw/services/svc_finisher.h index aab7350fdcf..fbe4a7c52cb 100644 --- a/src/rgw/services/svc_finisher.h +++ b/src/rgw/services/svc_finisher.h @@ -22,9 +22,12 @@ public: private: Finisher *finisher{nullptr}; + bool finalized{false}; std::map get_deps() override; - int load(const std::string& conf, std::map& dep_refs) override; + int load(const std::string& conf, std::map& dep_refs) override { + return 0; + } int init() override; void shutdown() override; diff --git a/src/rgw/services/svc_notify.cc b/src/rgw/services/svc_notify.cc index e8ac830feab..03a73bae1dc 100644 --- a/src/rgw/services/svc_notify.cc +++ b/src/rgw/services/svc_notify.cc @@ -246,10 +246,6 @@ int RGWSI_Notify::init_watch() void RGWSI_Notify::finalize_watch() { - if (finalized) { - return; - } - for (int i = 0; i < num_watchers; i++) { RGWWatcher *watcher = watchers[i]; watcher->unregister_watch(); @@ -277,8 +273,21 @@ int RGWSI_Notify::init() void RGWSI_Notify::shutdown() { + if (finalized) { + return; + } + finisher_svc->unregister_caller(finisher_handle); finalize_watch(); + + delete shutdown_cb; + + finalized = true; +} + +RGWSI_Notify::~RGWSI_Notify() +{ + shutdown(); } int RGWSI_Notify::unwatch(RGWSI_RADOS::Obj& obj, uint64_t watch_handle) diff --git a/src/rgw/services/svc_sync_modules.cc b/src/rgw/services/svc_sync_modules.cc new file mode 100644 index 00000000000..e6239628e78 --- /dev/null +++ b/src/rgw/services/svc_sync_modules.cc @@ -0,0 +1,32 @@ +#include "svc_sync_modules.h" + +#include "rgw/rgw_sync_module.h" + +int RGWS_SyncModules::create_instance(const string& conf, RGWServiceInstanceRef *instance) +{ + instance->reset(new RGWSI_SyncModules(this, cct)); + return 0; +} + +std::map RGWSI_SyncModules::get_deps() +{ + return std::map(); +} + +int RGWSI_SyncModules::load(const string& conf, std::map& dep_refs) +{ + return 0; +} + +int RGWSI_SyncModules::init() +{ + sync_modules_manager = new RGWSyncModulesManager(); + rgw_register_sync_modules(sync_modules_manager); + return 0; +} + +RGWSI_SyncModules::~RGWSI_SyncModules() +{ + delete sync_modules_manager; +} + diff --git a/src/rgw/services/svc_sync_modules.h b/src/rgw/services/svc_sync_modules.h new file mode 100644 index 00000000000..6e578c8d7cf --- /dev/null +++ b/src/rgw/services/svc_sync_modules.h @@ -0,0 +1,36 @@ +#ifndef CEPH_RGW_SERVICES_SYNC_MODULES_H +#define CEPH_RGW_SERVICES_SYNC_MODULES_H + + +#include "rgw/rgw_service.h" + + +class RGWSyncModulesManager; + +class RGWS_SyncModules : public RGWService +{ +public: + RGWS_SyncModules(CephContext *cct) : RGWService(cct, "sync_modules") {} + + int create_instance(const std::string& conf, RGWServiceInstanceRef *instance) override; +}; + +class RGWSI_SyncModules : public RGWServiceInstance +{ + RGWSyncModulesManager *sync_modules_manager; + + std::map get_deps() override; + int load(const std::string& conf, std::map& dep_refs) override; + int init() override; + +public: + RGWSI_SyncModules(RGWService *svc, CephContext *cct): RGWServiceInstance(svc, cct) {} + ~RGWSI_SyncModules(); + + RGWSyncModulesManager *get_manager() { + return sync_modules_manager; + } +}; + +#endif + diff --git a/src/rgw/services/svc_sys_obj.cc b/src/rgw/services/svc_sys_obj.cc index 8b4aa6e0093..a553c6b282b 100644 --- a/src/rgw/services/svc_sys_obj.cc +++ b/src/rgw/services/svc_sys_obj.cc @@ -119,8 +119,7 @@ int RGWSI_SysObj::Pool::Op::list_prefixed_objs(const string& prefix, listpool(source.pool); + auto rados_pool = source.rados_svc->pool(source.pool); auto op = rados_pool.op(); @@ -191,6 +190,16 @@ int RGWSI_SysObj::Obj::OmapOp::del(const std::string& key) return svc->omap_del(obj, key); } +int RGWSI_SysObj::Obj::WNOp::notify(bufferlist& bl, + uint64_t timeout_ms, + bufferlist *pbl) +{ + RGWSI_SysObj_Core *svc = source.core_svc; + rgw_raw_obj& obj = source.obj; + + return svc->notify(obj, bl, timeout_ms, pbl); +} + RGWSI_Zone *RGWSI_SysObj::get_zone_svc() { return core_svc->get_zone_svc(); diff --git a/src/rgw/services/svc_sys_obj.h b/src/rgw/services/svc_sys_obj.h index f7429534905..13d4e34c37c 100644 --- a/src/rgw/services/svc_sys_obj.h +++ b/src/rgw/services/svc_sys_obj.h @@ -32,8 +32,6 @@ public: RGWSysObjectCtx& ctx; rgw_raw_obj obj; - RGWSI_RADOS *get_rados_svc(); - public: Obj(RGWSI_SysObj_Core *_core_svc, RGWSysObjectCtx& _ctx, @@ -157,6 +155,16 @@ public: int set(const map& m); int del(const std::string& key); }; + + struct WNOp { + Obj& source; + + WNOp(Obj& _source) : source(_source) {} + + int notify(bufferlist& bl, + uint64_t timeout_ms, + bufferlist *pbl); + }; ROp rop() { return ROp(*this); } @@ -168,19 +176,24 @@ public: OmapOp omap() { return OmapOp(*this); } + + WNOp wn() { + return WNOp(*this); + } }; class Pool { friend class Op; + RGWSI_RADOS *rados_svc; RGWSI_SysObj_Core *core_svc; rgw_pool pool; - RGWSI_RADOS *get_rados_svc(); - public: - Pool(RGWSI_SysObj_Core *_core_svc, - const rgw_pool& _pool) : core_svc(_core_svc), + Pool(RGWSI_RADOS *_rados_svc, + RGWSI_SysObj_Core *_core_svc, + const rgw_pool& _pool) : rados_svc(_rados_svc), + core_svc(_core_svc), pool(_pool) {} rgw_pool& get_pool() { @@ -220,7 +233,7 @@ public: Obj get_obj(RGWSysObjectCtx& obj_ctx, const rgw_raw_obj& obj); Pool get_pool(const rgw_pool& pool) { - return Pool(core_svc.get(), pool); + return Pool(rados_svc.get(), core_svc.get(), pool); } RGWSI_Zone *get_zone_svc(); diff --git a/src/rgw/services/svc_sys_obj_cache.cc b/src/rgw/services/svc_sys_obj_cache.cc index 1d9f326f156..ee044ed2beb 100644 --- a/src/rgw/services/svc_sys_obj_cache.cc +++ b/src/rgw/services/svc_sys_obj_cache.cc @@ -173,6 +173,36 @@ int RGWSI_SysObj_Cache::read(RGWSysObjectCtxBase& obj_ctx, return r; } +int RGWSI_SysObj_Cache::get_attr(rgw_raw_obj& obj, + const char *attr_name, + bufferlist *dest) +{ + rgw_pool pool; + string oid; + + normalize_pool_and_obj(obj.pool, obj.oid, pool, oid); + string name = normal_name(pool, oid); + + ObjectCacheInfo info; + + uint32_t flags = CACHE_FLAG_XATTRS; + + if (cache.get(name, info, flags, nullptr) == 0) { + if (info.status < 0) + return info.status; + + auto iter = info.xattrs.find(attr_name); + if (iter == info.xattrs.end()) { + return -ENODATA; + } + + *dest = iter->second; + return dest->length(); + } + /* don't try to cache this one */ + return RGWSI_SysObj_Core::get_attr(obj, attr_name, dest); +} + int RGWSI_SysObj_Cache::set_attrs(rgw_raw_obj& obj, map& attrs, map *rmattrs, diff --git a/src/rgw/services/svc_sys_obj_core.cc b/src/rgw/services/svc_sys_obj_core.cc index c75b72ccca0..f19b2cf7dd5 100644 --- a/src/rgw/services/svc_sys_obj_core.cc +++ b/src/rgw/services/svc_sys_obj_core.cc @@ -467,6 +467,22 @@ int RGWSI_SysObj_Core::omap_del(rgw_raw_obj& obj, const std::string& key) return r; } +int RGWSI_SysObj_Core::notify(rgw_raw_obj& obj, + bufferlist& bl, + uint64_t timeout_ms, + bufferlist *pbl) +{ + RGWSI_RADOS::Obj rados_obj; + int r = get_rados_obj(zone_svc.get(), obj, &rados_obj); + if (r < 0) { + ldout(cct, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; + return r; + } + + r = rados_obj.notify(bl, timeout_ms, pbl); + return r; +} + int RGWSI_SysObj_Core::remove(RGWSysObjectCtxBase& obj_ctx, RGWObjVersionTracker *objv_tracker, rgw_raw_obj& obj) diff --git a/src/rgw/services/svc_sys_obj_core.h b/src/rgw/services/svc_sys_obj_core.h index c330a865145..7165ae29ebc 100644 --- a/src/rgw/services/svc_sys_obj_core.h +++ b/src/rgw/services/svc_sys_obj_core.h @@ -180,6 +180,11 @@ protected: virtual int omap_set(rgw_raw_obj& obj, const map& m, bool must_exist = false); virtual int omap_del(rgw_raw_obj& obj, const std::string& key); + virtual int notify(rgw_raw_obj& obj, + bufferlist& bl, + uint64_t timeout_ms, + bufferlist *pbl); + /* wrappers */ int get_system_obj_state_impl(RGWSysObjectCtxBase *rctx, rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker); int get_system_obj_state(RGWSysObjectCtxBase *rctx, rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker); diff --git a/src/rgw/services/svc_zone.cc b/src/rgw/services/svc_zone.cc index 2c455acdd5d..4674181e68a 100644 --- a/src/rgw/services/svc_zone.cc +++ b/src/rgw/services/svc_zone.cc @@ -1,6 +1,7 @@ #include "svc_zone.h" #include "svc_rados.h" #include "svc_sys_obj.h" +#include "svc_sync_modules.h" #include "rgw/rgw_zone.h" #include "rgw/rgw_rest_conn.h" @@ -20,15 +21,13 @@ int RGWS_Zone::create_instance(const string& conf, RGWServiceInstanceRef *instan std::map RGWSI_Zone::get_deps() { - RGWServiceInstance::dependency dep1 = { .name = "sys_obj", - .conf = "{}" }; map deps; - deps["sys_obj_dep"] = dep1; - - RGWServiceInstance::dependency dep2 = { .name = "rados_obj", - .conf = "{}" }; - map deps2; - deps["rados_dep"] = dep2; + deps["sys_obj_dep"] = { .name = "sys_obj", + .conf = "{}" }; + deps["rados_dep"] = { .name = "rados_obj", + .conf = "{}" }; + deps["sync_modules_dep"] = { .name = "sync_modules", + .conf = "{}" }; return deps; } @@ -46,9 +45,18 @@ int RGWSI_Zone::load(const string& conf, std::map(dep_refs["rados_dep"]); assert(rados_svc); + sync_modules_svc = static_pointer_cast(dep_refs["sync_modules_dep"]); + assert(sync_modules_svc); + return 0; } +bool RGWSI_Zone::zone_syncs_from(RGWZone& target_zone, RGWZone& source_zone) +{ + return target_zone.syncs_from(source_zone.name) && + sync_modules_svc->get_manager()->supports_data_export(source_zone.tier_type); +} + int RGWSI_Zone::init() { int ret = realm->init(cct, sysobj_svc.get()); diff --git a/src/rgw/services/svc_zone.h b/src/rgw/services/svc_zone.h index 13da2cc4fd9..54c05df707b 100644 --- a/src/rgw/services/svc_zone.h +++ b/src/rgw/services/svc_zone.h @@ -8,6 +8,7 @@ class RGWSI_RADOS; class RGWSI_SysObj; +class RGWSI_SyncModules; class RGWRESTConn; @@ -23,6 +24,7 @@ class RGWSI_Zone : public RGWServiceInstance { std::shared_ptr sysobj_svc; std::shared_ptr rados_svc; + std::shared_ptr sync_modules_svc; std::shared_ptr realm; std::shared_ptr zonegroup; -- 2.39.5