33
44#include " ./pg_scrubber.h" // '.' notation used to affect clang-format order
55
6+ #include < fmt/ranges.h>
7+
68#include < cmath>
79#include < iostream>
810#include < span>
911#include < vector>
1012
11- #include < fmt/ranges.h>
12-
1313#include " debug.h"
1414
1515#include " common/ceph_time.h"
@@ -824,21 +824,21 @@ namespace {
824824 * an aux function to be used in select_range() below, to
825825 * select the correct chunk size based on the type of scrub
826826 */
827- int size_from_conf (
827+ int64_t size_from_conf (
828828 bool is_deep,
829829 const ceph::common::ConfigProxy& conf,
830- std::string_view deep_opt,
831- std::string_view shallow_opt)
830+ const md_config_cacher_t < int64_t >& deep_opt,
831+ const md_config_cacher_t < int64_t >& shallow_opt)
832832{
833833 if (!is_deep) {
834- auto sz = conf. get_val < int64_t >( shallow_opt) ;
834+ auto sz = * shallow_opt;
835835 if (sz != 0 ) {
836836 // assuming '0' means that no distinction was yet configured between
837837 // deep and shallow scrubbing
838- return static_cast < int >(sz) ;
838+ return sz ;
839839 }
840840 }
841- return static_cast < int >(conf. get_val < int64_t >( deep_opt)) ;
841+ return * deep_opt;
842842}
843843} // anonymous namespace
844844
@@ -917,16 +917,16 @@ std::optional<uint64_t> PgScrubber::select_range()
917917 dout (20 ) << fmt::format (
918918 " {} {} mins: {}d {}s, max: {}d {}s" , __func__,
919919 (m_is_deep ? " D" : " S" ),
920- conf. get_val < int64_t >( " osd_scrub_chunk_min" ) ,
921- conf. get_val < int64_t >( " osd_shallow_scrub_chunk_min" ) ,
922- conf. get_val < int64_t >( " osd_scrub_chunk_max" ) ,
923- conf. get_val < int64_t >( " osd_shallow_scrub_chunk_max" ) )
920+ * osd_scrub_chunk_min,
921+ * osd_shallow_scrub_chunk_min,
922+ * osd_scrub_chunk_max,
923+ * osd_shallow_scrub_chunk_max)
924924 << dendl;
925925
926- const int min_from_conf = size_from_conf (
927- m_is_deep, conf, " osd_scrub_chunk_min" , " osd_shallow_scrub_chunk_min" );
928- const int max_from_conf = size_from_conf (
929- m_is_deep, conf, " osd_scrub_chunk_max" , " osd_shallow_scrub_chunk_max" );
926+ const int min_from_conf = static_cast < int >( size_from_conf (
927+ m_is_deep, conf, osd_scrub_chunk_min, osd_shallow_scrub_chunk_min) );
928+ const int max_from_conf = static_cast < int >( size_from_conf (
929+ m_is_deep, conf, osd_scrub_chunk_max, osd_shallow_scrub_chunk_max) );
930930
931931 const int divisor = static_cast <int >(preemption_data.chunk_divisor ());
932932 const int min_chunk_sz = std::max (3 , min_from_conf / divisor);
@@ -1640,7 +1640,7 @@ void PgScrubber::replica_scrub_op(OpRequestRef op)
16401640 advance_token ();
16411641 const auto & conf = m_pg->get_cct ()->_conf ;
16421642 const int max_from_conf = size_from_conf (
1643- m_is_deep, conf, " osd_scrub_chunk_max" , " osd_shallow_scrub_chunk_max" );
1643+ m_is_deep, conf, osd_scrub_chunk_max, osd_shallow_scrub_chunk_max);
16441644 auto cost = get_scrub_cost (max_from_conf);
16451645 m_osds->queue_for_rep_scrub (m_pg,
16461646 m_replica_request_priority,
@@ -2546,6 +2546,16 @@ PgScrubber::PgScrubber(PG* pg)
25462546 , m_pg_id{pg->pg_id }
25472547 , m_osds{m_pg->osd }
25482548 , m_pg_whoami{pg->pg_whoami }
2549+ , osd_scrub_chunk_max{m_osds->cct ->_conf , " osd_scrub_chunk_max" }
2550+ , osd_shallow_scrub_chunk_max{m_osds->cct ->_conf ,
2551+ " osd_shallow_scrub_chunk_max" }
2552+ , osd_scrub_chunk_min{m_osds->cct ->_conf , " osd_scrub_chunk_min" }
2553+ , osd_shallow_scrub_chunk_min{m_osds->cct ->_conf ,
2554+ " osd_shallow_scrub_chunk_min" }
2555+ , osd_stats_update_period_scrubbing{
2556+ m_osds->cct ->_conf , " osd_stats_update_period_scrubbing" }
2557+ , osd_stats_update_period_not_scrubbing{
2558+ m_osds->cct ->_conf , " osd_stats_update_period_not_scrubbing" }
25492559 , preemption_data{pg}
25502560{
25512561 m_fsm = std::make_unique<ScrubMachine>(m_pg, this );
@@ -2674,7 +2684,8 @@ const OSDMapRef& PgScrubber::get_osdmap() const
26742684
26752685LoggerSinkSet& PgScrubber::get_logger () const { return *m_osds->clog .get (); }
26762686
2677- ostream &operator <<(ostream &out, const PgScrubber &scrubber) {
2687+ ostream& operator <<(ostream& out, const PgScrubber& scrubber)
2688+ {
26782689 return out << scrubber.m_flags ;
26792690}
26802691
@@ -2788,16 +2799,14 @@ void PgScrubber::update_scrub_stats(ceph::coarse_real_clock::time_point now_is)
27882799 using clock = ceph::coarse_real_clock;
27892800 using namespace std ::chrono;
27902801
2791- const seconds period_active = seconds (m_pg->get_cct ()->_conf .get_val <int64_t >(
2792- " osd_stats_update_period_scrubbing" ));
2802+ const seconds period_active = seconds (*osd_stats_update_period_scrubbing);
27932803 if (!period_active.count ()) {
27942804 // a way for the operator to disable these stats updates
27952805 return ;
27962806 }
2797- const seconds period_inactive =
2798- seconds (m_pg->get_cct ()->_conf .get_val <int64_t >(
2799- " osd_stats_update_period_not_scrubbing" ) +
2800- m_pg_id.pgid .m_seed % 30 );
2807+ const seconds period_inactive = seconds (
2808+ *osd_stats_update_period_not_scrubbing +
2809+ m_pg_id.pgid .m_seed % 30 );
28012810
28022811 // determine the required update period, based on our current state
28032812 auto period{period_inactive};
@@ -2831,10 +2840,10 @@ void PgScrubber::update_scrub_stats(ceph::coarse_real_clock::time_point now_is)
28312840
28322841// ///////////////////// preemption_data_t //////////////////////////////////
28332842
2834- PgScrubber::preemption_data_t::preemption_data_t (PG* pg) : m_pg{pg}
2843+ PgScrubber::preemption_data_t::preemption_data_t (PG* pg) : m_pg{pg},
2844+ osd_scrub_max_preemptions{pg->cct ->_conf , " osd_scrub_max_preemptions" }
28352845{
2836- m_left = static_cast <int >(
2837- m_pg->get_cct ()->_conf .get_val <uint64_t >(" osd_scrub_max_preemptions" ));
2846+ m_left = *osd_scrub_max_preemptions;
28382847}
28392848
28402849void PgScrubber::preemption_data_t::reset ()
@@ -2843,8 +2852,7 @@ void PgScrubber::preemption_data_t::reset()
28432852
28442853 m_preemptable = false ;
28452854 m_preempted = false ;
2846- m_left = static_cast <int >(
2847- m_pg->cct ->_conf .get_val <uint64_t >(" osd_scrub_max_preemptions" ));
2855+ m_left = *osd_scrub_max_preemptions;
28482856 m_size_divisor = 1 ;
28492857}
28502858
0 commit comments