From: xie xingguo Date: Tue, 14 Aug 2018 06:24:55 +0000 (+0800) Subject: osd/PG: find_best_info - add completeness as the preferred option X-Git-Tag: v14.0.1~435^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4068e724ce9cc1463de0174c2ad266bec3454630;p=ceph.git osd/PG: find_best_info - add completeness as the preferred option Async recovery peers usually have a relative complete log history but may exist a lot of missing objects. Choosing them as auth_log_shard and further as primary if current up_primary is unrecoverable, say, could have a bigger chance to block client I/Os. Among peers with identical new log history, we now consider those who are now complete (having no missing objects) as the preferred ones when determining auth_log_shard. Signed-off-by: xie xingguo --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index cc6845678dd17..95c92f670f254 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1208,6 +1208,22 @@ map::const_iterator PG::find_best_info( continue; } + if (!p->second.has_missing() && best->second.has_missing()) { + dout(10) << __func__ << " prefer osd." << p->first + << " because it is complete while best has missing" + << dendl; + best = p; + continue; + } else if (p->second.has_missing() && !best->second.has_missing()) { + dout(10) << __func__ << " skipping osd." << p->first + << " because it has missing while best is complete" + << dendl; + continue; + } else { + // both are complete or have missing + // fall through + } + // prefer current primary (usually the caller), all things being equal if (p->first == pg_whoami) { dout(10) << "calc_acting prefer osd." << p->first diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 455ff56d359ca..1945272bef3b0 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2411,6 +2411,7 @@ struct pg_info_t { bool is_empty() const { return last_update.version == 0; } bool dne() const { return history.epoch_created == 0; } + bool has_missing() const { return last_complete != last_update; } bool is_incomplete() const { return !last_backfill.is_max(); } void encode(bufferlist& bl) const;