From: Kefu Chai Date: Thu, 9 Feb 2017 16:54:54 +0000 (+0800) Subject: tests: osd-scrub-repair.sh disable scrub backoff in test X-Git-Tag: v12.0.1~459^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6016dd9acbd9dab928437b1f1d76522b22d5c241;p=ceph.git tests: osd-scrub-repair.sh disable scrub backoff in test there is good chance that the newly scheduled scrub fail to pass the flip-coin check: the probability of scheduling a new scrub 1/3 every time we flip the coin. so, instead hardwiring the probability to 1/3, a new option named "osd_scrub_backoff_ratio" is introduced. so we can override it when performing test. Signed-off-by: Kefu Chai --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 6e3f37917a6..3a27dbed58d 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -808,6 +808,7 @@ 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 OPTION(osd_scrub_interval_randomize_ratio, OPT_FLOAT, 0.5) // randomize the scheduled scrub in the span of [min,min*(1+randomize_ratio)) +OPTION(osd_scrub_backoff_ratio, OPT_DOUBLE, .66) // the probability to back off the scheduled scrub OPTION(osd_scrub_chunk_min, OPT_INT, 5) OPTION(osd_scrub_chunk_max, OPT_INT, 25) OPTION(osd_scrub_sleep, OPT_FLOAT, 0) // sleep between [deep]scrub ops diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index c7c281dbf9f..95b3062e65c 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -6582,7 +6582,8 @@ void OSD::handle_scrub(MOSDScrub *m) bool OSD::scrub_random_backoff() { - bool coin_flip = (rand() % 3) == whoami % 3; + bool coin_flip = (rand() / (double)RAND_MAX >= + cct->_conf->osd_scrub_backoff_ratio); if (!coin_flip) { dout(20) << "scrub_random_backoff lost coin flip, randomly backing off" << dendl; return true; diff --git a/src/test/osd/osd-scrub-repair.sh b/src/test/osd/osd-scrub-repair.sh index 680af924ad1..a912933c0c8 100755 --- a/src/test/osd/osd-scrub-repair.sh +++ b/src/test/osd/osd-scrub-repair.sh @@ -2227,7 +2227,11 @@ function TEST_periodic_scrub_replicated() { rados list-inconsistent-obj $pg | jq '.' | grep -q $objname || return 1 # Request a regular scrub and it will be done + local scrub_backoff_ratio=$(get_config osd ${primary} osd_scrub_backoff_ratio) + set_config osd ${primary} osd_scrub_backoff_ratio 0 pg_scrub $pg + sleep 1 + set_config osd ${primary} osd_scrub_backoff_ratio $scrub_backoff_ratio grep -q "Regular scrub request, losing deep-scrub details" $dir/osd.${primary}.log || return 1 # deep-scrub error is no longer present