1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2019 Red Hat Inc.
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
17 #include "osd/scheduler/OpScheduler.h"
19 #include "common/WeightedPriorityQueue.h"
20 #include "osd/scheduler/mClockScheduler.h"
22 namespace ceph::osd::scheduler
{
24 OpSchedulerRef
make_scheduler(
25 CephContext
*cct
, uint32_t num_shards
,
26 bool is_rotational
, std::string_view osd_objectstore
)
28 const std::string
*type
= &cct
->_conf
->osd_op_queue
;
29 if (*type
== "debug_random") {
30 static const std::string index_lookup
[] = { "mclock_scheduler",
33 unsigned which
= rand() % (sizeof(index_lookup
) / sizeof(index_lookup
[0]));
34 type
= &index_lookup
[which
];
37 // Force the use of 'wpq' scheduler for filestore OSDs.
38 // The 'mclock_scheduler' is not supported for filestore OSDs.
39 if (*type
== "wpq" || osd_objectstore
== "filestore") {
40 return std::make_unique
<
41 ClassedOpQueueScheduler
<WeightedPriorityQueue
<OpSchedulerItem
, client
>>>(
43 cct
->_conf
->osd_op_pq_max_tokens_per_priority
,
44 cct
->_conf
->osd_op_pq_min_cost
46 } else if (*type
== "mclock_scheduler") {
47 // default is 'mclock_scheduler'
48 return std::make_unique
<mClockScheduler
>(cct
, num_shards
, is_rotational
);
50 ceph_assert("Invalid choice of wq" == 0);
54 std::ostream
&operator<<(std::ostream
&lhs
, const OpScheduler
&rhs
) {