]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: be_select_auth_object() gives chksum objectstore priority if osd_distrust_data_d...
authorDavid Zafman <dzafman@redhat.com>
Fri, 20 Jul 2018 15:09:52 +0000 (08:09 -0700)
committerDavid Zafman <dzafman@redhat.com>
Thu, 26 Jul 2018 18:39:42 +0000 (11:39 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/osd/PGBackend.cc
src/osd/osd_types.h

index 26e08eae070101e8f6376d2d134830d567269e06..1465bdcd5382711d70486a2c15a462af8ae53c46 100644 (file)
@@ -742,9 +742,12 @@ bool PGBackend::be_compare_scrub_objects(
   return error == FOUND_ERROR;
 }
 
-static int dcount(const object_info_t &oi)
+static int dcount(const object_info_t &oi, bool prioritize)
 {
   int count = 0;
+  // Prioritize bluestore objects when osd_distrust_data_digest is set
+  if (prioritize)
+    count += 1000;
   if (oi.is_data_digest())
     count++;
   if (oi.is_omap_digest())
@@ -762,6 +765,7 @@ map<pg_shard_t, ScrubMap *>::const_iterator
   bool &digest_match)
 {
   eversion_t auth_version;
+  bool auth_prio = false;
   bufferlist first_oi_bl, first_ss_bl, first_hk_bl;
 
   // Create list of shards with primary first so it will be auth copy all
@@ -779,6 +783,7 @@ map<pg_shard_t, ScrubMap *>::const_iterator
   map<pg_shard_t, ScrubMap *>::const_iterator auth = maps.end();
   digest_match = true;
   for (auto &l : shards) {
+    bool oi_prio = false;
     map<pg_shard_t, ScrubMap *>::const_iterator j = maps.find(l);
     map<hobject_t, ScrubMap::object>::iterator i =
       j->second->objects.find(obj);
@@ -916,11 +921,21 @@ map<pg_shard_t, ScrubMap *>::const_iterator
     if (shard_info.errors)
       goto out;
 
+    // XXX: Do I want replicated only?
+    if (parent->get_pool().is_replicated() && cct->_conf->osd_distrust_data_digest) {
+      // This is a boost::optional<bool> so see if option set AND it has the value true
+      // We give priority to a replica where the ObjectStore like BlueStore has builtin checksum
+      if (j->second->has_builtin_csum && j->second->has_builtin_csum == true) {
+        oi_prio = true;
+      }
+    }
+
     if (auth_version == eversion_t() || oi.version > auth_version ||
-        (oi.version == auth_version && dcount(oi) > dcount(*auth_oi))) {
+        (oi.version == auth_version && dcount(oi, oi_prio) > dcount(*auth_oi, auth_prio))) {
       auth = j;
       *auth_oi = oi;
       auth_version = oi.version;
+      auth_prio = oi_prio;
     }
 
 out:
index ec268b118c6fcc1261a372648d511817ec89211a..ae94225bf648e9e0a7c1cd512b2b05f0cd81e42e 100644 (file)
@@ -4966,6 +4966,7 @@ struct ScrubMap {
   eversion_t valid_through;
   eversion_t incr_since;
   bool has_large_omap_object_errors:1;
+  boost::optional<bool> has_builtin_csum;
 
   void merge_incr(const ScrubMap &l);
   void clear_from(const hobject_t& start) {