]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PeeringState.cc: don't let num_objects become negative 33331/head
authorNeha <nojha@redhat.com>
Sat, 14 Dec 2019 00:49:27 +0000 (00:49 +0000)
committerNathan Cutler <ncutler@suse.com>
Fri, 14 Feb 2020 14:21:37 +0000 (15:21 +0100)
If num_objects become negative, we may end up incorrectly setting
the PG_STATE_DEGRADED flag. Instead reset num_objects to zero and set
the PG_STATE_INCONSISTENT flag when this happens expecting scrub to fix
the inconsistency.

Fixes: https://tracker.ceph.com/issues/43308
Co-authored-by: David Zafman <dzafman@redhat.com>
Signed-off-by: Neha Ojha <nojha@redhat.com>
(cherry picked from commit 54c5eca48ce94dc4a1416836a06203db880c3842)

Conflicts:
src/osd/PeeringState.cc
- file is missing in nautilus; backported the code change manually
  to src/osd/PG.cc

src/osd/PG.cc

index 0e818d1651e7988ef8c993c0b416326c3a559c7e..d9d08bf7ef11a80df53514b8401770ae15dec97c 100644 (file)
@@ -2933,6 +2933,16 @@ void PG::_update_calc_stats()
   info.stats.stats.sum.num_objects_unfound = 0;
   info.stats.stats.sum.num_objects_misplaced = 0;
 
+  // We should never hit this condition, but if end up hitting it,
+  // make sure to update num_objects and set PG_STATE_INCONSISTENT.
+  if (info.stats.stats.sum.num_objects < 0) {
+    dout(0) << __func__ << " negative num_objects = "
+            << info.stats.stats.sum.num_objects << " setting it to 0 "
+            << dendl;
+    info.stats.stats.sum.num_objects = 0;
+    state_set(PG_STATE_INCONSISTENT);
+  }
+
   if ((is_remapped() || is_undersized() || !is_clean()) && (is_peered() || is_activating())) {
     dout(20) << __func__ << " actingset " << actingset << " upset "
              << upset << " acting_recovery_backfill " << acting_recovery_backfill << dendl;