From b9e51fc0ec55618e05a617c00444c24bb2924faf Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Fri, 11 Sep 2015 11:23:28 +0200 Subject: [PATCH] rgw: fix period init and activate Signed-off-by: Orit Wasserman --- src/rgw/rgw_rados.cc | 23 ++++++++++++++++------- src/rgw/rgw_rados.h | 10 +++++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index e7f5ca1e83108..191f169e45471 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -573,13 +573,13 @@ const string& RGWRealm::get_info_oid_prefix(bool old_format) int RGWRealm::set_current_period(const string& period_id) { /* check to see period id is valid */ - RGWPeriod new_current(cct, store, period_id); - int ret = new_current.init(); + RGWPeriod new_current(cct, store); + int ret = new_current.init(period_id); if (ret < 0) { derr << "Error init new period id " << period_id << " : " << cpp_strerror(-ret) << dendl; return ret; } - new_current.set_predecessor(id); + new_current.set_predecessor(current_period); ret = new_current.store_info(false); if (ret < 0) { return ret; @@ -602,7 +602,7 @@ int RGWPeriod::init(const string& period_id, epoch_t period_epoch, bool setup_o return 0; } - return init(); + return init(setup_obj); } int RGWPeriod::init(const string& period_realm_id, const string& period_realm_name, bool setup_obj) @@ -612,10 +612,19 @@ int RGWPeriod::init(const string& period_realm_id, const string& period_realm_na if (!setup_obj) return 0; - RGWRealm realm(realm_id, period_realm_name); + return init(setup_obj,period_realm_name); +} + + +int RGWPeriod::init(bool setup_obj,const string& realm_name) +{ + if (!setup_obj) + return 0; + + RGWRealm realm(realm_id, realm_name); int ret = realm.init(cct, store); if (ret < 0) { - derr << "failed to init realm " << period_realm_name << " id " << realm_id << " : " << cpp_strerror(-ret) << + derr << "failed to init realm " << realm_name << " id " << realm_id << " : " << cpp_strerror(-ret) << dendl; return ret; } @@ -632,7 +641,7 @@ int RGWPeriod::init(const string& period_realm_id, const string& period_realm_na if (!epoch) { ret = use_latest_epoch(); if (ret < 0) { - derr << "failed to use_latest_epoch " << period_realm_name << " id " << realm_id << " : " + derr << "failed to use_latest_epoch " << realm_name << " id " << realm_id << " : " << cpp_strerror(-ret) << dendl; return ret; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index b5b94be2036ce..d43db17c872f2 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1273,8 +1273,11 @@ class RGWPeriod const string get_period_oid_prefix(); public: + RGWPeriod(CephContext *_cct, RGWRados *_store) + : epoch(0), cct(_cct), store(_store) {} + RGWPeriod(CephContext *_cct, RGWRados *_store, - const string& period_id = "", epoch_t _epoch = 0) + const string& period_id, epoch_t _epoch = 0) : id(period_id), epoch(_epoch), cct(_cct), store(_store) {} RGWPeriod(CephContext *_cct, RGWRados *_store, @@ -1299,8 +1302,9 @@ public: predecessor_uuid = predecessor; } int get_latest_epoch(epoch_t& epoch); - int init(const string& realm_id = "", const string &realm_name = "", bool setup_obj = true); - int init(const string& period_id, epoch_t epoch, bool setup_obj = true); + int init(const string& realm_id, const string &realm_name, bool setup_obj = true); + int init(const string& period_id, epoch_t epoch = 0, bool setup_obj = true); + int init(bool setup_obj = true, const string& realm_name = ""); int create(); int delete_obj(); int store_info(bool exclusive); -- 2.39.5