summaryrefslogtreecommitdiffstats
path: root/src/osd/scheduler
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/scheduler')
-rw-r--r--src/osd/scheduler/OpScheduler.cc21
-rw-r--r--src/osd/scheduler/OpScheduler.h26
-rw-r--r--src/osd/scheduler/mClockScheduler.cc2
-rw-r--r--src/osd/scheduler/mClockScheduler.h28
4 files changed, 32 insertions, 45 deletions
diff --git a/src/osd/scheduler/OpScheduler.cc b/src/osd/scheduler/OpScheduler.cc
index cb5ef13b6..12e5bdb6c 100644
--- a/src/osd/scheduler/OpScheduler.cc
+++ b/src/osd/scheduler/OpScheduler.cc
@@ -23,30 +23,25 @@ namespace ceph::osd::scheduler {
OpSchedulerRef make_scheduler(
CephContext *cct, int whoami, uint32_t num_shards, int shard_id,
- bool is_rotational, std::string_view osd_objectstore, MonClient *monc)
+ bool is_rotational, std::string_view osd_objectstore,
+ op_queue_type_t osd_scheduler, unsigned op_queue_cut_off, MonClient *monc)
{
- const std::string *type = &cct->_conf->osd_op_queue;
- if (*type == "debug_random") {
- static const std::string index_lookup[] = { "mclock_scheduler",
- "wpq" };
- srand(time(NULL));
- unsigned which = rand() % (sizeof(index_lookup) / sizeof(index_lookup[0]));
- type = &index_lookup[which];
- }
-
// Force the use of 'wpq' scheduler for filestore OSDs.
// The 'mclock_scheduler' is not supported for filestore OSDs.
- if (*type == "wpq" || osd_objectstore == "filestore") {
+ if (op_queue_type_t::WeightedPriorityQueue == osd_scheduler ||
+ osd_objectstore == "filestore") {
return std::make_unique<
ClassedOpQueueScheduler<WeightedPriorityQueue<OpSchedulerItem, client>>>(
cct,
+ op_queue_cut_off,
cct->_conf->osd_op_pq_max_tokens_per_priority,
cct->_conf->osd_op_pq_min_cost
);
- } else if (*type == "mclock_scheduler") {
+ } else if (op_queue_type_t::mClockScheduler == osd_scheduler) {
// default is 'mclock_scheduler'
return std::make_unique<
- mClockScheduler>(cct, whoami, num_shards, shard_id, is_rotational, monc);
+ mClockScheduler>(cct, whoami, num_shards, shard_id, is_rotational,
+ op_queue_cut_off, monc);
} else {
ceph_assert("Invalid choice of wq" == 0);
}
diff --git a/src/osd/scheduler/OpScheduler.h b/src/osd/scheduler/OpScheduler.h
index 1575bcae4..570a2a162 100644
--- a/src/osd/scheduler/OpScheduler.h
+++ b/src/osd/scheduler/OpScheduler.h
@@ -18,6 +18,7 @@
#include <variant>
#include "common/ceph_context.h"
+#include "common/OpQueue.h"
#include "mon/MonClient.h"
#include "osd/scheduler/OpSchedulerItem.h"
@@ -54,6 +55,9 @@ public:
// Apply config changes to the scheduler (if any)
virtual void update_configuration() = 0;
+ // Get the scheduler type set for the queue
+ virtual op_queue_type_t get_type() const = 0;
+
// Destructor
virtual ~OpScheduler() {};
};
@@ -63,7 +67,8 @@ using OpSchedulerRef = std::unique_ptr<OpScheduler>;
OpSchedulerRef make_scheduler(
CephContext *cct, int whoami, uint32_t num_shards, int shard_id,
- bool is_rotational, std::string_view osd_objectstore, MonClient *monc);
+ bool is_rotational, std::string_view osd_objectstore,
+ op_queue_type_t osd_scheduler, unsigned op_queue_cut_off, MonClient *monc);
/**
* Implements OpScheduler in terms of OpQueue
@@ -78,21 +83,10 @@ class ClassedOpQueueScheduler final : public OpScheduler {
unsigned cutoff;
T queue;
- static unsigned int get_io_prio_cut(CephContext *cct) {
- if (cct->_conf->osd_op_queue_cut_off == "debug_random") {
- srand(time(NULL));
- return (rand() % 2 < 1) ? CEPH_MSG_PRIO_HIGH : CEPH_MSG_PRIO_LOW;
- } else if (cct->_conf->osd_op_queue_cut_off == "high") {
- return CEPH_MSG_PRIO_HIGH;
- } else {
- // default / catch-all is 'low'
- return CEPH_MSG_PRIO_LOW;
- }
- }
public:
template <typename... Args>
- ClassedOpQueueScheduler(CephContext *cct, Args&&... args) :
- cutoff(get_io_prio_cut(cct)),
+ ClassedOpQueueScheduler(CephContext *cct, unsigned prio_cut, Args&&... args) :
+ cutoff(prio_cut),
queue(std::forward<Args>(args)...)
{}
@@ -143,6 +137,10 @@ public:
// no-op
}
+ op_queue_type_t get_type() const final {
+ return queue.get_type();
+ }
+
~ClassedOpQueueScheduler() final {};
};
diff --git a/src/osd/scheduler/mClockScheduler.cc b/src/osd/scheduler/mClockScheduler.cc
index 0ea519655..f72683d52 100644
--- a/src/osd/scheduler/mClockScheduler.cc
+++ b/src/osd/scheduler/mClockScheduler.cc
@@ -35,12 +35,14 @@ mClockScheduler::mClockScheduler(CephContext *cct,
uint32_t num_shards,
int shard_id,
bool is_rotational,
+ unsigned cutoff_priority,
MonClient *monc)
: cct(cct),
whoami(whoami),
num_shards(num_shards),
shard_id(shard_id),
is_rotational(is_rotational),
+ cutoff_priority(cutoff_priority),
monc(monc),
scheduler(
std::bind(&mClockScheduler::ClientRegistry::get_info,
diff --git a/src/osd/scheduler/mClockScheduler.h b/src/osd/scheduler/mClockScheduler.h
index f708b1d7a..16e7f911f 100644
--- a/src/osd/scheduler/mClockScheduler.h
+++ b/src/osd/scheduler/mClockScheduler.h
@@ -27,7 +27,6 @@
#include "osd/scheduler/OpScheduler.h"
#include "common/config.h"
#include "common/ceph_context.h"
-#include "common/mClockPriorityQueue.h"
#include "osd/scheduler/OpSchedulerItem.h"
@@ -97,6 +96,7 @@ class mClockScheduler : public OpScheduler, md_config_obs_t {
const uint32_t num_shards;
const int shard_id;
const bool is_rotational;
+ const unsigned cutoff_priority;
MonClient *monc;
/**
@@ -199,21 +199,6 @@ class mClockScheduler : public OpScheduler, md_config_obs_t {
};
}
- static unsigned int get_io_prio_cut(CephContext *cct) {
- if (cct->_conf->osd_op_queue_cut_off == "debug_random") {
- std::random_device rd;
- std::mt19937 random_gen(rd());
- return (random_gen() % 2 < 1) ? CEPH_MSG_PRIO_HIGH : CEPH_MSG_PRIO_LOW;
- } else if (cct->_conf->osd_op_queue_cut_off == "high") {
- return CEPH_MSG_PRIO_HIGH;
- } else {
- // default / catch-all is 'low'
- return CEPH_MSG_PRIO_LOW;
- }
- }
-
- unsigned cutoff_priority = get_io_prio_cut(cct);
-
/**
* set_osd_capacity_params_from_config
*
@@ -233,7 +218,8 @@ class mClockScheduler : public OpScheduler, md_config_obs_t {
public:
mClockScheduler(CephContext *cct, int whoami, uint32_t num_shards,
- int shard_id, bool is_rotational, MonClient *monc);
+ int shard_id, bool is_rotational, unsigned cutoff_priority,
+ MonClient *monc);
~mClockScheduler() override;
/// Calculate scaled cost per item
@@ -260,12 +246,18 @@ public:
void dump(ceph::Formatter &f) const final;
void print(std::ostream &ostream) const final {
- ostream << "mClockScheduler";
+ ostream << get_op_queue_type_name(get_type());
+ ostream << ", cutoff=" << cutoff_priority;
}
// Update data associated with the modified mclock config key(s)
void update_configuration() final;
+ // Return the scheduler type
+ op_queue_type_t get_type() const final {
+ return op_queue_type_t::mClockScheduler;
+ }
+
const char** get_tracked_conf_keys() const final;
void handle_conf_change(const ConfigProxy& conf,
const std::set<std::string> &changed) final;