From: Yehuda Sadeh Date: Thu, 15 Oct 2015 23:37:37 +0000 (-0700) Subject: rgw: stuff more info into the period X-Git-Tag: v10.1.0~354^2~342 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=78f53f3f970b562a0ebbfca8757876a8d678629d;p=ceph.git rgw: stuff more info into the period and don't update the current period when adding zone, this will be done through the staging period. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index e34035a5fe81..9ee0c41bf695 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1367,6 +1367,7 @@ int main(int argc, char **argv) std::string master_url; int is_master = false; bool is_master_set = false; + int staging = false; int key_type = KEY_TYPE_UNDEFINED; rgw_bucket bucket; uint32_t perm_mask = 0; @@ -1509,6 +1510,8 @@ int main(int argc, char **argv) // do nothing } else if (ceph_argparse_binary_flag(args, i, &system, NULL, "--system", (char*)NULL)) { system_specified = true; + } else if (ceph_argparse_binary_flag(args, i, &staging, NULL, "--staging", (char*)NULL)) { + // do nothing } else if (ceph_argparse_witharg(args, i, &tmp, errs, "-a", "--auth-uid", (char*)NULL)) { if (!errs.str().empty()) { cerr << errs.str() << std::endl; @@ -1873,13 +1876,22 @@ int main(int argc, char **argv) if (!period_epoch.empty()) { epoch = atoi(period_epoch.c_str()); } + if (staging) { + RGWRealm realm(realm_id, realm_name); + int ret = realm.init(g_ceph_context, store); + if (ret < 0 ) { + cerr << "Error initializing realm " << cpp_strerror(-ret) << std::endl; + return ret; + } + period_id = RGWPeriod::get_staging_id(realm.get_id()); + epoch = 1; + } RGWPeriod period(period_id, epoch); int ret = period.init(g_ceph_context, store, realm_id, realm_name); if (ret < 0) { cerr << "period init failed: " << cpp_strerror(-ret) << std::endl; return -ret; } - encode_json("realm", period.get_realm(), formatter); encode_json("period", period, formatter); formatter->flush(cout); cout << std::endl; @@ -1983,8 +1995,12 @@ int main(int argc, char **argv) cerr << "Error initializing realm " << cpp_strerror(-ret) << std::endl; return ret; } - RGWPeriod period(realm.get_current_period(), 0); - ret = period.init(g_ceph_context, store, realm.get_id(), realm.get_name()); + epoch_t epoch = 0; + if (!period_epoch.empty()) { + epoch = atoi(period_epoch.c_str()); + } + RGWPeriod period(period_id, epoch); + ret = period.init(g_ceph_context, store); if (ret < 0) { cerr << "period init failed: " << cpp_strerror(-ret) << std::endl; return -ret; diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index 704a6dad2d9e..297690c48bcd 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -748,12 +748,16 @@ void RGWPeriodLatestEpochInfo::decode_json(JSONObj *obj) { void RGWPeriod::dump(Formatter *f) const { - encode_json("id", id , f); + encode_json("id", id, f); encode_json("epoch", epoch , f); encode_json("predecessor_uuid", predecessor_uuid, f); encode_json("sync_status", sync_status, f); encode_json("period_map", period_map, f); + encode_json("master_zonegroup", master_zonegroup, f); encode_json("master_zone", master_zone, f); + encode_json("period_config", period_config, f); + encode_json("realm_id", realm_id, f); + encode_json("realm_name", realm_name, f); } void RGWPeriod::decode_json(JSONObj *obj) @@ -763,7 +767,11 @@ void RGWPeriod::decode_json(JSONObj *obj) JSONDecoder::decode_json("predecessor_uuid", predecessor_uuid, obj); JSONDecoder::decode_json("sync_status", sync_status, obj); JSONDecoder::decode_json("period_map", period_map, obj); + JSONDecoder::decode_json("master_zonegroup", master_zonegroup, obj); JSONDecoder::decode_json("master_zone", master_zone, obj); + JSONDecoder::decode_json("period_config", period_config, obj); + JSONDecoder::decode_json("realm_id", realm_id, obj); + JSONDecoder::decode_json("realm_name", realm_name, obj); } void RGWZoneParams::dump(Formatter *f) const @@ -916,7 +924,6 @@ void RGWPeriodMap::dump(Formatter *f) const { encode_json("id", id, f); encode_json_map("zonegroups", zonegroups, f); - encode_json("master_zonegroup", master_zonegroup, f); } static void decode_zonegroups(map& zonegroups, JSONObj *o) @@ -934,13 +941,25 @@ void RGWPeriodMap::decode_json(JSONObj *obj) if (zonegroups.empty()) { JSONDecoder::decode_json("regions", zonegroups, obj); } - JSONDecoder::decode_json("master_zonegroup", master_zonegroup, obj); /* backward compatability with region */ if (master_zonegroup.empty()) { JSONDecoder::decode_json("master_region", master_zonegroup, obj); } } + +void RGWPeriodConfig::dump(Formatter *f) const +{ + encode_json("bucket_quota", bucket_quota, f); + encode_json("user_quota", user_quota, f); +} + +void RGWPeriodConfig::decode_json(JSONObj *obj) +{ + JSONDecoder::decode_json("bucket_quota", bucket_quota, obj); + JSONDecoder::decode_json("user_quota", user_quota, obj); +} + static void decode_realms(map& realms, JSONObj *o) { RGWRealm r; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index f7e5e0e56ba9..a5212c98c37a 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -979,7 +979,6 @@ int RGWPeriod::update() for (auto iter : zonegroups) { RGWZoneGroup zg(string(), iter); -cerr << __FILE__ << ":" << __LINE__ << " iter=" << iter << std::endl; ret = zg.init(cct, store); if (ret < 0) { ldout(cct, 0) << "WARNING: zg.init() failed: " << cpp_strerror(-ret) << dendl; @@ -1003,8 +1002,9 @@ cerr << __FILE__ << ":" << __LINE__ << " iter=" << iter << std::endl; void RGWPeriod::fork() { + predecessor_uuid = id; epoch = 1; - id = realm_id + ":staging"; + id = get_staging_id(realm_id); period_map.reset(); } @@ -1301,17 +1301,6 @@ int RGWZoneGroupMap::update(CephContext *cct, RGWRados *store, } } - RGWPeriod period(realm.get_current_period()); - ret = period.init(cct, store, realm.get_id()); - if (ret < 0) { - derr << " failed to init period:" << cpp_strerror(-ret) << dendl; - return ret; - } - ret = period.add_zonegroup(zonegroup); - if (ret < 0) { - derr << " failed to add zonegroup to period :" << cpp_strerror(-ret) << dendl; - return ret; - } return 0; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index cea6cece0315..432ab71a9b54 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1164,6 +1164,30 @@ struct RGWPeriodMap }; WRITE_CLASS_ENCODER(RGWPeriodMap) +struct RGWPeriodConfig +{ + RGWQuotaInfo bucket_quota; + RGWQuotaInfo user_quota; + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + ::encode(bucket_quota, bl); + ::encode(user_quota, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::iterator& bl) { + DECODE_START(1, bl); + ::decode(bucket_quota, bl); + ::decode(user_quota, bl); + DECODE_FINISH(bl); + } + + void dump(Formatter *f) const; + void decode_json(JSONObj *obj); +}; +WRITE_CLASS_ENCODER(RGWPeriodConfig) + struct RGWRegionMap { map regions; map regions_by_api; @@ -1340,6 +1364,8 @@ class RGWPeriod string predecessor_uuid; rgw_meta_sync_status sync_status; RGWPeriodMap period_map; + RGWPeriodConfig period_config; + string master_zonegroup; string master_zone; string realm_id; @@ -1369,6 +1395,7 @@ public: const string& get_master_zone() { return master_zone;} const string& get_realm() { return realm_id;} const RGWPeriodMap& get_map() { return period_map;} + const RGWPeriodConfig& get_config() { return period_config;} const rgw_meta_sync_status& get_sync_status() { return sync_status;} const string& get_pool_name(CephContext *cct); const string& get_latest_epoch_oid(); @@ -1409,6 +1436,10 @@ public: ::encode(sync_status, bl); ::encode(period_map, bl); ::encode(master_zone, bl); + ::encode(master_zonegroup, bl); + ::encode(period_config, bl); + ::encode(realm_id, bl); + ::encode(realm_name, bl); ENCODE_FINISH(bl); } @@ -1420,10 +1451,18 @@ public: ::decode(sync_status, bl); ::decode(period_map, bl); ::decode(master_zone, bl); + ::decode(master_zonegroup, bl); + ::decode(period_config, bl); + ::decode(realm_id, bl); + ::decode(realm_name, bl); DECODE_FINISH(bl); } void dump(Formatter *f) const; void decode_json(JSONObj *obj); + + static string get_staging_id(const string& realm_id) { + return realm_id + ":staging"; + } }; WRITE_CLASS_ENCODER(RGWPeriod)