From 0c78dd717814ecc37b5ea4ca871d57b832a70f6f Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 8 Mar 2023 14:08:23 +0300 Subject: [PATCH] Add no_scrub flag --- src/cli.h | 1 - src/cli_status.cpp | 2 ++ src/osd.cpp | 10 ++++++++++ src/osd.h | 1 + src/osd_scrub.cpp | 23 ++++++++++++++++++++++- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/cli.h b/src/cli.h index 4d4c1012..c01adaf4 100644 --- a/src/cli.h +++ b/src/cli.h @@ -39,7 +39,6 @@ public: ring_loop_t *ringloop = NULL; epoll_manager_t *epmgr = NULL; cluster_client_t *cli = NULL; - bool no_recovery = false, no_rebalance = false, readonly = false; int waiting = 0; cli_result_t etcd_err; diff --git a/src/cli_status.cpp b/src/cli_status.cpp index 220b6de2..fdefe20c 100644 --- a/src/cli_status.cpp +++ b/src/cli_status.cpp @@ -201,6 +201,7 @@ resume_2: bool readonly = json_is_true(parent->cli->config["readonly"]); bool no_recovery = json_is_true(parent->cli->config["no_recovery"]); bool no_rebalance = json_is_true(parent->cli->config["no_rebalance"]); + bool no_scrub = json_is_true(parent->cli->config["no_scrub"]); if (parent->json_output) { // JSON output @@ -219,6 +220,7 @@ resume_2: { "readonly", readonly }, { "no_recovery", no_recovery }, { "no_rebalance", no_rebalance }, + { "no_scrub", no_scrub }, { "pool_count", pool_count }, { "active_pool_count", pools_active }, { "pg_states", pgs_by_state }, diff --git a/src/osd.cpp b/src/osd.cpp index 21ea86dc..6db6cb94 100644 --- a/src/osd.cpp +++ b/src/osd.cpp @@ -169,6 +169,8 @@ void osd_t::parse_config(bool init) no_rebalance = json_is_true(config["no_rebalance"]); auto old_no_recovery = no_recovery; no_recovery = json_is_true(config["no_recovery"]); + auto old_no_scrub = no_scrub; + no_scrub = json_is_true(config["no_scrub"]); auto old_autosync_interval = autosync_interval; if (!config["autosync_interval"].is_null()) { @@ -219,6 +221,14 @@ void osd_t::parse_config(bool init) scrub_list_limit = config["scrub_list_limit"].uint64_value(); if (!scrub_list_limit) scrub_list_limit = 1000; + if (old_no_scrub && !no_scrub) + { + // Wakeup scrubbing + for (auto & pgp: pgs) + { + schedule_scrub(pgp.second); + } + } if ((old_no_rebalance && !no_rebalance || old_no_recovery && !no_recovery) && !(peering_state & (OSD_RECOVERING | OSD_FLUSHING_PGS))) { diff --git a/src/osd.h b/src/osd.h index 403badf0..fc760c23 100644 --- a/src/osd.h +++ b/src/osd.h @@ -99,6 +99,7 @@ class osd_t bool run_primary = false; bool no_rebalance = false; bool no_recovery = false; + bool no_scrub = false; std::string bind_address; int bind_port, listen_backlog = 128; // FIXME: Implement client queue depth limit diff --git a/src/osd_scrub.cpp b/src/osd_scrub.cpp index 7cd2c3a3..64771258 100644 --- a/src/osd_scrub.cpp +++ b/src/osd_scrub.cpp @@ -285,6 +285,27 @@ bool osd_t::continue_scrub() { return true; } + if (no_scrub) + { + // Return false = no more scrub work to do + scrub_cur_list = {}; + scrub_last_pg = {}; + scrub_nearest_ts = 0; + if (scrub_timer_id >= 0) + { + tfd->clear_timer(scrub_timer_id); + scrub_timer_id = -1; + } + for (auto pg_it = pgs.begin(); pg_it != pgs.end(); pg_it++) + { + if (pg_it->second.state & PG_SCRUBBING) + { + pg_it->second.state = pg_it->second.state & ~PG_SCRUBBING; + report_pg_state(pg_it->second); + } + } + return false; + } while (scrub_ops.size() < scrub_queue_depth) { object_id oid; @@ -299,7 +320,7 @@ bool osd_t::continue_scrub() void osd_t::schedule_scrub(pg_t & pg) { - if (pg.next_scrub && (!scrub_nearest_ts || scrub_nearest_ts > pg.next_scrub)) + if (!no_scrub && pg.next_scrub && (!scrub_nearest_ts || scrub_nearest_ts > pg.next_scrub)) { scrub_nearest_ts = pg.next_scrub; timespec tv_now;