]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add use_next_epoch method
authorOrit Wasserman <owasserm@redhat.com>
Fri, 18 Sep 2015 10:18:06 +0000 (12:18 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:00 +0000 (16:13 -0800)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 8fb3600d39459a475df4cd4c2873e7b2dc5062ed..46c597b3ae184668b3ec51aa46b2188ba8831515 100644 (file)
@@ -854,6 +854,28 @@ const string& RGWPeriod::get_pool_name(CephContext *cct)
   return cct->_conf->rgw_period_root_pool;
 }
 
+int RGWPeriod::use_next_epoch()
+{
+  epoch_t latest_epoch;
+  int ret = get_latest_epoch(latest_epoch);
+  if (ret < 0) {
+    return ret;
+  }
+  epoch = latest_epoch + 1;
+  ret = read_info();
+  if (ret < 0 && ret != -ENOENT) {
+    return ret;
+  }
+  if (ret == -ENOENT) {
+    ret = create();
+    if (ret < 0) {
+      derr << "Error creating new epoch " << epoch << dendl;
+      return ret;
+    }
+  }
+  return 0;
+}
+
 int RGWZoneParams::create_default(bool old_format)
 {
   name = default_zone_name;
index 0e0064254be85704f68761705a5d79e63cb5f2a5..3aa1e845116d38e3e24a64b06f89c1c7799a509b 100644 (file)
@@ -1315,11 +1315,13 @@ public:
   int get_latest_epoch(epoch_t& epoch);
   int init(const string &period_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 use_next_epoch();
+  
   int create();
   int delete_obj();
   int store_info(bool exclusive);
   int activate() { return -ENOTSUP;}
-  
+
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);    
     ::encode(id, bl);