]> git.proxmox.com Git - ceph.git/blob - ceph/src/osd/mClockClientQueue.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / osd / mClockClientQueue.cc
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) 2016 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
16 #include <memory>
17
18 #include "osd/mClockClientQueue.h"
19 #include "common/dout.h"
20
21 namespace dmc = crimson::dmclock;
22 using namespace std::placeholders;
23
24 #define dout_context cct
25 #define dout_subsys ceph_subsys_osd
26 #undef dout_prefix
27 #define dout_prefix *_dout
28
29
30 namespace ceph {
31
32 /*
33 * class mClockClientQueue
34 */
35
36 mClockClientQueue::mClockClientQueue(CephContext *cct) :
37 queue(std::bind(&mClockClientQueue::op_class_client_info_f, this, _1),
38 cct->_conf->osd_op_queue_mclock_anticipation_timeout),
39 client_info_mgr(cct)
40 {
41 // empty
42 }
43
44 const dmc::ClientInfo* mClockClientQueue::op_class_client_info_f(
45 const mClockClientQueue::InnerClient& client)
46 {
47 return client_info_mgr.get_client_info(client.second);
48 }
49
50 mClockClientQueue::InnerClient
51 inline mClockClientQueue::get_inner_client(const Client& cl,
52 const Request& request) {
53 return InnerClient(cl, client_info_mgr.osd_op_type(request));
54 }
55
56 // Formatted output of the queue
57 inline void mClockClientQueue::dump(ceph::Formatter *f) const {
58 queue.dump(f);
59 }
60
61 inline void mClockClientQueue::enqueue_strict(Client cl,
62 unsigned priority,
63 Request&& item) {
64 queue.enqueue_strict(get_inner_client(cl, item), priority,
65 std::move(item));
66 }
67
68 // Enqueue op in the front of the strict queue
69 inline void mClockClientQueue::enqueue_strict_front(Client cl,
70 unsigned priority,
71 Request&& item) {
72 queue.enqueue_strict_front(get_inner_client(cl, item), priority,
73 std::move(item));
74 }
75
76 // Enqueue op in the back of the regular queue
77 inline void mClockClientQueue::enqueue(Client cl,
78 unsigned priority,
79 unsigned cost,
80 Request&& item) {
81 queue.enqueue(get_inner_client(cl, item), priority, 1u, std::move(item));
82 }
83
84 // Enqueue the op in the front of the regular queue
85 inline void mClockClientQueue::enqueue_front(Client cl,
86 unsigned priority,
87 unsigned cost,
88 Request&& item) {
89 queue.enqueue_front(get_inner_client(cl, item), priority, 1u,
90 std::move(item));
91 }
92
93 // Return an op to be dispatched
94 inline Request mClockClientQueue::dequeue() {
95 return queue.dequeue();
96 }
97 } // namespace ceph