]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: write multi shard markers on replica_log appropriately
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 8 Dec 2014 23:44:09 +0000 (15:44 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 14 Jan 2015 03:21:27 +0000 (19:21 -0800)
When getting a list of shard_id#marker, iterate through the shards and
write each as needed.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_replica_log.cc
src/rgw/rgw_replica_log.h

index 04547176041c18183439994648ad7c046d0c34ae..02c32d3554f78e464a530a61855e499dbe6df946 100644 (file)
 
 #include "rgw_replica_log.h"
 #include "cls/replica_log/cls_replica_log_client.h"
+#include "cls/rgw/cls_rgw_client.h"
 #include "rgw_rados.h"
 
+#define dout_subsys ceph_subsys_rgw
 
 void RGWReplicaBounds::dump(Formatter *f) const
 {
@@ -144,3 +146,38 @@ string RGWReplicaBucketLogger::obj_name(const rgw_bucket& bucket, int shard_id)
   }
   return s;
 }
+
+int RGWReplicaBucketLogger::update_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id,
+                   const string& marker, const utime_t& time,
+                   const list<RGWReplicaItemMarker> *entries)
+{
+  if (shard_id >= 0 ||
+      !BucketIndexShardsManager::is_shards_marker(marker)) {
+    return RGWReplicaLogger::update_bound(obj_name(bucket, shard_id), pool,
+                                          daemon_id, marker, time, entries);
+  }
+
+  BucketIndexShardsManager sm;
+  int ret = sm.from_string(marker, true);
+  if (ret < 0) {
+    ldout(cct, 0) << "ERROR: could not parse shards marker: " << marker << dendl;
+    return ret;
+  }
+
+  map<int, string>& vals = sm.get();
+
+  ret = 0;
+
+  map<int, string>::iterator iter;
+  for (iter = vals.begin(); iter != vals.end(); ++iter) {
+    ldout(cct, 20) << "updating bound: bucket=" << bucket << " shard=" << iter->first << " marker=" << marker << dendl;
+    int r = RGWReplicaLogger::update_bound(obj_name(bucket, iter->first), pool,
+                                          daemon_id, iter->second, time, entries);
+    if (r < 0) {
+      ldout(cct, 0) << "failed to update bound: bucket=" << bucket << " shard=" << iter->first << " marker=" << marker << dendl;
+      ret = r;
+    }
+  }
+
+  return ret;
+}
index 8fec5f766af1bcba2b82d50e50c2afa2b8b615b5..a9adc9eedbe6ff1ee89ccba9c27df522ed47cdd7 100644 (file)
@@ -103,10 +103,7 @@ public:
   RGWReplicaBucketLogger(RGWRados *_store);
   int update_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id,
                    const string& marker, const utime_t& time,
-                   const list<RGWReplicaItemMarker> *entries) {
-    return RGWReplicaLogger::update_bound(obj_name(bucket, shard_id), pool,
-                                          daemon_id, marker, time, entries);
-  }
+                   const list<RGWReplicaItemMarker> *entries);
   int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id) {
     return RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id), pool,
                                           daemon_id);