Skip to content

Commit 257e529

Browse files
committed
osd/scrub: remove the 2'nd option for determining 'low load' for scrubbing
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 <[email protected]> (cherry picked from commit 4a0d5ea)
1 parent f590506 commit 257e529

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

src/osd/scrubber/osd_scrub.cc

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -294,47 +294,32 @@ std::optional<double> OsdScrub::LoadTracker::update_load_average()
294294

295295
double loadavg;
296296
if (getloadavg(&loadavg, 1) == 1) {
297+
loadavg_1min = loadavg;
297298
daily_loadavg = (daily_loadavg * (n_samples - 1) + loadavg) / n_samples;
298299
return 100 * loadavg;
299300
}
300301

301-
return std::nullopt; // getloadavg() failed
302+
// getloadavg() failed
303+
loadavg_1min = 0;
304+
return std::nullopt;
302305
}
303306

304307
bool OsdScrub::LoadTracker::scrub_load_below_threshold() const
305308
{
306-
double loadavgs[3];
307-
if (getloadavg(loadavgs, 3) != 3) {
308-
dout(10) << "couldn't read loadavgs" << dendl;
309-
return false;
310-
}
311-
312309
// allow scrub if below configured threshold
313-
long cpus = sysconf(_SC_NPROCESSORS_ONLN);
314-
double loadavg_per_cpu = cpus > 0 ? loadavgs[0] / cpus : loadavgs[0];
310+
const long cpus = sysconf(_SC_NPROCESSORS_ONLN);
311+
const double loadavg_per_cpu = cpus > 0 ? loadavg_1min / cpus : loadavg_1min;
315312
if (loadavg_per_cpu < conf->osd_scrub_load_threshold) {
316313
dout(20) << fmt::format(
317-
"loadavg per cpu {:.3f} < max {:.3f} = yes",
318-
loadavg_per_cpu, conf->osd_scrub_load_threshold)
319-
<< dendl;
320-
return true;
321-
}
322-
323-
// allow scrub if below daily avg and currently decreasing
324-
if (loadavgs[0] < daily_loadavg && loadavgs[0] < loadavgs[2]) {
325-
dout(20) << fmt::format(
326-
"loadavg {:.3f} < daily_loadavg {:.3f} and < 15m avg "
327-
"{:.3f} = yes",
328-
loadavgs[0], daily_loadavg, loadavgs[2])
314+
"loadavg per cpu {:.3f} < max {:.3f} (#CPUs: {}) = yes",
315+
loadavg_per_cpu, conf->osd_scrub_load_threshold, cpus)
329316
<< dendl;
330317
return true;
331318
}
332319

333320
dout(10) << fmt::format(
334-
"loadavg {:.3f} >= max {:.3f} and ( >= daily_loadavg {:.3f} "
335-
"or >= 15m avg {:.3f} ) = no",
336-
loadavgs[0], conf->osd_scrub_load_threshold, daily_loadavg,
337-
loadavgs[2])
321+
"loadavg {:.3f} >= max {:.3f} (#CPUs: {}) = no", loadavg_1min,
322+
conf->osd_scrub_load_threshold, cpus)
338323
<< dendl;
339324
return false;
340325
}

src/osd/scrubber/osd_scrub.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ class OsdScrub {
205205
const ceph::common::ConfigProxy& conf;
206206
const std::string log_prefix;
207207
double daily_loadavg{0.0};
208+
double loadavg_1min{0.0};
208209

209210
public:
210211
explicit LoadTracker(

0 commit comments

Comments
 (0)