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"
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"
31 using Request
= OpQueueItem
;
32 using Client
= uint64_t;
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
38 class mClockClientQueue
: public OpQueue
<Request
, Client
> {
40 using osd_op_type_t
= ceph::mclock::osd_op_type_t
;
42 using InnerClient
= std::pair
<uint64_t,osd_op_type_t
>;
44 using queue_t
= mClockQueue
<Request
, InnerClient
>;
48 ceph::mclock::OpClassClientInfoMgr client_info_mgr
;
52 mClockClientQueue(CephContext
*cct
);
54 const crimson::dmclock::ClientInfo
* op_class_client_info_f(const InnerClient
& client
);
56 inline unsigned get_size_slow() const {
57 return queue
.get_size_slow();
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
));
74 void enqueue_strict(Client cl
,
76 Request
&& item
) override final
;
78 // Enqueue op in the front of the strict queue
79 void enqueue_strict_front(Client cl
,
81 Request
&& item
) override final
;
83 // Enqueue op in the back of the regular queue
84 void enqueue(Client cl
,
87 Request
&& item
) override final
;
89 // Enqueue the op in the front of the regular queue
90 void enqueue_front(Client cl
,
93 Request
&& item
) override final
;
95 // Return an op to be dispatch
96 Request
dequeue() override final
;
98 // Returns if the queue is empty
99 inline bool empty() const override final
{
100 return queue
.empty();
103 // Formatted output of the queue
104 void dump(ceph::Formatter
*f
) const override final
;
108 InnerClient
get_inner_client(const Client
& cl
, const Request
& request
);
109 }; // class mClockClientAdapter