From 9536f74ac66137d368ed8bf21db2e5dd4c2282ba Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 8 Dec 2014 15:44:09 -0800 Subject: [PATCH] rgw: write multi shard markers on replica_log appropriately When getting a list of shard_id#marker, iterate through the shards and write each as needed. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_replica_log.cc | 37 +++++++++++++++++++++++++++++++++++++ src/rgw/rgw_replica_log.h | 5 +---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_replica_log.cc b/src/rgw/rgw_replica_log.cc index 04547176041..02c32d3554f 100644 --- a/src/rgw/rgw_replica_log.cc +++ b/src/rgw/rgw_replica_log.cc @@ -14,8 +14,10 @@ #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 *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& vals = sm.get(); + + ret = 0; + + map::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; +} diff --git a/src/rgw/rgw_replica_log.h b/src/rgw/rgw_replica_log.h index 8fec5f766af..a9adc9eedbe 100644 --- a/src/rgw/rgw_replica_log.h +++ b/src/rgw/rgw_replica_log.h @@ -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 *entries) { - return RGWReplicaLogger::update_bound(obj_name(bucket, shard_id), pool, - daemon_id, marker, time, entries); - } + const list *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);