]>
Commit | Line | Data |
---|---|---|
224ce89b WB |
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" | |
11fdf7f2 | 21 | #include "boost/container/flat_set.hpp" |
224ce89b WB |
22 | |
23 | #include "common/config.h" | |
24 | #include "common/ceph_context.h" | |
224ce89b | 25 | #include "common/mClockPriorityQueue.h" |
11fdf7f2 TL |
26 | #include "osd/OpQueueItem.h" |
27 | #include "osd/mClockOpClassSupport.h" | |
224ce89b WB |
28 | |
29 | ||
30 | namespace ceph { | |
31 | ||
11fdf7f2 TL |
32 | using Request = OpQueueItem; |
33 | using Client = uint64_t; | |
224ce89b WB |
34 | |
35 | // This class exists to bridge the ceph code, which treats the class | |
36 | // as the client, and the queue, where the class is | |
11fdf7f2 | 37 | // osd_op_type_t. So this adapter class will transform calls |
224ce89b WB |
38 | // appropriately. |
39 | class mClockOpClassQueue : public OpQueue<Request, Client> { | |
40 | ||
11fdf7f2 | 41 | using osd_op_type_t = ceph::mclock::osd_op_type_t; |
224ce89b WB |
42 | |
43 | using queue_t = mClockQueue<Request, osd_op_type_t>; | |
224ce89b WB |
44 | queue_t queue; |
45 | ||
11fdf7f2 | 46 | ceph::mclock::OpClassClientInfoMgr client_info_mgr; |
224ce89b WB |
47 | |
48 | public: | |
49 | ||
50 | mClockOpClassQueue(CephContext *cct); | |
51 | ||
11fdf7f2 | 52 | const crimson::dmclock::ClientInfo* |
224ce89b WB |
53 | op_class_client_info_f(const osd_op_type_t& op_type); |
54 | ||
11fdf7f2 TL |
55 | inline unsigned get_size_slow() const { |
56 | return queue.get_size_slow(); | |
224ce89b WB |
57 | } |
58 | ||
59 | // Ops of this priority should be deleted immediately | |
60 | inline void remove_by_class(Client cl, | |
61 | std::list<Request> *out) override final { | |
62 | queue.remove_by_filter( | |
11fdf7f2 TL |
63 | [&cl, out] (Request&& r) -> bool { |
64 | if (cl == r.get_owner()) { | |
65 | out->push_front(std::move(r)); | |
224ce89b WB |
66 | return true; |
67 | } else { | |
68 | return false; | |
69 | } | |
70 | }); | |
71 | } | |
72 | ||
73 | inline void enqueue_strict(Client cl, | |
74 | unsigned priority, | |
11fdf7f2 TL |
75 | Request&& item) override final { |
76 | queue.enqueue_strict(client_info_mgr.osd_op_type(item), | |
77 | priority, | |
78 | std::move(item)); | |
224ce89b WB |
79 | } |
80 | ||
81 | // Enqueue op in the front of the strict queue | |
82 | inline void enqueue_strict_front(Client cl, | |
83 | unsigned priority, | |
11fdf7f2 TL |
84 | Request&& item) override final { |
85 | queue.enqueue_strict_front(client_info_mgr.osd_op_type(item), | |
86 | priority, | |
87 | std::move(item)); | |
224ce89b WB |
88 | } |
89 | ||
90 | // Enqueue op in the back of the regular queue | |
91 | inline void enqueue(Client cl, | |
92 | unsigned priority, | |
93 | unsigned cost, | |
11fdf7f2 TL |
94 | Request&& item) override final { |
95 | queue.enqueue(client_info_mgr.osd_op_type(item), | |
96 | priority, | |
97 | 1u, | |
98 | std::move(item)); | |
224ce89b WB |
99 | } |
100 | ||
101 | // Enqueue the op in the front of the regular queue | |
102 | inline void enqueue_front(Client cl, | |
103 | unsigned priority, | |
104 | unsigned cost, | |
11fdf7f2 TL |
105 | Request&& item) override final { |
106 | queue.enqueue_front(client_info_mgr.osd_op_type(item), | |
107 | priority, | |
108 | 1u, | |
109 | std::move(item)); | |
224ce89b WB |
110 | } |
111 | ||
112 | // Returns if the queue is empty | |
113 | inline bool empty() const override final { | |
114 | return queue.empty(); | |
115 | } | |
116 | ||
117 | // Return an op to be dispatch | |
118 | inline Request dequeue() override final { | |
119 | return queue.dequeue(); | |
120 | } | |
121 | ||
122 | // Formatted output of the queue | |
123 | void dump(ceph::Formatter *f) const override final; | |
224ce89b | 124 | }; // class mClockOpClassAdapter |
224ce89b | 125 | } // namespace ceph |