From 84f74e5ccecbea4dafd2f4f388bcbca6fc5b7533 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 25 Oct 2017 14:29:18 +0800 Subject: [PATCH] OSD/PG: fix calc of misplaced objects Signed-off-by: Kefu Chai --- src/osd/PG.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 988114056bb..01c2dc8286b 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2637,11 +2637,12 @@ void PG::_update_calc_stats() // Add recovery objects not part of actingbackfill to be used to reduce // degraded and account as misplaced. - for (auto i = peer_info.begin() ; i != peer_info.end() ; ++i) { - if (actingbackfill.find(i->first) == actingbackfill.end()) - object_copies += i->second.stats.stats.sum.num_objects; - misplaced += i->second.stats.stats.sum.num_objects; + for (const auto& peer : peer_info) { + if (actingbackfill.find(peer.first) == actingbackfill.end()) { + object_copies += peer.second.stats.stats.sum.num_objects; + misplaced += peer.second.stats.stats.sum.num_objects; ++num_misplaced; + } } if (object_copies) dout(20) << __func__ << " objects not part of up/acting " << object_copies << dendl; -- 2.39.5