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) 2016 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.
20 #include "boost/variant.hpp"
21 #include "boost/container/flat_set.hpp"
23 #include "common/config.h"
24 #include "common/ceph_context.h"
25 #include "common/mClockPriorityQueue.h"
26 #include "osd/OpQueueItem.h"
27 #include "osd/mClockOpClassSupport.h"
32 using Request
= OpQueueItem
;
33 using Client
= uint64_t;
35 // This class exists to bridge the ceph code, which treats the class
36 // as the client, and the queue, where the class is
37 // osd_op_type_t. So this adapter class will transform calls
39 class mClockOpClassQueue
: public OpQueue
<Request
, Client
> {
41 using osd_op_type_t
= ceph::mclock::osd_op_type_t
;
43 using queue_t
= mClockQueue
<Request
, osd_op_type_t
>;
46 ceph::mclock::OpClassClientInfoMgr client_info_mgr
;
50 mClockOpClassQueue(CephContext
*cct
);
52 const crimson::dmclock::ClientInfo
*
53 op_class_client_info_f(const osd_op_type_t
& op_type
);
55 inline unsigned get_size_slow() const {
56 return queue
.get_size_slow();
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(
63 [&cl
, out
] (Request
&& r
) -> bool {
64 if (cl
== r
.get_owner()) {
65 out
->push_front(std::move(r
));
73 inline void enqueue_strict(Client cl
,
75 Request
&& item
) override final
{
76 queue
.enqueue_strict(client_info_mgr
.osd_op_type(item
),
81 // Enqueue op in the front of the strict queue
82 inline void enqueue_strict_front(Client cl
,
84 Request
&& item
) override final
{
85 queue
.enqueue_strict_front(client_info_mgr
.osd_op_type(item
),
90 // Enqueue op in the back of the regular queue
91 inline void enqueue(Client cl
,
94 Request
&& item
) override final
{
95 queue
.enqueue(client_info_mgr
.osd_op_type(item
),
101 // Enqueue the op in the front of the regular queue
102 inline void enqueue_front(Client cl
,
105 Request
&& item
) override final
{
106 queue
.enqueue_front(client_info_mgr
.osd_op_type(item
),
112 // Returns if the queue is empty
113 inline bool empty() const override final
{
114 return queue
.empty();
117 // Return an op to be dispatch
118 inline Request
dequeue() override final
{
119 return queue
.dequeue();
122 // Formatted output of the queue
123 void dump(ceph::Formatter
*f
) const override final
;
124 }; // class mClockOpClassAdapter