]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: fix off-by-one when updating new_last_in_change 28568/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Sat, 15 Jun 2019 03:08:39 +0000 (11:08 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sat, 15 Jun 2019 03:14:43 +0000 (11:14 +0800)
E.g., osdmap.osd_weight[osdmap.max_osd] does not exist.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/mon/OSDMonitor.cc

index 72b464ba6d4e59e12d07254ad13009a59493e6b2..279fe674bfcf18c2d7d368fbd335fc0b4020a070 100644 (file)
@@ -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;
     }
   }