]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix period init and activate
authorOrit Wasserman <owasserm@redhat.com>
Fri, 11 Sep 2015 09:23:28 +0000 (11:23 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:12:43 +0000 (16:12 -0800)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index e7f5ca1e831082a2c2eb96ff0699e7a1142e261b..191f169e454716fcbbf6807af0ae2d52b0b0cc50 100644 (file)
@@ -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;
     }
index b5b94be2036ce121989787230783c473f0459135..d43db17c872f2a35a5d4f9eee38e09637baab286 100644 (file)
@@ -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);