From 4df59f8735afe7585803da4130e7e93e9f4946d3 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Fri, 20 Jul 2018 08:09:52 -0700 Subject: [PATCH] osd: be_select_auth_object() gives chksum objectstore priority if osd_distrust_data_digest true Signed-off-by: David Zafman --- src/osd/PGBackend.cc | 19 +++++++++++++++++-- src/osd/osd_types.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/osd/PGBackend.cc b/src/osd/PGBackend.cc index 26e08eae07010..1465bdcd53827 100644 --- a/src/osd/PGBackend.cc +++ b/src/osd/PGBackend.cc @@ -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::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::const_iterator map::const_iterator auth = maps.end(); digest_match = true; for (auto &l : shards) { + bool oi_prio = false; map::const_iterator j = maps.find(l); map::iterator i = j->second->objects.find(obj); @@ -916,11 +921,21 @@ map::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 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: diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index ec268b118c6fc..ae94225bf648e 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -4966,6 +4966,7 @@ struct ScrubMap { eversion_t valid_through; eversion_t incr_since; bool has_large_omap_object_errors:1; + boost::optional has_builtin_csum; void merge_incr(const ScrubMap &l); void clear_from(const hobject_t& start) { -- 2.39.5