From: Yehuda Sadeh Date: Sat, 16 Feb 2019 00:06:51 +0000 (-0800) Subject: rgw: bucket sync: integrate bucket sync decisions X-Git-Tag: v15.1.0~22^2~123 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=79802837cf6090950f70d52fbc9eed2dcffc2e38;p=ceph-ci.git rgw: bucket sync: integrate bucket sync decisions Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index e1f56d82d04..834c9edaa57 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2285,7 +2285,7 @@ static int bucket_sync_status(rgw::sal::RGWRadosStore *store, const RGWBucketInf out << indented{width, "zone"} << zone.id << " (" << zone.name << ")\n"; out << indented{width, "bucket"} << info.bucket << "\n\n"; - if (!info.datasync_flag_enabled()) { + if (!info.bucket_datasync_enabled()) { out << "Sync is disabled for bucket " << info.bucket.name << '\n'; return 0; } diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index fd433b07bc1..b654edcf483 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -2180,8 +2180,7 @@ int RGWDataChangesLog::get_log_shard_id(rgw_bucket& bucket, int shard_id) { } int RGWDataChangesLog::add_entry(const RGWBucketInfo& bucket_info, int shard_id) { - if (!svc.zone->need_to_log_data() && - (!bucket_info.sync_policy || !bucket_info.sync_policy->zone_is_source(svc.zone->zone_id()))) { + if (!bucket_info.bucket_datasync_enabled(svc.zone)) { return 0; } diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index b8805942852..3927900dbe8 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -29,6 +29,8 @@ #include "rgw_crypt_sanitize.h" #include "rgw_bucket_sync.h" +#include "services/svc_zone.h" + #include #define dout_context g_ceph_context @@ -2084,3 +2086,19 @@ bool RGWBucketInfo::empty_sync_policy() const return sync_policy->empty(); } + +bool RGWBucketInfo::bucket_is_sync_source(const string& zone_id) const +{ + return (sync_policy && + sync_policy->zone_is_source(zone_id)); +} + +bool RGWBucketInfo::bucket_datasync_enabled(const RGWSI_Zone *zone_svc) const +{ + if (bucket_is_sync_source(zone_svc->zone_id())) { + return true; + } + + return (zone_svc->need_to_log_data() && + datasync_flag_enabled()); +} diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 0e69956fa49..8c943a1658c 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1309,6 +1309,14 @@ struct rgw_bucket_shard { } }; +inline ostream& operator<<(ostream& out, const rgw_bucket_shard& bs) { + if (bs.shard_id <= 0) { + return out << bs.bucket; + } + + return out << bs.bucket << ":" << bs.shard_id; +} + struct rgw_bucket_placement { rgw_placement_rule placement_rule; rgw_bucket bucket; @@ -1393,6 +1401,7 @@ inline ostream& operator<<(ostream& out, const RGWBucketIndexType &index_type) } struct RGWBucketSyncPolicy; +class RGWSI_Zone; struct RGWBucketInfo { enum BIShardsHashType { @@ -1467,6 +1476,8 @@ struct RGWBucketInfo { void set_sync_policy(RGWBucketSyncPolicy&& policy); bool empty_sync_policy() const; + bool bucket_is_sync_source(const string& zone_id) const; + bool bucket_datasync_enabled(const RGWSI_Zone *zone_svc) const; RGWBucketInfo(); ~RGWBucketInfo(); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 5032ac120d3..67093096efd 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4829,12 +4829,10 @@ int RGWRados::Object::Delete::delete_obj(optional_yield y) return r; } - if (target->bucket_info.datasync_flag_enabled()) { - r = store->data_log->add_entry(target->bucket_info, bs->shard_id); - if (r < 0) { - lderr(store->ctx()) << "ERROR: failed writing data log" << dendl; - return r; - } + r = store->svc.datalog_rados->add_entry(target->bucket_info, bs->shard_id); + if (r < 0) { + lderr(store->ctx()) << "ERROR: failed writing data log" << dendl; + return r; } return 0; @@ -5901,11 +5899,9 @@ int RGWRados::Bucket::UpdateIndex::complete(int64_t poolid, uint64_t epoch, ret = store->cls_obj_complete_add(*bs, obj, optag, poolid, epoch, ent, category, remove_objs, bilog_flags, zones_trace); - if (target->bucket_info.datasync_flag_enabled()) { - int r = store->data_log->add_entry(target->bucket_info, bs->shard_id); - if (r < 0) { - lderr(store->ctx()) << "ERROR: failed writing data log" << dendl; - } + int r = store->svc.datalog_rados->add_entry(target->bucket_info, bs->shard_id); + if (r < 0) { + lderr(store->ctx()) << "ERROR: failed writing data log" << dendl; } return ret; @@ -5929,11 +5925,9 @@ int RGWRados::Bucket::UpdateIndex::complete_del(int64_t poolid, uint64_t epoch, ret = store->cls_obj_complete_del(*bs, optag, poolid, epoch, obj, removed_mtime, remove_objs, bilog_flags, zones_trace); - if (target->bucket_info.datasync_flag_enabled()) { - int r = store->data_log->add_entry(target->bucket_info, bs->shard_id); - if (r < 0) { - lderr(store->ctx()) << "ERROR: failed writing data log" << dendl; - } + int r = store->svc.datalog_rados->add_entry(target->bucket_info, bs->shard_id); + if (r < 0) { + lderr(store->ctx()) << "ERROR: failed writing data log" << dendl; } return ret; @@ -5957,11 +5951,9 @@ int RGWRados::Bucket::UpdateIndex::cancel() * for following the specific bucket shard log. Otherwise they end up staying behind, and users * have no way to tell that they're all caught up */ - if (target->bucket_info.datasync_flag_enabled()) { - int r = store->data_log->add_entry(target->bucket_info, bs->shard_id); - if (r < 0) { - lderr(store->ctx()) << "ERROR: failed writing data log" << dendl; - } + int r = store->svc.datalog_rados->add_entry(target->bucket_info, bs->shard_id); + if (r < 0) { + lderr(store->ctx()) << "ERROR: failed writing data log" << dendl; } return ret; @@ -6601,8 +6593,9 @@ int RGWRados::bucket_index_link_olh(const RGWBucketInfo& bucket_info, RGWObjStat return r; } - if (log_data_change && bucket_info.datasync_flag_enabled()) { - data_log->add_entry(bucket_info, bs.shard_id); + r = svc.datalog_rados->add_entry(bucket_info, bs.shard_id); + if (r < 0) { + ldout(cct, 0) << "ERROR: failed writing data log" << dendl; } return 0; diff --git a/src/rgw/services/svc_bi_rados.cc b/src/rgw/services/svc_bi_rados.cc index 956deeb26be..7bd9ab8054f 100644 --- a/src/rgw/services/svc_bi_rados.cc +++ b/src/rgw/services/svc_bi_rados.cc @@ -411,12 +411,15 @@ int RGWSI_BucketIndex_RADOS::get_reshard_status(const RGWBucketInfo& bucket_info int RGWSI_BucketIndex_RADOS::handle_overwrite(const RGWBucketInfo& info, const RGWBucketInfo& orig_info) { - if (orig_info.datasync_flag_enabled() != info.datasync_flag_enabled()) { + bool new_sync_enabled = info.bucket_datasync_enabled(svc.zone); + bool old_sync_enabled = orig_info.bucket_datasync_enabled(svc.zone); + + if (old_sync_enabled != new_sync_enabled) { int shards_num = info.num_shards? info.num_shards : 1; int shard_id = info.num_shards? 0 : -1; int ret; - if (!info.datasync_flag_enabled()) { + if (!new_sync_enabled) { ret = svc.bilog->log_stop(info, -1); } else { ret = svc.bilog->log_start(info, -1); diff --git a/src/rgw/services/svc_zone.cc b/src/rgw/services/svc_zone.cc index b80bd6df3f0..7cccd99cb26 100644 --- a/src/rgw/services/svc_zone.cc +++ b/src/rgw/services/svc_zone.cc @@ -819,7 +819,7 @@ const RGWPeriod& RGWSI_Zone::get_current_period() const return *current_period; } -const string& RGWSI_Zone::get_current_period_id() +const string& RGWSI_Zone::get_current_period_id() const { return current_period->get_id(); } @@ -851,11 +851,11 @@ uint32_t RGWSI_Zone::get_zone_short_id() const return zone_short_id; } -const string& RGWSI_Zone::zone_name() +const string& RGWSI_Zone::zone_name() const { return get_zone_params().get_name(); } -const string& RGWSI_Zone::zone_id() +const string& RGWSI_Zone::zone_id() const { return get_zone_params().get_id(); } diff --git a/src/rgw/services/svc_zone.h b/src/rgw/services/svc_zone.h index c321e1d12a5..19ebd4f19da 100644 --- a/src/rgw/services/svc_zone.h +++ b/src/rgw/services/svc_zone.h @@ -67,11 +67,11 @@ public: int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) const; const RGWZone& get_zone() const; - const string& zone_name(); - const string& zone_id(); + const string& zone_name() const; + const string& zone_id() const; uint32_t get_zone_short_id() const; - const string& get_current_period_id(); + const string& get_current_period_id() const; bool has_zonegroup_api(const std::string& api) const; bool zone_is_writeable();