]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: bucket sync: integrate bucket sync decisions
authorYehuda Sadeh <yehuda@redhat.com>
Sat, 16 Feb 2019 00:06:51 +0000 (16:06 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 28 Jan 2020 18:20:36 +0000 (10:20 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_rados.cc
src/rgw/services/svc_bi_rados.cc
src/rgw/services/svc_zone.cc
src/rgw/services/svc_zone.h

index e1f56d82d0412cf89cdeb0690a5d4175375b6ecb..834c9edaa577d41fc19f94c23f7cf08763e227b1 100644 (file)
@@ -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;
   }
index fd433b07bc189de5f48423255a57861036c6069d..b654edcf4832505db693e3e0bfd671bcdc1384a0 100644 (file)
@@ -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;
   }
 
index b880594285282e1196bc2b3166a8ce7374fc2d46..3927900dbe8e1f5b123be76d5b8a86a5ca7224d1 100644 (file)
@@ -29,6 +29,8 @@
 #include "rgw_crypt_sanitize.h"
 #include "rgw_bucket_sync.h"
 
+#include "services/svc_zone.h"
+
 #include <sstream>
 
 #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());
+}
index 0e69956fa498d4b73d6eaab1f6a4d7bdb498b176..8c943a1658c7c60908d7830a65b70eaf10c7dbb1 100644 (file)
@@ -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();
index 5032ac120d340524fe477965d3b679b50c594da4..67093096efde82fcc0587d9067a053d251e21750 100644 (file)
@@ -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;
index 956deeb26beffaea8d9a3a46304d632367e93a8d..7bd9ab8054f2ca8a9e4b9164181aa2b3681fa85e 100644 (file)
@@ -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);
index b80bd6df3f0a41c2e00ea2c25f465c99fc475d4a..7cccd99cb269da07aa00c1bbd3eddddb5d54a91b 100644 (file)
@@ -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();
 }
index c321e1d12a5ef86ddbcc085e4c58b99ff7118d63..19ebd4f19da0881bb8cf1d3afa0e5250badef9cc 100644 (file)
@@ -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();