]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: period commit uses sync status markers
authorCasey Bodley <cbodley@redhat.com>
Mon, 20 Mar 2017 20:13:03 +0000 (16:13 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 6 Jun 2017 23:26:00 +0000 (19:26 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit bb49e2fbed3a87de837329cfa0c11f8d97633a94)

Conflicts:
src/rgw/rgw_rados.cc: RGWPeriod::update removed

src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_sync.h

index 1030bb52cf307f1aa049774bf28343ce7ab54d07..fc88d2f3bbf34a8630582760676fb62eb537908f 100644 (file)
@@ -1257,33 +1257,49 @@ void RGWPeriod::update(const RGWZoneGroupMap& map)
   period_map.master_zonegroup = map.master_zonegroup;
 }
 
-int RGWPeriod::update_sync_status()
+static int read_sync_status(RGWRados *store, rgw_meta_sync_status *sync_status)
 {
-  // must be new period's master zone to write sync status
-  if (master_zone != store->get_zone_params().get_id()) {
-    ldout(cct, 0) << "my zone " << store->get_zone_params().get_id()
-        << " is not period's master zone " << master_zone << dendl;
-    return -EINVAL;
+  // initialize a sync status manager to read the status
+  RGWMetaSyncStatusManager mgr(store, store->get_async_rados());
+  int r = mgr.init();
+  if (r < 0) {
+    return r;
   }
+  r = mgr.read_sync_status(sync_status);
+  mgr.stop();
+  return r;
+}
 
-  auto mdlog = store->meta_mgr->get_log(get_id());
-  const auto num_shards = cct->_conf->rgw_md_log_max_shards;
+int RGWPeriod::update_sync_status(const RGWPeriod &current_period)
+{
+  rgw_meta_sync_status status;
+  int r = read_sync_status(store, &status);
+  if (r < 0) {
+    ldout(cct, 0) << "period failed to read sync status: "
+        << cpp_strerror(-r) << dendl;
+    return r;
+  }
 
   std::vector<std::string> markers;
-  markers.reserve(num_shards);
 
-  // gather the markers for each shard
-  // TODO: use coroutines to read them in parallel
-  for (int i = 0; i < num_shards; i++) {
-    RGWMetadataLogInfo info;
-    int r = mdlog->get_info(i, &info);
-    if (r < 0) {
-      ldout(cct, 0) << "period failed to get metadata log info for shard " << i
-          << ": " << cpp_strerror(-r) << dendl;
-      return r;
+  const auto current_epoch = current_period.get_realm_epoch();
+  if (current_epoch != status.sync_info.realm_epoch) {
+    // no sync status markers for the current period
+    assert(current_epoch > status.sync_info.realm_epoch);
+    const int behind = current_epoch - status.sync_info.realm_epoch;
+    lderr(cct) << "ERROR: This zone is " << behind << " period(s) behind "
+          "the current master zone in metadata sync." << dendl;
+    return -EINVAL;
+  } else {
+    markers.reserve(status.sync_info.num_shards);
+    for (auto& i : status.sync_markers) {
+      auto& marker = i.second;
+      // filter out markers from other periods
+      if (marker.realm_epoch != current_epoch) {
+        marker.marker.clear();
+      }
+      markers.emplace_back(std::move(marker.marker));
     }
-    ldout(cct, 15) << "got shard " << i << " marker " << info.marker << dendl;
-    markers.emplace_back(std::move(info.marker));
   }
 
   std::swap(sync_status, markers);
@@ -1321,7 +1337,7 @@ int RGWPeriod::commit(RGWRealm& realm, const RGWPeriod& current_period,
   // did the master zone change?
   if (master_zone != current_period.get_master_zone()) {
     // store the current metadata sync status in the period
-    int r = update_sync_status();
+    int r = update_sync_status(current_period);
     if (r < 0) {
       ldout(cct, 0) << "failed to update metadata sync status: "
           << cpp_strerror(-r) << dendl;
index 6a63a03a63663e43c76d2fc4cb65a11b862169f2..1db50f3f1aae63c103291836e038af1ca97f64a8 100644 (file)
@@ -1444,7 +1444,7 @@ class RGWPeriod
   const string get_period_oid_prefix();
 
   // gather the metadata sync status for each shard; only for use on master zone
-  int update_sync_status();
+  int update_sync_status(const RGWPeriod &current_period);
 
 public:
   RGWPeriod() : epoch(0) {}
index 2d2e7b284ad2fad06415bf44ab8911bdc8e68a8b..442f2d9ebc5a641f5aa0d965e6789ccdcbe050dd 100644 (file)
@@ -255,7 +255,6 @@ public:
     : store(_store), master_log(store, async_rados, this),
       ts_to_shard_lock("ts_to_shard_lock") {}
   int init();
-  void finish();
 
   int read_sync_status(rgw_meta_sync_status *sync_status) {
     return master_log.read_sync_status(sync_status);