From 3bfb5c2621cf9b5e602bc37724b20c18eb852aea Mon Sep 17 00:00:00 2001 From: Jeegn Chen Date: Fri, 26 Jul 2019 10:09:01 +0800 Subject: [PATCH] osd: support osd_scrub_extended_sleep 1. always take osd_scrub_sleep for manually initiated scrubs 2. when scrub_time_permit() return true for scheduled ones, the existing osd_scrub_sleep is used 3. when scrub_time_permit() return false for scheduled ones, there may be 2 scenarios 3.1 if osd_scrub_extended_sleep <= osd_scrub_sleep, let's take osd_scrub_sleep 3.2 otherwise, let's take osd_scrub_extended_sleep Fixes: http://tracker.ceph.com/issues/40955 Signed-off-by: Jeegn Chen --- qa/standalone/scrub/osd-scrub-test.sh | 43 +++++++++++++++++++++++++++ src/common/legacy_config_opts.h | 1 + src/common/options.cc | 8 +++++ src/osd/OSD.cc | 14 +++++++++ src/osd/OSD.h | 2 ++ src/osd/PG.cc | 7 +++-- 6 files changed, 72 insertions(+), 3 deletions(-) diff --git a/qa/standalone/scrub/osd-scrub-test.sh b/qa/standalone/scrub/osd-scrub-test.sh index c530233ea82..b99ef328c81 100755 --- a/qa/standalone/scrub/osd-scrub-test.sh +++ b/qa/standalone/scrub/osd-scrub-test.sh @@ -187,6 +187,49 @@ function TEST_interval_changes() { teardown $dir || return 1 } +function TEST_scrub_extented_sleep() { + local dir=$1 + local poolname=test + local OSDS=3 + local objects=15 + + TESTDATA="testdata.$$" + + setup $dir || return 1 + run_mon $dir a --osd_pool_default_size=3 || return 1 + run_mgr $dir x || return 1 + local scrub_begin_hour=$(date -d '2 hour ago' +"%H" | sed 's/^0//') + local scrub_end_hour=$(date -d '1 hour ago' +"%H" | sed 's/^0//') + for osd in $(seq 0 $(expr $OSDS - 1)) + do + run_osd $dir $osd --osd_scrub_sleep=0 \ + --osd_scrub_extended_sleep=10 \ + --bluestore_cache_autotune=false \ + --osd_scrub_begin_hour=$scrub_begin_hour \ + --osd_scrub_end_hour=$scrub_end_hour || return 1 + done + + # Create a pool with a single pg + create_pool $poolname 1 1 + wait_for_clean || return 1 + + # Trigger a scrub on a PG + local pgid=$(get_pg $poolname SOMETHING) + local primary=$(get_primary $poolname SOMETHING) + local last_scrub=$(get_last_scrub_stamp $pgid) + CEPH_ARGS='' ceph daemon $(get_asok_path osd.$primary) trigger_scrub $pgid || return 1 + + # Due to the long delay, the scrub should not be done within 3 seconds + for ((i=0; i < 3; i++)); do + if test "$(get_last_scrub_stamp $pgid)" '>' "$last_scrub" ; then + return 1 + fi + sleep 1 + done + + teardown $dir || return 1 +} + main osd-scrub-test "$@" # Local Variables: diff --git a/src/common/legacy_config_opts.h b/src/common/legacy_config_opts.h index df13b12c80f..be8d8972806 100644 --- a/src/common/legacy_config_opts.h +++ b/src/common/legacy_config_opts.h @@ -717,6 +717,7 @@ OPTION(osd_scrub_backoff_ratio, OPT_DOUBLE) // the probability to back off the OPTION(osd_scrub_chunk_min, OPT_INT) OPTION(osd_scrub_chunk_max, OPT_INT) OPTION(osd_scrub_sleep, OPT_FLOAT) // sleep between [deep]scrub ops +OPTION(osd_scrub_extended_sleep, OPT_FLOAT) // more sleep between [deep]scrub ops OPTION(osd_scrub_auto_repair, OPT_BOOL) // whether auto-repair inconsistencies upon deep-scrubbing OPTION(osd_scrub_auto_repair_num_errors, OPT_U32) // only auto-repair when number of errors is below this threshold OPTION(osd_deep_scrub_interval, OPT_FLOAT) // once a week diff --git a/src/common/options.cc b/src/common/options.cc index 0d07fa57ed2..b457d039fef 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -3503,6 +3503,14 @@ std::vector