From 07c285ae4e230454ffcdf8b9dc64d912a9994626 Mon Sep 17 00:00:00 2001 From: Aishwarya Mathuria Date: Tue, 27 Feb 2024 17:04:22 +0000 Subject: [PATCH] osd: Rename queue_scrub_event_msg to queue_scrub_event_msg_default_cost Since most scrub messages are queued with the default scrub cost, we can use queue_scrub_event_msg_default_cost where the default scrub cost will be passed when a scrub message is to be queued. Signed-off-by: Aishwarya Mathuria --- src/osd/OSD.cc | 60 +++++++++++++++++++++++++++++++++----------------- src/osd/OSD.h | 12 ++++++++-- 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index dfb2134f3ff..881d0e1d639 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1755,29 +1755,49 @@ template void OSDService::queue_scrub_event_msg(PG* pg, Scrub::scrub_prio_t with_priority, unsigned int qu_priority, - Scrub::act_token_t act_token) + Scrub::act_token_t act_token, + uint64_t cost) { const auto epoch = pg->get_osdmap_epoch(); auto msg = new MSG_TYPE(pg->get_pgid(), epoch, act_token); dout(15) << "queue a scrub event (" << *msg << ") for " << *pg << ". Epoch: " << epoch << " token: " << act_token << dendl; enqueue_back(OpSchedulerItem( - unique_ptr(msg), get_scrub_cost(), + unique_ptr(msg), cost, pg->scrub_requeue_priority(with_priority, qu_priority), ceph_clock_now(), 0, epoch)); } template void OSDService::queue_scrub_event_msg(PG* pg, - Scrub::scrub_prio_t with_priority) + Scrub::scrub_prio_t with_priority, + uint64_t cost) { const auto epoch = pg->get_osdmap_epoch(); auto msg = new MSG_TYPE(pg->get_pgid(), epoch); dout(15) << "queue a scrub event (" << *msg << ") for " << *pg << ". Epoch: " << epoch << dendl; enqueue_back(OpSchedulerItem( - unique_ptr(msg), get_scrub_cost(), + unique_ptr(msg), cost, pg->scrub_requeue_priority(with_priority), ceph_clock_now(), 0, epoch)); } +template +void OSDService::queue_scrub_event_msg_default_cost(PG* pg, + Scrub::scrub_prio_t with_priority, + unsigned int qu_priority, + Scrub::act_token_t act_token) +{ + uint64_t cost = cct->_conf->osd_scrub_event_cost; + queue_scrub_event_msg(pg, with_priority, qu_priority, act_token, cost); +} + +template +void OSDService::queue_scrub_event_msg_default_cost(PG* pg, + Scrub::scrub_prio_t with_priority) +{ + uint64_t cost = cct->_conf->osd_scrub_event_cost; + queue_scrub_event_msg(pg, with_priority, cost); +} + int64_t OSDService::get_scrub_cost() { @@ -1791,12 +1811,12 @@ int64_t OSDService::get_scrub_cost() void OSDService::queue_for_scrub(PG* pg, Scrub::scrub_prio_t with_priority) { - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_scrub_after_repair(PG* pg, Scrub::scrub_prio_t with_priority) { - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_for_rep_scrub(PG* pg, @@ -1804,7 +1824,7 @@ void OSDService::queue_for_rep_scrub(PG* pg, unsigned int qu_priority, Scrub::act_token_t act_token) { - queue_scrub_event_msg(pg, with_priority, qu_priority, act_token); + queue_scrub_event_msg(pg, with_priority, qu_priority, act_token, get_scrub_cost()); } void OSDService::queue_for_rep_scrub_resched(PG* pg, @@ -1813,73 +1833,73 @@ void OSDService::queue_for_rep_scrub_resched(PG* pg, Scrub::act_token_t act_token) { // Resulting scrub event: 'SchedReplica' - queue_scrub_event_msg(pg, with_priority, qu_priority, - act_token); + queue_scrub_event_msg_default_cost(pg, with_priority, qu_priority, + act_token); } void OSDService::queue_for_scrub_resched(PG* pg, Scrub::scrub_prio_t with_priority) { // Resulting scrub event: 'InternalSchedScrub' - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_scrub_pushes_update(PG* pg, Scrub::scrub_prio_t with_priority) { // Resulting scrub event: 'ActivePushesUpd' - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_scrub_chunk_free(PG* pg, Scrub::scrub_prio_t with_priority) { // Resulting scrub event: 'SelectedChunkFree' - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg(pg, with_priority, get_scrub_cost()); } void OSDService::queue_scrub_chunk_busy(PG* pg, Scrub::scrub_prio_t with_priority) { // Resulting scrub event: 'ChunkIsBusy' - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_scrub_applied_update(PG* pg, Scrub::scrub_prio_t with_priority) { - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_scrub_unblocking(PG* pg, Scrub::scrub_prio_t with_priority) { // Resulting scrub event: 'Unblocked' - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_scrub_digest_update(PG* pg, Scrub::scrub_prio_t with_priority) { // Resulting scrub event: 'DigestUpdate' - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_scrub_got_repl_maps(PG* pg, Scrub::scrub_prio_t with_priority) { // Resulting scrub event: 'GotReplicas' - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_scrub_replica_pushes(PG *pg, Scrub::scrub_prio_t with_priority) { // Resulting scrub event: 'ReplicaPushesUpd' - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_scrub_is_finished(PG *pg) { // Resulting scrub event: 'ScrubFinished' - queue_scrub_event_msg(pg, Scrub::scrub_prio_t::high_priority); + queue_scrub_event_msg_default_cost(pg, Scrub::scrub_prio_t::high_priority); } void OSDService::queue_scrub_next_chunk(PG *pg, Scrub::scrub_prio_t with_priority) { // Resulting scrub event: 'NextChunk' - queue_scrub_event_msg(pg, with_priority); + queue_scrub_event_msg_default_cost(pg, with_priority); } void OSDService::queue_for_pg_delete(spg_t pgid, epoch_t e) diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 99fd0818765..d810b77abad 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -585,12 +585,20 @@ private: void queue_scrub_event_msg(PG* pg, Scrub::scrub_prio_t with_priority, unsigned int qu_priority, - Scrub::act_token_t act_token); + Scrub::act_token_t act_token, + uint64_t cost); /// An alternative version of queue_scrub_event_msg(), in which the queuing priority is /// provided by the executing scrub (i.e. taken from PgScrubber::m_flags) template - void queue_scrub_event_msg(PG* pg, Scrub::scrub_prio_t with_priority); + void queue_scrub_event_msg(PG* pg, Scrub::scrub_prio_t with_priority, uint64_t cost); + template + void queue_scrub_event_msg_default_cost(PG* pg, Scrub::scrub_prio_t with_priority); + template + void queue_scrub_event_msg_default_cost(PG* pg, + Scrub::scrub_prio_t with_priority, + unsigned int qu_priority, + Scrub::act_token_t act_token); int64_t get_scrub_cost(); utime_t defer_recovery_until; -- 2.39.5