]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/TrackedOp: fix 'warned' handling
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 27 Apr 2018 21:07:12 +0000 (23:07 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 27 Apr 2018 21:07:12 +0000 (23:07 +0200)
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 <danny.al-gaaf@bisect.de>
src/common/TrackedOp.cc
src/common/TrackedOp.h

index 12331ca50c659ec321455694f51d0b2d4f74e6a5..e937723b5f00db747d03ca5238345dc6c7c1b683 100644 (file)
@@ -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<void(TrackedOp&)>&& 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 > "
index 85cdc177f9f1ef7d78bc4ea8aa9abb2ee454e862..1a34507d1b536c0ee5980e699be80ba688869903 100644 (file)
@@ -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<void(TrackedOp&)>&& on_warn);
   /**
    * Look for Ops which are too old, and insert warning