From: xie xingguo Date: Mon, 16 May 2016 08:46:06 +0000 (+0800) Subject: osd/PG: count "num_want_acting" and fill "have" in single round X-Git-Tag: v11.0.0~409^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=10036d63f9c55bd6bc663f70cb9660b6f1567f12;p=ceph.git osd/PG: count "num_want_acting" and fill "have" in single round This is good for performance under most cases. Signed-off-by: xie xingguo --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index ac839c076865..34d21c7b7524 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1409,11 +1409,15 @@ bool PG::choose_acting(pg_shard_t &auth_log_shard_id, bool *history_les_bound) dout(10) << ss.str() << dendl; unsigned num_want_acting = 0; - for (vector::iterator i = want.begin(); - i != want.end(); - ++i) { - if (*i != CRUSH_ITEM_NONE) + set have; + for (int i = 0; i < (int)want.size(); ++i) { + if (want[i] != CRUSH_ITEM_NONE) { ++num_want_acting; + have.insert( + pg_shard_t( + want[i], + pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD)); + } } // We go incomplete if below min_size for ec_pools since backfill @@ -1430,14 +1434,6 @@ bool PG::choose_acting(pg_shard_t &auth_log_shard_id, bool *history_les_bound) /* Check whether we have enough acting shards to later perform recovery */ boost::scoped_ptr recoverable_predicate( get_pgbackend()->get_is_recoverable_predicate()); - set have; - for (int i = 0; i < (int)want.size(); ++i) { - if (want[i] != CRUSH_ITEM_NONE) - have.insert( - pg_shard_t( - want[i], - pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD)); - } if (!(*recoverable_predicate)(have)) { want_acting.clear(); dout(10) << "choose_acting failed, not recoverable" << dendl;