]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: find_best_info - add completeness as the preferred option
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 14 Aug 2018 06:24:55 +0000 (14:24 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 31 Aug 2018 05:51:04 +0000 (13:51 +0800)
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 <xie.xingguo@zte.com.cn>
src/osd/PG.cc
src/osd/osd_types.h

index cc6845678dd1712423af66c8521c5f7abdbb3ffc..95c92f670f2549592622a45af0b6a8958f3f3ef6 100644 (file)
@@ -1208,6 +1208,22 @@ map<pg_shard_t, pg_info_t>::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
index 455ff56d359ca1e525189ce46a2775e1a4226570..1945272bef3b0be8466442a6a42e034bdb92578a 100644 (file)
@@ -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;