// periodically kick recovery work queue
recovery_tp.wake();
- sched_scrub();
+ if (!scrub_random_backoff()) {
+ sched_scrub();
+ }
map_lock.get_read();
m->put();
}
-bool OSDService::scrub_should_schedule()
+bool OSD::scrub_random_backoff()
{
- double loadavgs[1];
-
- // TODOSAM: is_active should be conveyed to OSDService
- /*
- if (!is_active())
- return false;
- */
+ bool coin_flip = (rand() % 3) == whoami % 3;
+ if (!coin_flip) {
+ dout(20) << "scrub_random_backoff lost coin flip, randomly backing off" << dendl;
+ return true;
+ }
+ return false;
+}
+bool OSD::scrub_should_schedule()
+{
+ double loadavgs[1];
if (getloadavg(loadavgs, 1) != 1) {
dout(10) << "scrub_should_schedule couldn't read loadavgs\n" << dendl;
return false;
return false;
}
- bool coin_flip = (rand() % 3) == whoami % 3;
- if (!coin_flip) {
- dout(20) << "scrub_should_schedule loadavg " << loadavgs[0]
- << " < max " << g_conf->osd_scrub_load_threshold
- << " = no, randomly backing off"
- << dendl;
- return false;
- }
-
dout(20) << "scrub_should_schedule loadavg " << loadavgs[0]
<< " < max " << g_conf->osd_scrub_load_threshold
<< " = yes" << dendl;
{
assert(osd_lock.is_locked());
- bool should = service.scrub_should_schedule();
+ bool should = scrub_should_schedule();
dout(20) << "sched_scrub should=" << (int)should << dendl;
utime_t t = pos.first;
pg_t pgid = pos.second;
- if (t > min) {
+ if (t > max) {
dout(10) << " " << pgid << " at " << t
<< " > " << max << " (" << g_conf->osd_scrub_max_interval << " seconds ago)" << dendl;
break;
int scrubs_active;
set< pair<utime_t,pg_t> > last_scrub_pg;
- bool scrub_should_schedule();
-
void reg_last_pg_scrub(pg_t pgid, utime_t t) {
Mutex::Locker l(sched_scrub_lock);
last_scrub_pg.insert(pair<utime_t,pg_t>(t, pgid));
// -- scrubbing --
void sched_scrub();
- xlist<PG*> scrub_queue;
+ bool scrub_random_backoff();
+ bool scrub_should_schedule();
+ xlist<PG*> scrub_queue;
struct ScrubWQ : public ThreadPool::WorkQueue<PG> {
OSD *osd;