From a6acb1a017e2f960eb03feacc4b582fdc541eb69 Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Mon, 7 Sep 2015 10:27:01 +0200 Subject: [PATCH] rgw: add id to RGWZoneParams Signed-off-by: Orit Wasserman --- src/rgw/rgw_admin.cc | 5 +++-- src/rgw/rgw_rados.cc | 32 ++++++++++++++++---------------- src/rgw/rgw_rados.h | 20 ++++++++++++++------ 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 71d58e54f1a55..a32e9109e0df7 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1243,7 +1243,7 @@ int main(int argc, char **argv) std::string key_type_str; std::string period_id, url, parent_period; std::string realm_name, realm_id, realm_new_name; - std::string zone_name; + std::string zone_name, zone_id; std::string zonegroup_name, zonegroup_id, zonegroup_new_name; epoch_t period_epoch = 0; int key_type = KEY_TYPE_UNDEFINED; @@ -2166,7 +2166,8 @@ int main(int argc, char **argv) if (ret < 0) { cerr << "WARNING: failed to initialize zonegroup " << zonegroup_name << std::endl; } - RGWZoneParams zone(zone_name); + RGWZoneParams zone; + zone.id = zone_id; ret = zone.init(g_ceph_context, store, zonegroup); if (ret < 0) { cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index c4d9ca896c34f..25b594bf169a7 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -801,22 +801,22 @@ int RGWZoneParams::get_pool_name(CephContext *cct, string *pool_name) return 0; } -void RGWZoneParams::init_name(CephContext *cct, RGWZoneGroup& zonegroup) +void RGWZoneParams::init_id(CephContext *cct, RGWZoneGroup& zonegroup) { - name = cct->_conf->rgw_zone; + id = cct->_conf->rgw_zone; - if (name.empty()) { - name = zonegroup.master_zone; + if (id.empty()) { + id = zonegroup.master_zone; - if (name.empty()) { - name = default_zonegroup_name; + if (id.empty()) { + id = default_zone_name; } } } int RGWZoneParams::init(CephContext *cct, RGWRados *store, RGWZoneGroup& zonegroup) { - init_name(cct, zonegroup); + init_id(cct, zonegroup); string pool_name; int ret = get_pool_name(cct, &pool_name); @@ -828,7 +828,7 @@ int RGWZoneParams::init(CephContext *cct, RGWRados *store, RGWZoneGroup& zonegro rgw_bucket pool(pool_name.c_str()); bufferlist bl; - string oid = zone_info_oid_prefix + name; + string oid = zone_info_oid_prefix + id; RGWObjectCtx obj_ctx(store); ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, NULL, NULL); if (ret < 0) @@ -842,7 +842,7 @@ int RGWZoneParams::init(CephContext *cct, RGWRados *store, RGWZoneGroup& zonegro return -EIO; } - is_master = (name == zonegroup.master_zone) || (zonegroup.master_zone.empty() && name == default_zonegroup_name); + is_master = (id == zonegroup.master_zone) || (zonegroup.master_zone.empty() && id == default_zone_name); ldout(cct, 2) << "zone " << name << " is " << (is_master ? "" : "NOT ") << "master" << dendl; @@ -851,7 +851,7 @@ int RGWZoneParams::init(CephContext *cct, RGWRados *store, RGWZoneGroup& zonegro int RGWZoneParams::store_info(CephContext *cct, RGWRados *store, RGWZoneGroup& zonegroup) { - init_name(cct, zonegroup); + init_id(cct, zonegroup); string pool_name; int ret = get_pool_name(cct, &pool_name); @@ -859,7 +859,7 @@ int RGWZoneParams::store_info(CephContext *cct, RGWRados *store, RGWZoneGroup& z return ret; rgw_bucket pool(pool_name.c_str()); - string oid = zone_info_oid_prefix + name; + string oid = zone_info_oid_prefix + id; bufferlist bl; ::encode(*this, bl); @@ -2188,11 +2188,11 @@ int RGWRados::init_complete() map::iterator ziter; for (ziter = zonegroup.zones.begin(); ziter != zonegroup.zones.end(); ++ziter) { - const string& name = ziter->first; + const string& id = ziter->first; RGWZone& z = ziter->second; - if (name != zone.name) { + if (id != zone.id) { ldout(cct, 20) << "generating connection object for zone " << name << dendl; - zone_conn_map[name] = new RGWRESTConn(cct, this, z.endpoints); + zone_conn_map[id] = new RGWRESTConn(cct, this, z.endpoints); } else { zone_public_config = z; } @@ -3439,8 +3439,8 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, if (!pmaster_bucket) { uint64_t iid = instance_id(); uint64_t bid = next_bucket_id(); - char buf[zone.name.size() + 48]; - snprintf(buf, sizeof(buf), "%s.%llu.%llu", zone.name.c_str(), (long long)iid, (long long)bid); + char buf[zone.id.size() + 48]; + snprintf(buf, sizeof(buf), "%s.%llu.%llu", zone.id.c_str(), (long long)iid, (long long)bid); bucket.marker = buf; bucket.bucket_id = bucket.marker; } else { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 06a1c0e06437f..5a976e88d1b4f 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -845,6 +845,7 @@ struct RGWZoneParams { rgw_bucket user_swift_pool; rgw_bucket user_uid_pool; + string id; string name; bool is_master; @@ -853,16 +854,15 @@ struct RGWZoneParams { map placement_pools; RGWZoneParams() : is_master(false) {} - RGWZoneParams(const std::string& _name):name(_name) {} static int get_pool_name(CephContext *cct, string *pool_name); - void init_name(CephContext *cct, RGWZoneGroup& zonegroup); + void init_id(CephContext *cct, RGWZoneGroup& zonegroup); int init(CephContext *cct, RGWRados *store, RGWZoneGroup& zonegroup); void init_default(RGWRados *store); int store_info(CephContext *cct, RGWRados *store, RGWZoneGroup& zonegroup); void encode(bufferlist& bl) const { - ENCODE_START(5, 1, bl); + ENCODE_START(6, 1, bl); ::encode(domain_root, bl); ::encode(control_pool, bl); ::encode(gc_pool, bl); @@ -873,6 +873,7 @@ struct RGWZoneParams { ::encode(user_email_pool, bl); ::encode(user_swift_pool, bl); ::encode(user_uid_pool, bl); + ::encode(id, bl); ::encode(name, bl); ::encode(system_key, bl); ::encode(placement_pools, bl); @@ -881,7 +882,7 @@ struct RGWZoneParams { } void decode(bufferlist::iterator& bl) { - DECODE_START(5, bl); + DECODE_START(6, bl); ::decode(domain_root, bl); ::decode(control_pool, bl); ::decode(gc_pool, bl); @@ -892,8 +893,15 @@ struct RGWZoneParams { ::decode(user_email_pool, bl); ::decode(user_swift_pool, bl); ::decode(user_uid_pool, bl); - if (struct_v >= 2) + if (struct_v >= 6) { + ::decode(id, bl); + } + if (struct_v >= 2) { ::decode(name, bl); + if (struct_v < 6) { + id = name; + } + } if (struct_v >= 3) ::decode(system_key, bl); if (struct_v >= 4) @@ -2508,7 +2516,7 @@ public: string unique_id(uint64_t unique_num) { char buf[32]; snprintf(buf, sizeof(buf), ".%llu.%llu", (unsigned long long)instance_id(), (unsigned long long)unique_num); - string s = zone.name + buf; + string s = zone.id + buf; return s; } -- 2.39.5