From 575c0d1bec07abfbc714f17194a053bd9fed0ce5 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Sat, 15 Jun 2019 11:08:39 +0800 Subject: [PATCH] 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 --- src/mon/OSDMonitor.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 72b464ba6d4..279fe674bfc 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; } } -- 2.39.5