]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: remove the 2'nd option for determining 'low load' for scrubbing
authorRonen Friedman <rfriedma@redhat.com>
Sat, 17 May 2025 06:04:22 +0000 (01:04 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Mon, 19 May 2025 12:42:07 +0000 (07:42 -0500)
Previously, there were two conditions under which the CPU load was
considered
low enough to allow scrubbing:
- the CPU load was below the configured threshold, or
- the load was below a calculated "daily" average, and lower than the
  15-min average.
That second condition was confusing and surprising, and is now removed.

As the scrubber logic no longer requires the 5m & 15m load averages,
scrub_load_below_threshold() can use the data gathered by the
periodic LoadTracker::update_load_average().

Fixes: https://tracker.ceph.com/issues/71347
Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
(cherry picked from commit 4a0d5ea20acabb522c664b71d702f948098feaaf)

src/osd/scrubber/osd_scrub.cc
src/osd/scrubber/osd_scrub.h

index d119ad754deb9b5540e20ddca6d0accf31f18a9f..6ce087ad9546ffd4dea8b404d426d7393ca85918 100644 (file)
@@ -294,47 +294,32 @@ std::optional<double> OsdScrub::LoadTracker::update_load_average()
 
   double loadavg;
   if (getloadavg(&loadavg, 1) == 1) {
+    loadavg_1min = loadavg;
     daily_loadavg = (daily_loadavg * (n_samples - 1) + loadavg) / n_samples;
     return 100 * loadavg;
   }
 
-  return std::nullopt; // getloadavg() failed
+  // getloadavg() failed
+  loadavg_1min = 0;
+  return std::nullopt;
 }
 
 bool OsdScrub::LoadTracker::scrub_load_below_threshold() const
 {
-  double loadavgs[3];
-  if (getloadavg(loadavgs, 3) != 3) {
-    dout(10) << "couldn't read loadavgs" << dendl;
-    return false;
-  }
-
   // allow scrub if below configured threshold
-  long cpus = sysconf(_SC_NPROCESSORS_ONLN);
-  double loadavg_per_cpu = cpus > 0 ? loadavgs[0] / cpus : loadavgs[0];
+  const long cpus = sysconf(_SC_NPROCESSORS_ONLN);
+  const double loadavg_per_cpu = cpus > 0 ? loadavg_1min / cpus : loadavg_1min;
   if (loadavg_per_cpu < conf->osd_scrub_load_threshold) {
     dout(20) << fmt::format(
-                   "loadavg per cpu {:.3f} < max {:.3f} = yes",
-                   loadavg_per_cpu, conf->osd_scrub_load_threshold)
-            << dendl;
-    return true;
-  }
-
-  // allow scrub if below daily avg and currently decreasing
-  if (loadavgs[0] < daily_loadavg && loadavgs[0] < loadavgs[2]) {
-    dout(20) << fmt::format(
-                   "loadavg {:.3f} < daily_loadavg {:.3f} and < 15m avg "
-                   "{:.3f} = yes",
-                   loadavgs[0], daily_loadavg, loadavgs[2])
+                   "loadavg per cpu {:.3f} < max {:.3f}  (#CPUs: {}) = yes",
+                   loadavg_per_cpu, conf->osd_scrub_load_threshold, cpus)
             << dendl;
     return true;
   }
 
   dout(10) << fmt::format(
-                 "loadavg {:.3f} >= max {:.3f} and ( >= daily_loadavg {:.3f} "
-                 "or >= 15m avg {:.3f} ) = no",
-                 loadavgs[0], conf->osd_scrub_load_threshold, daily_loadavg,
-                 loadavgs[2])
+                 "loadavg {:.3f} >= max {:.3f} (#CPUs: {}) = no", loadavg_1min,
+                 conf->osd_scrub_load_threshold, cpus)
           << dendl;
   return false;
 }
index b06798c4bef200ec85a479c69949edfacf689353..a280679f16b02459ba22b088ebd1ba1c813775c5 100644 (file)
@@ -205,6 +205,7 @@ class OsdScrub {
     const ceph::common::ConfigProxy& conf;
     const std::string log_prefix;
     double daily_loadavg{0.0};
+    double loadavg_1min{0.0};
 
    public:
     explicit LoadTracker(