Skip to content

Commit 6d3146b

Browse files
authored
Merge pull request ceph#63349 from ronen-fr/wip-rf-63325-tentacle
tentacle: osd/scrub: remove the 2'nd option for determining 'low load' for scrub
2 parents 9434334 + cf85a00 commit 6d3146b

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

src/osd/scrubber/osd_scrub.cc

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -294,47 +294,43 @@ 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-
312-
// 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];
315-
if (loadavg_per_cpu < conf->osd_scrub_load_threshold) {
309+
// if the 1-min load average - even before dividing by the number of CPUs -
310+
// is below the configured threshold, scrubs are allowed. No need to call
311+
// sysconf().
312+
if (loadavg_1min < 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)
314+
"loadavg {:.3f} < max {:.3f} = yes",
315+
loadavg_1min, conf->osd_scrub_load_threshold)
319316
<< dendl;
320317
return true;
321318
}
322319

323-
// allow scrub if below daily avg and currently decreasing
324-
if (loadavgs[0] < daily_loadavg && loadavgs[0] < loadavgs[2]) {
320+
// check the load per CPU
321+
const long cpus = sysconf(_SC_NPROCESSORS_ONLN);
322+
const double loadavg_per_cpu = cpus > 0 ? loadavg_1min / cpus : loadavg_1min;
323+
if (loadavg_per_cpu < conf->osd_scrub_load_threshold) {
325324
dout(20) << fmt::format(
326-
"loadavg {:.3f} < daily_loadavg {:.3f} and < 15m avg "
327-
"{:.3f} = yes",
328-
loadavgs[0], daily_loadavg, loadavgs[2])
325+
"loadavg per cpu {:.3f} < max {:.3f} (#CPUs: {}) = yes",
326+
loadavg_per_cpu, conf->osd_scrub_load_threshold, cpus)
329327
<< dendl;
330328
return true;
331329
}
332330

333331
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])
332+
"loadavg {:.3f} >= max {:.3f} (#CPUs: {}) = no", loadavg_1min,
333+
conf->osd_scrub_load_threshold, cpus)
338334
<< dendl;
339335
return false;
340336
}

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)