From 8d13461db64888ec844f88f6f700bbedf821c066 Mon Sep 17 00:00:00 2001 From: Aishwarya Mathuria Date: Fri, 19 May 2023 17:16:11 +0530 Subject: [PATCH] osd: Change scrub cost in case of mClock scheduler With osd_op_queue as WPQ, high costs were assigned to scrub in order to throttle it effectively. In the case of mClock scheduler, mClock parameters are used to do the throttling and the cost should represent a realistic value. Fixes: https://tracker.ceph.com/issues/61313 Signed-off-by: Aishwarya Mathuria (cherry picked from commit 43544d296c5fc14aaf638ddf21de9ea9d99f6059) --- src/common/options/global.yaml.in | 6 ++++++ src/osd/OSD.cc | 17 +++++++++++++---- src/osd/OSD.h | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/common/options/global.yaml.in b/src/common/options/global.yaml.in index bdb415c5de5c3..45f8905fa51b6 100644 --- a/src/common/options/global.yaml.in +++ b/src/common/options/global.yaml.in @@ -3645,6 +3645,12 @@ options: desc: Cost for scrub operations in work queue default: 50_M with_legacy: true +- name: osd_scrub_event_cost + type: size + level: advanced + desc: Cost for each scrub operation, used when osd_op_queue=mclock_scheduler + default: 4_K + with_legacy: true # set requested scrub priority higher than scrub priority to make the # requested scrubs jump the queue of scheduled scrubs - name: osd_requested_scrub_priority diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index c2404ce793b38..5bf61fc787903 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1750,9 +1750,8 @@ void OSDService::queue_scrub_event_msg(PG* pg, 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), cct->_conf->osd_scrub_cost, + unique_ptr(msg), get_scrub_cost(), pg->scrub_requeue_priority(with_priority, qu_priority), ceph_clock_now(), 0, epoch)); } @@ -1763,12 +1762,22 @@ void OSDService::queue_scrub_event_msg(PG* pg, 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), cct->_conf->osd_scrub_cost, + unique_ptr(msg), get_scrub_cost(), pg->scrub_requeue_priority(with_priority), ceph_clock_now(), 0, epoch)); } +int64_t OSDService::get_scrub_cost() +{ + + int64_t cost_for_queue = cct->_conf->osd_scrub_cost; + if (cct->_conf->osd_op_queue == "mclock_scheduler") { + cost_for_queue = cct->_conf->osd_scrub_event_cost * + cct->_conf->osd_shallow_scrub_chunk_max; + } + return cost_for_queue; +} + void OSDService::queue_for_scrub(PG* pg, Scrub::scrub_prio_t with_priority) { queue_scrub_event_msg(pg, with_priority); diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 9f8ac6ea7f6af..fae9a8e2aefdb 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -605,6 +605,7 @@ private: /// 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); + int64_t get_scrub_cost(); utime_t defer_recovery_until; uint64_t recovery_ops_active; -- 2.39.5