]> git.proxmox.com Git - ceph.git/blame - ceph/src/osd/scheduler/OpScheduler.cc
import ceph quincy 17.2.6
[ceph.git] / ceph / src / osd / scheduler / OpScheduler.cc
CommitLineData
9f95a23c
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2019 Red Hat Inc.
7 *
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.
12 *
13 */
14
15#include <ostream>
16
17#include "osd/scheduler/OpScheduler.h"
18
19#include "common/WeightedPriorityQueue.h"
20#include "osd/scheduler/mClockScheduler.h"
21
22namespace ceph::osd::scheduler {
23
f67539c2 24OpSchedulerRef make_scheduler(
39ae355f
TL
25 CephContext *cct, int whoami, uint32_t num_shards, int shard_id,
26 bool is_rotational, std::string_view osd_objectstore, MonClient *monc)
9f95a23c
TL
27{
28 const std::string *type = &cct->_conf->osd_op_queue;
29 if (*type == "debug_random") {
30 static const std::string index_lookup[] = { "mclock_scheduler",
31 "wpq" };
32 srand(time(NULL));
33 unsigned which = rand() % (sizeof(index_lookup) / sizeof(index_lookup[0]));
34 type = &index_lookup[which];
35 }
36
20effc67
TL
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") {
9f95a23c
TL
40 return std::make_unique<
41 ClassedOpQueueScheduler<WeightedPriorityQueue<OpSchedulerItem, client>>>(
42 cct,
43 cct->_conf->osd_op_pq_max_tokens_per_priority,
44 cct->_conf->osd_op_pq_min_cost
45 );
46 } else if (*type == "mclock_scheduler") {
20effc67 47 // default is 'mclock_scheduler'
39ae355f
TL
48 return std::make_unique<
49 mClockScheduler>(cct, whoami, num_shards, shard_id, is_rotational, monc);
9f95a23c
TL
50 } else {
51 ceph_assert("Invalid choice of wq" == 0);
52 }
53}
54
55std::ostream &operator<<(std::ostream &lhs, const OpScheduler &rhs) {
56 rhs.print(lhs);
57 return lhs;
58}
59
60}