]> git.proxmox.com Git - ceph.git/blob - ceph/src/osd/mClockClientQueue.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / osd / mClockClientQueue.h
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 #pragma once
17
18 #include <ostream>
19
20 #include "boost/variant.hpp"
21
22 #include "common/config.h"
23 #include "common/ceph_context.h"
24 #include "common/mClockPriorityQueue.h"
25 #include "osd/OpQueueItem.h"
26 #include "osd/mClockOpClassSupport.h"
27
28
29 namespace ceph {
30
31 using Request = OpQueueItem;
32 using Client = uint64_t;
33
34 // This class exists to bridge the ceph code, which treats the class
35 // as the client, and the queue, where the class is
36 // osd_op_type_t. So this adapter class will transform calls
37 // appropriately.
38 class mClockClientQueue : public OpQueue<Request, Client> {
39
40 using osd_op_type_t = ceph::mclock::osd_op_type_t;
41
42 using InnerClient = std::pair<uint64_t,osd_op_type_t>;
43
44 using queue_t = mClockQueue<Request, InnerClient>;
45
46 queue_t queue;
47
48 ceph::mclock::OpClassClientInfoMgr client_info_mgr;
49
50 public:
51
52 mClockClientQueue(CephContext *cct);
53
54 const crimson::dmclock::ClientInfo* op_class_client_info_f(const InnerClient& client);
55
56 inline unsigned get_size_slow() const {
57 return queue.get_size_slow();
58 }
59
60 // Ops of this priority should be deleted immediately
61 inline void remove_by_class(Client cl,
62 std::list<Request> *out) override final {
63 queue.remove_by_filter(
64 [&cl, out] (Request&& r) -> bool {
65 if (cl == r.get_owner()) {
66 out->push_front(std::move(r));
67 return true;
68 } else {
69 return false;
70 }
71 });
72 }
73
74 void enqueue_strict(Client cl,
75 unsigned priority,
76 Request&& item) override final;
77
78 // Enqueue op in the front of the strict queue
79 void enqueue_strict_front(Client cl,
80 unsigned priority,
81 Request&& item) override final;
82
83 // Enqueue op in the back of the regular queue
84 void enqueue(Client cl,
85 unsigned priority,
86 unsigned cost,
87 Request&& item) override final;
88
89 // Enqueue the op in the front of the regular queue
90 void enqueue_front(Client cl,
91 unsigned priority,
92 unsigned cost,
93 Request&& item) override final;
94
95 // Return an op to be dispatch
96 Request dequeue() override final;
97
98 // Returns if the queue is empty
99 inline bool empty() const override final {
100 return queue.empty();
101 }
102
103 // Formatted output of the queue
104 void dump(ceph::Formatter *f) const override final;
105
106 protected:
107
108 InnerClient get_inner_client(const Client& cl, const Request& request);
109 }; // class mClockClientAdapter
110
111 } // namespace ceph