From: Danny Al-Gaaf Date: Fri, 27 Apr 2018 21:07:12 +0000 (+0200) Subject: common/TrackedOp: fix 'warned' handling X-Git-Tag: v13.1.0~44^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f91ffea306ce46587ac4ef8e4f488dbc4d50e846;p=ceph.git common/TrackedOp: fix 'warned' handling Fix for this cppcheck issue: [src/common/TrackedOp.cc:385]: (style) The scope of the variable 'warned' can be reduced. Actually it seems that warned was not set correctly anymore after rewrite of the code. Set 'warned' in with_slow_ops_in_flight() as already done with number of slow iops. Signed-off-by: Danny Al-Gaaf --- diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc index 12331ca50c65..e937723b5f00 100644 --- a/src/common/TrackedOp.cc +++ b/src/common/TrackedOp.cc @@ -337,6 +337,7 @@ bool OpTracker::visit_ops_in_flight(utime_t* oldest_secs, bool OpTracker::with_slow_ops_in_flight(utime_t* oldest_secs, int* num_slow_ops, + int* num_warned_ops, std::function&& on_warn) { const utime_t now = ceph_clock_now(); @@ -368,6 +369,7 @@ bool OpTracker::with_slow_ops_in_flight(utime_t* oldest_secs, if (visit_ops_in_flight(oldest_secs, check)) { if (num_slow_ops) { *num_slow_ops = slow; + *num_warned_ops = warned; } return true; } else { @@ -396,7 +398,7 @@ bool OpTracker::check_ops_in_flight(std::string* summary, op.warn_interval_multiplier *= 2; }; int slow = 0; - if (with_slow_ops_in_flight(&oldest_secs, &slow, warn_on_slow_op)) { + if (with_slow_ops_in_flight(&oldest_secs, &slow, &warned, warn_on_slow_op)) { stringstream ss; ss << slow << " slow requests, " << warned << " included below; oldest blocked for > " diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 85cdc177f9f1..1a34507d1b53 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -152,12 +152,14 @@ public: * * @param[out] oldest_sec the amount of time since the oldest op was initiated * @param[out] num_slow_ops total number of slow ops + * @param[out] num_warned_ops total number of warned ops * @param on_warn a function consuming tracked ops, the function returns * false if it don't want to be fed with more ops * @return True if there are any Ops to warn on, false otherwise */ bool with_slow_ops_in_flight(utime_t* oldest_secs, int* num_slow_ops, + int* num_warned_ops, std::function&& on_warn); /** * Look for Ops which are too old, and insert warning