From: xie xingguo Date: Sat, 15 Jun 2019 03:08:39 +0000 (+0800) Subject: mon/OSDMonitor: fix off-by-one when updating new_last_in_change X-Git-Tag: v15.1.0~2421^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28568%2Fhead;p=ceph.git mon/OSDMonitor: fix off-by-one when updating new_last_in_change E.g., osdmap.osd_weight[osdmap.max_osd] does not exist. Signed-off-by: xie xingguo --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 72b464ba6d4e..279fe674bfcf 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -1166,14 +1166,16 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) pending_inc.new_last_up_change = pending_inc.modified; } for (auto& i : pending_inc.new_weight) { - if (i.first > osdmap.max_osd) { + if (i.first >= osdmap.max_osd) { if (i.second) { // new osd is already marked in pending_inc.new_last_in_change = pending_inc.modified; + break; } } else if (!!i.second != !!osdmap.osd_weight[i.first]) { // existing osd marked in or out pending_inc.new_last_in_change = pending_inc.modified; + break; } }