From 9331abc54239d9114f7e8b091459cce66dc9b6de Mon Sep 17 00:00:00 2001 From: Neha Date: Sat, 14 Dec 2019 00:49:27 +0000 Subject: [PATCH] osd/PeeringState.cc: don't let num_objects become negative 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 Signed-off-by: Neha Ojha (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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index ecc8a3fd99bb..7390a65ecfe2 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3271,6 +3271,16 @@ void PG::_update_calc_stats() info.stats.avail_no_missing.clear(); info.stats.object_location_counts.clear(); + // 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; -- 2.47.3