From: Casey Bodley Date: Tue, 4 Dec 2018 21:38:10 +0000 (-0500) Subject: rgw: zone service only provides const access to its data X-Git-Tag: v14.1.0~618^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=924ae7ca9a6d3662be5d7b9773ceb74e2f79e722;p=ceph.git rgw: zone service only provides const access to its data Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 80ec4908bf43..205754ac486c 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2253,9 +2253,9 @@ static void tab_dump(const string& header, int width, const list& entrie static void sync_status(Formatter *formatter) { - RGWRealm& realm = store->svc.zone->get_realm(); - RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup(); - RGWZone& zone = store->svc.zone->get_zone(); + const RGWRealm& realm = store->svc.zone->get_realm(); + const RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup(); + const RGWZone& zone = store->svc.zone->get_zone(); int width = 15; @@ -2399,9 +2399,9 @@ static int bucket_sync_status(RGWRados *store, const RGWBucketInfo& info, const std::string& source_zone_id, std::ostream& out) { - RGWRealm& realm = store->svc.zone->get_realm(); - RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup(); - RGWZone& zone = store->svc.zone->get_zone(); + const RGWRealm& realm = store->svc.zone->get_realm(); + const RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup(); + const RGWZone& zone = store->svc.zone->get_zone(); constexpr int width = 15; out << indented{width, "realm"} << realm.get_id() << " (" << realm.get_name() << ")\n"; diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index d742daa73834..2f2e99202238 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -1471,7 +1471,7 @@ class RGWDataSyncShardControlCR : public RGWBackoffControlCR { RGWSyncTraceNodeRef tn; public: - RGWDataSyncShardControlCR(RGWDataSyncEnv *_sync_env, rgw_pool& _pool, + RGWDataSyncShardControlCR(RGWDataSyncEnv *_sync_env, const rgw_pool& _pool, uint32_t _shard_id, rgw_data_sync_marker& _marker, RGWSyncTraceNodeRef& _tn_parent) : RGWBackoffControlCR(_sync_env->cct, false), sync_env(_sync_env), @@ -1764,7 +1764,7 @@ int RGWDataSyncStatusManager::init() return -ENOTSUP; } - RGWZoneParams& zone_params = store->svc.zone->get_zone_params(); + const RGWZoneParams& zone_params = store->svc.zone->get_zone_params(); if (sync_module == nullptr) { sync_module = store->get_sync_module(); diff --git a/src/rgw/rgw_orphan.cc b/src/rgw/rgw_orphan.cc index 87e3e8e4f975..930bbb048958 100644 --- a/src/rgw/rgw_orphan.cc +++ b/src/rgw/rgw_orphan.cc @@ -145,7 +145,7 @@ int RGWOrphanStore::list_jobs(map & job_list) int RGWOrphanStore::init() { - rgw_pool& log_pool = store->svc.zone->get_zone_params().log_pool; + const rgw_pool& log_pool = store->svc.zone->get_zone_params().log_pool; int r = rgw_init_ioctx(store->get_rados_handle(), log_pool, ioctx); if (r < 0) { cerr << "ERROR: failed to open log pool (" << log_pool << " ret=" << r << std::endl; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 93ce2247ee43..eafc712d4964 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -403,7 +403,8 @@ RGWObjManifest::obj_iterator RGWObjManifest::obj_find(uint64_t ofs) return iter; } -int RGWObjManifest::append(RGWObjManifest& m, RGWZoneGroup& zonegroup, RGWZoneParams& zone_params) +int RGWObjManifest::append(RGWObjManifest& m, const RGWZoneGroup& zonegroup, + const RGWZoneParams& zone_params) { if (explicit_objs || m.explicit_objs) { return append_explicit(m, zonegroup, zone_params); @@ -2305,7 +2306,7 @@ int RGWRados::objexp_hint_trim(const string& oid, return 0; } -int RGWRados::lock_exclusive(rgw_pool& pool, const string& oid, timespan& duration, +int RGWRados::lock_exclusive(const rgw_pool& pool, const string& oid, timespan& duration, string& zone_id, string& owner_id) { librados::IoCtx io_ctx; @@ -2325,7 +2326,7 @@ int RGWRados::lock_exclusive(rgw_pool& pool, const string& oid, timespan& durati return l.lock_exclusive(&io_ctx, oid); } -int RGWRados::unlock(rgw_pool& pool, const string& oid, string& zone_id, string& owner_id) { +int RGWRados::unlock(const rgw_pool& pool, const string& oid, string& zone_id, string& owner_id) { librados::IoCtx io_ctx; int r = rgw_init_ioctx(get_rados_handle(), pool, io_ctx); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 5a9c142cfd05..89a5d120426a 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -576,7 +576,8 @@ public: void dump(Formatter *f) const; static void generate_test_instances(list& o); - int append(RGWObjManifest& m, RGWZoneGroup& zonegroup, RGWZoneParams& zone_params); + int append(RGWObjManifest& m, const RGWZoneGroup& zonegroup, + const RGWZoneParams& zone_params); int append(RGWObjManifest& m, RGWSI_Zone *zone_svc); bool get_rule(uint64_t ofs, RGWObjManifestRule *rule); @@ -2260,8 +2261,8 @@ public: const string& from_marker = std::string(), const string& to_marker = std::string()); - int lock_exclusive(rgw_pool& pool, const string& oid, ceph::timespan& duration, string& zone_id, string& owner_id); - int unlock(rgw_pool& pool, const string& oid, string& zone_id, string& owner_id); + int lock_exclusive(const rgw_pool& pool, const string& oid, ceph::timespan& duration, string& zone_id, string& owner_id); + int unlock(const rgw_pool& pool, const string& oid, string& zone_id, string& owner_id); void update_gc_chain(rgw_obj& head_obj, RGWObjManifest& manifest, cls_rgw_obj_chain *chain); int send_chain_to_gc(cls_rgw_obj_chain& chain, const string& tag, bool sync); diff --git a/src/rgw/rgw_realm_watcher.cc b/src/rgw/rgw_realm_watcher.cc index 8ea58571c3db..6ad38c6e40ac 100644 --- a/src/rgw/rgw_realm_watcher.cc +++ b/src/rgw/rgw_realm_watcher.cc @@ -13,7 +13,7 @@ #define dout_prefix (*_dout << "rgw realm watcher: ") -RGWRealmWatcher::RGWRealmWatcher(CephContext* cct, RGWRealm& realm) +RGWRealmWatcher::RGWRealmWatcher(CephContext* cct, const RGWRealm& realm) : cct(cct) { // no default realm, nothing to watch @@ -80,7 +80,7 @@ void RGWRealmWatcher::handle_error(uint64_t cookie, int err) } } -int RGWRealmWatcher::watch_start(RGWRealm& realm) +int RGWRealmWatcher::watch_start(const RGWRealm& realm) { // initialize a Rados client int r = rados.init_with_context(cct); diff --git a/src/rgw/rgw_realm_watcher.h b/src/rgw/rgw_realm_watcher.h index 1df4f04fc8e1..03d7e939b281 100644 --- a/src/rgw/rgw_realm_watcher.h +++ b/src/rgw/rgw_realm_watcher.h @@ -36,7 +36,7 @@ class RGWRealmWatcher : public librados::WatchCtx2 { bufferlist::const_iterator& p) = 0; }; - RGWRealmWatcher(CephContext* cct, RGWRealm& realm); + RGWRealmWatcher(CephContext* cct, const RGWRealm& realm); ~RGWRealmWatcher() override; /// register a watcher for the given notification type @@ -59,7 +59,7 @@ class RGWRealmWatcher : public librados::WatchCtx2 { uint64_t watch_handle = 0; std::string watch_oid; - int watch_start(RGWRealm& realm); + int watch_start(const RGWRealm& realm); int watch_restart(); void watch_stop(); diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 324d28d49998..4e87b1478784 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -170,7 +170,7 @@ string uppercase_underscore_http_attr(const string& orig) static set hostnames_set; static set hostnames_s3website_set; -void rgw_rest_init(CephContext *cct, RGWRados *store, RGWZoneGroup& zone_group) +void rgw_rest_init(CephContext *cct, RGWRados *store, const RGWZoneGroup& zone_group) { for (const auto& rgw2http : base_rgw_to_http_attrs) { rgw_to_http_attrs[rgw2http.rgw_attr] = rgw2http.http_attr; diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index defbed1d4b5a..e6493bc9d3c8 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -17,7 +17,7 @@ extern std::map rgw_to_http_attrs; -extern void rgw_rest_init(CephContext *cct, RGWRados *store, RGWZoneGroup& zone_group); +extern void rgw_rest_init(CephContext *cct, RGWRados *store, const RGWZoneGroup& zone_group); extern void rgw_flush_formatter_and_reset(struct req_state *s, ceph::Formatter *formatter); diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 40a1ebe7e23c..1fcbc801ec9b 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -1902,7 +1902,7 @@ void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter, } formatter.open_array_section("policies"); - RGWZoneGroup& zonegroup = store.svc.zone->get_zonegroup(); + const RGWZoneGroup& zonegroup = store.svc.zone->get_zonegroup(); for (const auto& placement_targets : zonegroup.placement_targets) { formatter.open_object_section("policy"); diff --git a/src/rgw/rgw_sync_module_aws.cc b/src/rgw/rgw_sync_module_aws.cc index a9c0d5d9ee32..a8c77191c02a 100644 --- a/src/rgw/rgw_sync_module_aws.cc +++ b/src/rgw/rgw_sync_module_aws.cc @@ -560,11 +560,11 @@ struct AWSSyncConfig { void expand_target(RGWDataSyncEnv *sync_env, const string& sid, const string& path, string *dest) { apply_meta_param(path, "sid", sid, dest); - RGWZoneGroup& zg = sync_env->store->svc.zone->get_zonegroup(); + const RGWZoneGroup& zg = sync_env->store->svc.zone->get_zonegroup(); apply_meta_param(path, "zonegroup", zg.get_name(), dest); apply_meta_param(path, "zonegroup_id", zg.get_id(), dest); - RGWZone& zone = sync_env->store->svc.zone->get_zone(); + const RGWZone& zone = sync_env->store->svc.zone->get_zone(); apply_meta_param(path, "zone", zone.name, dest); apply_meta_param(path, "zone_id", zone.id, dest); } diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index ddbf40beae21..818111a1cc15 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -134,7 +134,7 @@ struct ElasticConfig { num_replicas = config["num_replicas"](ES_NUM_REPLICAS_DEFAULT); } - void init_instance(RGWRealm& realm, uint64_t instance_id) { + void init_instance(const RGWRealm& realm, uint64_t instance_id) { sync_instance = instance_id; if (!override_index_path.empty()) { diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 95df6a48d5c1..9fd576e6f6b9 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -261,7 +261,7 @@ static RGWChainedCacheImpl uinfo_cache; int rgw_get_user_info_from_index(RGWRados * const store, const string& key, - rgw_pool& pool, + const rgw_pool& pool, RGWUserInfo& info, RGWObjVersionTracker * const objv_tracker, real_time * const pmtime) diff --git a/src/rgw/rgw_zone.cc b/src/rgw/rgw_zone.cc index 5366ebdb0fee..0038d60eb3c6 100644 --- a/src/rgw/rgw_zone.cc +++ b/src/rgw/rgw_zone.cc @@ -55,7 +55,7 @@ void RGWDefaultZoneGroupInfo::decode_json(JSONObj *obj) { } } -rgw_pool RGWZoneGroup::get_pool(CephContext *cct_) +rgw_pool RGWZoneGroup::get_pool(CephContext *cct_) const { if (cct_->_conf->rgw_zonegroup_root_pool.empty()) { return rgw_pool(RGW_DEFAULT_ZONEGROUP_ROOT_POOL); @@ -128,7 +128,7 @@ int RGWZoneGroup::create_default(bool old_format) return 0; } -const string RGWZoneGroup::get_default_oid(bool old_region_format) +const string RGWZoneGroup::get_default_oid(bool old_region_format) const { if (old_region_format) { if (cct->_conf->rgw_default_region_info_oid.empty()) { @@ -148,7 +148,7 @@ const string RGWZoneGroup::get_default_oid(bool old_region_format) return default_oid; } -const string& RGWZoneGroup::get_info_oid_prefix(bool old_region_format) +const string& RGWZoneGroup::get_info_oid_prefix(bool old_region_format) const { if (old_region_format) { return region_info_oid_prefix; @@ -156,12 +156,12 @@ const string& RGWZoneGroup::get_info_oid_prefix(bool old_region_format) return zone_group_info_oid_prefix; } -const string& RGWZoneGroup::get_names_oid_prefix() +const string& RGWZoneGroup::get_names_oid_prefix() const { return zonegroup_names_oid_prefix; } -const string& RGWZoneGroup::get_predefined_name(CephContext *cct) { +const string& RGWZoneGroup::get_predefined_name(CephContext *cct) const { return cct->_conf->rgw_zonegroup; } @@ -681,7 +681,7 @@ int RGWSystemMetaObj::write(bool exclusive) } -const string& RGWRealm::get_predefined_name(CephContext *cct) { +const string& RGWRealm::get_predefined_name(CephContext *cct) const { return cct->_conf->rgw_realm; } @@ -763,7 +763,7 @@ int RGWRealm::delete_control() return sysobj.wop().remove(); } -rgw_pool RGWRealm::get_pool(CephContext *cct) +rgw_pool RGWRealm::get_pool(CephContext *cct) const { if (cct->_conf->rgw_realm_root_pool.empty()) { return rgw_pool(RGW_DEFAULT_REALM_ROOT_POOL); @@ -771,7 +771,7 @@ rgw_pool RGWRealm::get_pool(CephContext *cct) return rgw_pool(cct->_conf->rgw_realm_root_pool); } -const string RGWRealm::get_default_oid(bool old_format) +const string RGWRealm::get_default_oid(bool old_format) const { if (cct->_conf->rgw_default_realm_info_oid.empty()) { return default_realm_info_oid; @@ -779,12 +779,12 @@ const string RGWRealm::get_default_oid(bool old_format) return cct->_conf->rgw_default_realm_info_oid; } -const string& RGWRealm::get_names_oid_prefix() +const string& RGWRealm::get_names_oid_prefix() const { return realm_names_oid_prefix; } -const string& RGWRealm::get_info_oid_prefix(bool old_format) +const string& RGWRealm::get_info_oid_prefix(bool old_format) const { return realm_info_oid_prefix; } @@ -822,7 +822,7 @@ int RGWRealm::set_current_period(RGWPeriod& period) return 0; } -string RGWRealm::get_control_oid() +string RGWRealm::get_control_oid() const { return get_info_oid_prefix() + id + ".control"; } @@ -954,7 +954,9 @@ int RGWPeriod::init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, bool setup_obj } -int RGWPeriod::get_zonegroup(RGWZoneGroup& zonegroup, const string& zonegroup_id) { +int RGWPeriod::get_zonegroup(RGWZoneGroup& zonegroup, + const string& zonegroup_id) const +{ map::const_iterator iter; if (!zonegroup_id.empty()) { iter = period_map.zonegroups.find(zonegroup_id); @@ -969,7 +971,7 @@ int RGWPeriod::get_zonegroup(RGWZoneGroup& zonegroup, const string& zonegroup_id return -ENOENT; } -const string& RGWPeriod::get_latest_epoch_oid() +const string& RGWPeriod::get_latest_epoch_oid() const { if (cct->_conf->rgw_period_latest_epoch_info_oid.empty()) { return period_latest_epoch_info_oid; @@ -977,17 +979,17 @@ const string& RGWPeriod::get_latest_epoch_oid() return cct->_conf->rgw_period_latest_epoch_info_oid; } -const string& RGWPeriod::get_info_oid_prefix() +const string& RGWPeriod::get_info_oid_prefix() const { return period_info_oid_prefix; } -const string RGWPeriod::get_period_oid_prefix() +const string RGWPeriod::get_period_oid_prefix() const { return get_info_oid_prefix() + id; } -const string RGWPeriod::get_period_oid() +const string RGWPeriod::get_period_oid() const { std::ostringstream oss; oss << get_period_oid_prefix(); @@ -1216,7 +1218,7 @@ int RGWPeriod::store_info(bool exclusive) .write(bl); } -rgw_pool RGWPeriod::get_pool(CephContext *cct) +rgw_pool RGWPeriod::get_pool(CephContext *cct) const { if (cct->_conf->rgw_period_root_pool.empty()) { return rgw_pool(RGW_DEFAULT_PERIOD_ROOT_POOL); @@ -1663,7 +1665,7 @@ int RGWZoneParams::create(bool exclusive) return 0; } -rgw_pool RGWZoneParams::get_pool(CephContext *cct) +rgw_pool RGWZoneParams::get_pool(CephContext *cct) const { if (cct->_conf->rgw_zone_root_pool.empty()) { return rgw_pool(RGW_DEFAULT_ZONE_ROOT_POOL); @@ -1672,7 +1674,7 @@ rgw_pool RGWZoneParams::get_pool(CephContext *cct) return rgw_pool(cct->_conf->rgw_zone_root_pool); } -const string RGWZoneParams::get_default_oid(bool old_format) +const string RGWZoneParams::get_default_oid(bool old_format) const { if (old_format) { return cct->_conf->rgw_default_zone_info_oid; @@ -1681,17 +1683,17 @@ const string RGWZoneParams::get_default_oid(bool old_format) return cct->_conf->rgw_default_zone_info_oid + "." + realm_id; } -const string& RGWZoneParams::get_names_oid_prefix() +const string& RGWZoneParams::get_names_oid_prefix() const { return zone_names_oid_prefix; } -const string& RGWZoneParams::get_info_oid_prefix(bool old_format) +const string& RGWZoneParams::get_info_oid_prefix(bool old_format) const { return zone_info_oid_prefix; } -const string& RGWZoneParams::get_predefined_name(CephContext *cct) { +const string& RGWZoneParams::get_predefined_name(CephContext *cct) const { return cct->_conf->rgw_zone; } diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index f982915382ce..6632349dbec6 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -137,11 +137,11 @@ public: int read(); int write(bool exclusive); - virtual rgw_pool get_pool(CephContext *cct) = 0; - virtual const std::string get_default_oid(bool old_format = false) = 0; - virtual const std::string& get_names_oid_prefix() = 0; - virtual const std::string& get_info_oid_prefix(bool old_format = false) = 0; - virtual const std::string& get_predefined_name(CephContext *cct) = 0; + virtual rgw_pool get_pool(CephContext *cct) const = 0; + virtual const std::string get_default_oid(bool old_format = false) const = 0; + virtual const std::string& get_names_oid_prefix() const = 0; + virtual const std::string& get_info_oid_prefix(bool old_format = false) const = 0; + virtual const std::string& get_predefined_name(CephContext *cct) const = 0; void dump(Formatter *f) const; void decode_json(JSONObj *obj); @@ -233,11 +233,11 @@ struct RGWZoneParams : RGWSystemMetaObj { RGWZoneParams(const std::string& id, const std::string& name, const std::string& _realm_id) : RGWSystemMetaObj(id, name), realm_id(_realm_id) {} - rgw_pool get_pool(CephContext *cct) override; - const std::string get_default_oid(bool old_format = false) override; - const std::string& get_names_oid_prefix() override; - const std::string& get_info_oid_prefix(bool old_format = false) override; - const std::string& get_predefined_name(CephContext *cct) override; + rgw_pool get_pool(CephContext *cct) const override; + const std::string get_default_oid(bool old_format = false) const override; + const std::string& get_names_oid_prefix() const override; + const std::string& get_info_oid_prefix(bool old_format = false) const override; + const std::string& get_predefined_name(CephContext *cct) const override; int init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, bool setup_obj = true, bool old_format = false); @@ -456,7 +456,7 @@ struct RGWZone { void decode_json(JSONObj *obj); static void generate_test_instances(list& o); - bool is_read_only() { return read_only; } + bool is_read_only() const { return read_only; } bool syncs_from(const std::string& zone_id) const { return (sync_from_all || sync_from.find(zone_id) != sync_from.end()); @@ -618,11 +618,11 @@ struct RGWZoneGroup : public RGWSystemMetaObj { 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; - const std::string get_default_oid(bool old_region_format = false) override; - const std::string& get_info_oid_prefix(bool old_region_format = false) override; - const std::string& get_names_oid_prefix() override; - const std::string& get_predefined_name(CephContext *cct) override; + rgw_pool get_pool(CephContext *cct) const override; + const std::string get_default_oid(bool old_region_format = false) const override; + const std::string& get_info_oid_prefix(bool old_region_format = false) const override; + const std::string& get_names_oid_prefix() const override; + const std::string& get_predefined_name(CephContext *cct) const override; void dump(Formatter *f) const; void decode_json(JSONObj *obj); @@ -763,11 +763,11 @@ public: int create(bool exclusive = true) override; int delete_obj(); - rgw_pool get_pool(CephContext *cct) override; - const std::string get_default_oid(bool old_format = false) override; - const std::string& get_names_oid_prefix() override; - const std::string& get_info_oid_prefix(bool old_format = false) override; - const std::string& get_predefined_name(CephContext *cct) override; + rgw_pool get_pool(CephContext *cct) const override; + const std::string get_default_oid(bool old_format = false) const override; + const std::string& get_names_oid_prefix() const override; + const std::string& get_info_oid_prefix(bool old_format = false) const override; + const std::string& get_predefined_name(CephContext *cct) const override; using RGWSystemMetaObj::read_id; // expose as public for radosgw-admin @@ -785,7 +785,7 @@ public: } epoch_t get_epoch() const { return epoch; } - std::string get_control_oid(); + std::string get_control_oid() const; /// send a notify on the realm control object int notify_zone(bufferlist& bl); /// notify the zone of a new period @@ -837,8 +837,8 @@ class RGWPeriod int use_latest_epoch(); int use_current_period(); - const std::string get_period_oid(); - const std::string get_period_oid_prefix(); + const std::string get_period_oid() const; + const std::string get_period_oid_prefix() const; // gather the metadata sync status for each shard; only for use on master zone int update_sync_status(RGWRados *store, @@ -862,9 +862,9 @@ public: RGWPeriodConfig& get_config() { return period_config; } const RGWPeriodConfig& get_config() const { return period_config; } const std::vector& get_sync_status() const { return sync_status; } - rgw_pool get_pool(CephContext *cct); - const std::string& get_latest_epoch_oid(); - const std::string& get_info_oid_prefix(); + rgw_pool get_pool(CephContext *cct) const; + const std::string& get_latest_epoch_oid() const; + const std::string& get_info_oid_prefix() const; void set_user_quota(RGWQuotaInfo& user_quota) { period_config.user_quota = user_quota; @@ -893,7 +893,7 @@ public: int reflect(); int get_zonegroup(RGWZoneGroup& zonegroup, - const std::string& zonegroup_id); + const std::string& zonegroup_id) const; bool is_single_zonegroup() const { @@ -903,7 +903,7 @@ public: /* returns true if there are several zone groups with a least one zone */ - bool is_multi_zonegroups_with_zones() + bool is_multi_zonegroups_with_zones() const { int count = 0; for (const auto& zg: period_map.zonegroups) { diff --git a/src/rgw/services/svc_zone.cc b/src/rgw/services/svc_zone.cc index 2dc123262dd8..eeaffc23a187 100644 --- a/src/rgw/services/svc_zone.cc +++ b/src/rgw/services/svc_zone.cc @@ -41,7 +41,7 @@ RGWSI_Zone::~RGWSI_Zone() delete current_period; } -bool RGWSI_Zone::zone_syncs_from(RGWZone& target_zone, RGWZone& source_zone) +bool RGWSI_Zone::zone_syncs_from(const RGWZone& target_zone, const RGWZone& source_zone) const { return target_zone.syncs_from(source_zone.name) && sync_modules_svc->get_manager()->supports_data_export(source_zone.tier_type); @@ -128,8 +128,8 @@ int RGWSI_Zone::do_start() lderr(cct) << "failed reading zone info: ret "<< ret << " " << cpp_strerror(-ret) << dendl; return ret; } - map::iterator zone_iter = get_zonegroup().zones.find(zone_params->get_id()); - if (zone_iter == get_zonegroup().zones.end()) { + auto zone_iter = zonegroup->zones.find(zone_params->get_id()); + if (zone_iter == zonegroup->zones.end()) { if (using_local) { lderr(cct) << "Cannot find zone id=" << zone_params->get_id() << " (name=" << zone_params->get_name() << ")" << dendl; return -EINVAL; @@ -139,9 +139,9 @@ int RGWSI_Zone::do_start() if (ret < 0) { return ret; } - zone_iter = get_zonegroup().zones.find(zone_params->get_id()); + zone_iter = zonegroup->zones.find(zone_params->get_id()); } - if (zone_iter != get_zonegroup().zones.end()) { + if (zone_iter != zonegroup->zones.end()) { *zone_public_config = zone_iter->second; ldout(cct, 20) << "zone " << zone_params->get_name() << dendl; } else { @@ -165,7 +165,7 @@ int RGWSI_Zone::do_start() ldout(cct, 0) << "WARNING: could not find zone config in zonegroup for local zone (" << zone_id() << "), will use defaults" << dendl; } *zone_public_config = zone_by_id[zone_id()]; - for (auto ziter : get_zonegroup().zones) { + for (auto ziter : zonegroup->zones) { const string& id = ziter.first; RGWZone& z = ziter.second; if (id == zone_id()) { @@ -769,38 +769,38 @@ int RGWSI_Zone::convert_regionmap() return 0; } -RGWZoneParams& RGWSI_Zone::get_zone_params() +const RGWZoneParams& RGWSI_Zone::get_zone_params() const { return *zone_params; } -RGWZone& RGWSI_Zone::get_zone() +const RGWZone& RGWSI_Zone::get_zone() const { return *zone_public_config; } -RGWZoneGroup& RGWSI_Zone::get_zonegroup() +const RGWZoneGroup& RGWSI_Zone::get_zonegroup() const { return *zonegroup; } -int RGWSI_Zone::get_zonegroup(const string& id, RGWZoneGroup& zonegroup) +int RGWSI_Zone::get_zonegroup(const string& id, RGWZoneGroup& zg) const { int ret = 0; - if (id == get_zonegroup().get_id()) { - zonegroup = get_zonegroup(); + if (id == zonegroup->get_id()) { + zg = *zonegroup; } else if (!current_period->get_id().empty()) { - ret = current_period->get_zonegroup(zonegroup, id); + ret = current_period->get_zonegroup(zg, id); } return ret; } -RGWRealm& RGWSI_Zone::get_realm() +const RGWRealm& RGWSI_Zone::get_realm() const { return *realm; } -RGWPeriod& RGWSI_Zone::get_current_period() +const RGWPeriod& RGWSI_Zone::get_current_period() const { return *current_period; } @@ -1010,8 +1010,8 @@ int RGWSI_Zone::select_bucket_location_by_rule(const string& location_rule, RGWZ * checking it for the local zone, because that's where this bucket object is going to * reside. */ - map::iterator piter = get_zone_params().placement_pools.find(location_rule); - if (piter == get_zone_params().placement_pools.end()) { + auto piter = zone_params->placement_pools.find(location_rule); + if (piter == zone_params->placement_pools.end()) { /* couldn't find, means we cannot really place data for this bucket in this zone */ ldout(cct, 0) << "ERROR: This zone does not contain placement rule " << location_rule << " present in the zonegroup!" << dendl; @@ -1030,7 +1030,7 @@ int RGWSI_Zone::select_bucket_location_by_rule(const string& location_rule, RGWZ int RGWSI_Zone::select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& placement_rule, string *pselected_rule_name, RGWZonePlacementInfo *rule_info) { - if (!get_zone_params().placement_pools.empty()) { + if (!zone_params->placement_pools.empty()) { return select_new_bucket_location(user_info, zonegroup_id, placement_rule, pselected_rule_name, rule_info); } @@ -1053,7 +1053,7 @@ int RGWSI_Zone::select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info) string pool_name; bool write_map = false; - rgw_raw_obj obj(get_zone_params().domain_root, avail_pools); + rgw_raw_obj obj(zone_params->domain_root, avail_pools); auto obj_ctx = sysobj_svc->init_obj_ctx(); auto sysobj = obj_ctx.get_obj(obj); diff --git a/src/rgw/services/svc_zone.h b/src/rgw/services/svc_zone.h index fd9ec109b91a..940cb78f85d3 100644 --- a/src/rgw/services/svc_zone.h +++ b/src/rgw/services/svc_zone.h @@ -59,12 +59,12 @@ public: RGWSI_Zone(CephContext *cct); ~RGWSI_Zone(); - RGWZoneParams& get_zone_params(); - RGWPeriod& get_current_period(); - RGWRealm& get_realm(); - RGWZoneGroup& get_zonegroup(); - int get_zonegroup(const string& id, RGWZoneGroup& zonegroup); - RGWZone& get_zone(); + const RGWZoneParams& get_zone_params() const; + const RGWPeriod& get_current_period() const; + const RGWRealm& get_realm() const; + const RGWZoneGroup& get_zonegroup() const; + int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) const; + const RGWZone& get_zone() const; const string& zone_name(); const string& zone_id(); @@ -74,7 +74,7 @@ public: bool has_zonegroup_api(const std::string& api) const; bool zone_is_writeable(); - bool zone_syncs_from(RGWZone& target_zone, RGWZone& source_zone); + bool zone_syncs_from(const RGWZone& target_zone, const RGWZone& source_zone) const; bool get_redirect_zone_endpoint(string *endpoint); RGWRESTConn *get_master_conn() {