From: Xinze Chi Date: Fri, 16 Jan 2015 08:30:55 +0000 (+0000) Subject: osd: support schedule scrub between some time defined by users X-Git-Tag: v0.93~269^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f4b94e05cb9007502145bd422a8fcbf38d9fd160;p=ceph.git osd: support schedule scrub between some time defined by users Signed-off-by: Xinze Chi --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 08739c41720..970c345fd20 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -564,6 +564,8 @@ OPTION(osd_max_push_cost, OPT_U64, 8<<20) // max size of push message OPTION(osd_max_push_objects, OPT_U64, 10) // max objects in single push op OPTION(osd_recovery_forget_lost_objects, OPT_BOOL, false) // off for now OPTION(osd_max_scrubs, OPT_INT, 1) +OPTION(osd_scrub_begin_hour, OPT_INT, 0) +OPTION(osd_scrub_end_hour, OPT_INT, 24) OPTION(osd_scrub_load_threshold, OPT_FLOAT, 0.5) OPTION(osd_scrub_min_interval, OPT_FLOAT, 60*60*24) // if load is low OPTION(osd_scrub_max_interval, OPT_FLOAT, 7*60*60*24) // regardless of load diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index bc56c7c7f75..84dd4c5e2a0 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -5846,8 +5846,38 @@ bool OSD::scrub_random_backoff() return false; } +bool OSD::scrub_time_permit(utime_t now) +{ + struct tm bdt; + time_t tt = now.sec(); + localtime_r(&tt, &bdt); + bool time_permit = false; + if (cct->_conf->osd_scrub_begin_hour < cct->_conf->osd_scrub_end_hour) { + if (bdt.tm_hour >= cct->_conf->osd_scrub_begin_hour && bdt.tm_hour < cct->_conf->osd_scrub_end_hour) { + time_permit = true; + } + } else { + if (bdt.tm_hour >= cct->_conf->osd_scrub_begin_hour || bdt.tm_hour < cct->_conf->osd_scrub_end_hour) { + time_permit = true; + } + } + if (!time_permit) { + dout(20) << "scrub_should_schedule should run between " << cct->_conf->osd_scrub_begin_hour + << " - " << cct->_conf->osd_scrub_end_hour + << " now " << bdt.tm_hour << " = no" << dendl; + } else { + dout(20) << "scrub_should_schedule should run between " << cct->_conf->osd_scrub_begin_hour + << " - " << cct->_conf->osd_scrub_end_hour + << " now " << bdt.tm_hour << " = yes" << dendl; + } + return time_permit; +} + bool OSD::scrub_should_schedule() { + if (!scrub_time_permit(ceph_clock_now(cct))) { + return false; + } double loadavgs[1]; if (getloadavg(loadavgs, 1) != 1) { dout(10) << "scrub_should_schedule couldn't read loadavgs\n" << dendl; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 5638f39b6a9..f0ab31025ff 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -2088,6 +2088,7 @@ protected: void sched_scrub(); bool scrub_random_backoff(); bool scrub_should_schedule(); + bool scrub_time_permit(utime_t now); xlist scrub_queue;