Skip to content

Commit 5532f6a

Browse files
committed
osd/scrub: Change scrub cost to use average object size
In order to get an accurate cost of the scrub operation for mClock scheduler, we use the cost calculated by the get_scrub_cost() method which takes into account the average of the object sizes in a PG that is queued for a scrub. Signed-off-by: Aishwarya Mathuria <[email protected]>
1 parent 07c285a commit 5532f6a

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/osd/OSD.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,9 +1822,10 @@ void OSDService::queue_scrub_after_repair(PG* pg, Scrub::scrub_prio_t with_prior
18221822
void OSDService::queue_for_rep_scrub(PG* pg,
18231823
Scrub::scrub_prio_t with_priority,
18241824
unsigned int qu_priority,
1825-
Scrub::act_token_t act_token)
1825+
Scrub::act_token_t act_token,
1826+
uint64_t cost)
18261827
{
1827-
queue_scrub_event_msg<PGRepScrub>(pg, with_priority, qu_priority, act_token, get_scrub_cost());
1828+
queue_scrub_event_msg<PGRepScrub>(pg, with_priority, qu_priority, act_token, cost);
18281829
}
18291830

18301831
void OSDService::queue_for_rep_scrub_resched(PG* pg,
@@ -1849,10 +1850,10 @@ void OSDService::queue_scrub_pushes_update(PG* pg, Scrub::scrub_prio_t with_prio
18491850
queue_scrub_event_msg_default_cost<PGScrubPushesUpdate>(pg, with_priority);
18501851
}
18511852

1852-
void OSDService::queue_scrub_chunk_free(PG* pg, Scrub::scrub_prio_t with_priority)
1853+
void OSDService::queue_scrub_chunk_free(PG* pg, Scrub::scrub_prio_t with_priority, uint64_t cost)
18531854
{
18541855
// Resulting scrub event: 'SelectedChunkFree'
1855-
queue_scrub_event_msg<PGScrubChunkIsFree>(pg, with_priority, get_scrub_cost());
1856+
queue_scrub_event_msg<PGScrubChunkIsFree>(pg, with_priority, cost);
18561857
}
18571858

18581859
void OSDService::queue_scrub_chunk_busy(PG* pg, Scrub::scrub_prio_t with_priority)

src/osd/OSD.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ class OSDService : public Scrub::ScrubSchedListener {
526526
void queue_scrub_applied_update(PG* pg, Scrub::scrub_prio_t with_priority);
527527

528528
/// Signals that the selected chunk (objects range) is available for scrubbing
529-
void queue_scrub_chunk_free(PG* pg, Scrub::scrub_prio_t with_priority);
529+
void queue_scrub_chunk_free(PG* pg, Scrub::scrub_prio_t with_priority, uint64_t cost);
530530

531531
/// The chunk selected is blocked by user operations, and cannot be scrubbed now
532532
void queue_scrub_chunk_busy(PG* pg, Scrub::scrub_prio_t with_priority);
@@ -552,7 +552,8 @@ class OSDService : public Scrub::ScrubSchedListener {
552552
void queue_for_rep_scrub(PG* pg,
553553
Scrub::scrub_prio_t with_high_priority,
554554
unsigned int qu_priority,
555-
Scrub::act_token_t act_token);
555+
Scrub::act_token_t act_token,
556+
uint64_t cost);
556557

557558
/// Signals a change in the number of in-flight recovery writes
558559
void queue_scrub_replica_pushes(PG *pg, Scrub::scrub_prio_t with_priority);

src/osd/scrubber/pg_scrubber.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -948,11 +948,12 @@ std::optional<uint64_t> PgScrubber::select_range()
948948
void PgScrubber::select_range_n_notify()
949949
{
950950
get_counters_set().inc(scrbcnt_chunks_selected);
951-
952-
if (select_range()) {
951+
auto num_chunk_objects = select_range();
952+
if (num_chunk_objects.has_value()) {
953953
// the next chunk to handle is not blocked
954954
dout(20) << __func__ << ": selection OK" << dendl;
955-
m_osds->queue_scrub_chunk_free(m_pg, Scrub::scrub_prio_t::low_priority);
955+
auto cost = get_scrub_cost(num_chunk_objects.value());
956+
m_osds->queue_scrub_chunk_free(m_pg, Scrub::scrub_prio_t::low_priority, cost);
956957
} else {
957958
// we will wait for the objects range to become available for scrubbing
958959
dout(10) << __func__ << ": selected chunk is busy" << dendl;
@@ -1566,10 +1567,15 @@ void PgScrubber::replica_scrub_op(OpRequestRef op)
15661567

15671568
set_queued_or_active();
15681569
advance_token();
1570+
const auto& conf = m_pg->get_cct()->_conf;
1571+
const int max_from_conf = size_from_conf(
1572+
m_is_deep, conf, "osd_scrub_chunk_max", "osd_shallow_scrub_chunk_max");
1573+
auto cost = get_scrub_cost(max_from_conf);
15691574
m_osds->queue_for_rep_scrub(m_pg,
15701575
m_replica_request_priority,
15711576
m_flags.priority,
1572-
m_current_token);
1577+
m_current_token,
1578+
cost);
15731579
}
15741580

15751581
void PgScrubber::set_op_parameters(const requested_scrub_t& request)

0 commit comments

Comments
 (0)