]>
git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/osd/osd_operation.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
6 #include "crimson/common/operation.h"
7 #include "crimson/osd/pg_interval_interrupt_condition.h"
8 #include "crimson/osd/scheduler/scheduler.h"
9 #include "osd/osd_types.h"
11 namespace crimson::osd
{
13 enum class OperationTypeCode
{
16 compound_peering_request
,
21 background_recovery_sub
,
22 internal_client_request
,
26 static constexpr const char* const OP_NAMES
[] = {
29 "compound_peering_request",
33 "background_recovery",
34 "background_recovery_sub",
35 "internal_client_request",
38 // prevent the addition of OperationTypeCode-s with no matching OP_NAMES entry:
40 (sizeof(OP_NAMES
)/sizeof(OP_NAMES
[0])) ==
41 static_cast<int>(OperationTypeCode::last_op
));
43 struct InterruptibleOperation
: Operation
{
44 template <typename ValuesT
= void>
45 using interruptible_future
=
46 ::crimson::interruptible::interruptible_future
<
47 ::crimson::osd::IOInterruptCondition
, ValuesT
>;
49 ::crimson::interruptible::interruptor
<
50 ::crimson::osd::IOInterruptCondition
>;
54 class OperationT
: public InterruptibleOperation
{
56 static constexpr const char *type_name
= OP_NAMES
[static_cast<int>(T::type
)];
57 using IRef
= boost::intrusive_ptr
<T
>;
59 unsigned get_type() const final
{
60 return static_cast<unsigned>(T::type
);
63 const char *get_type_name() const final
{
67 virtual ~OperationT() = default;
70 virtual void dump_detail(ceph::Formatter
*f
) const = 0;
74 * Maintains a set of lists of all active ops.
76 using OSDOperationRegistry
= OperationRegistryT
<
77 static_cast<size_t>(OperationTypeCode::last_op
)
81 * Throttles set of currently running operations
83 * Very primitive currently, assumes all ops are equally
84 * expensive and simply limits the number that can be
85 * concurrently active.
87 class OperationThrottler
: public Blocker
,
88 private md_config_obs_t
{
90 OperationThrottler(ConfigProxy
&conf
);
92 const char** get_tracked_conf_keys() const final
;
93 void handle_conf_change(const ConfigProxy
& conf
,
94 const std::set
<std::string
> &changed
) final
;
95 void update_from_config(const ConfigProxy
&conf
);
100 crimson::osd::scheduler::params_t params
,
102 if (!max_in_progress
) return f();
103 auto fut
= acquire_throttle(params
);
104 return op
->with_blocking_future(std::move(fut
))
105 .then(std::forward
<F
>(f
))
106 .then([this](auto x
) {
112 template <typename F
>
113 seastar::future
<> with_throttle_while(
115 crimson::osd::scheduler::params_t params
,
117 return with_throttle(op
, params
, f
).then([this, params
, op
, f
](bool cont
) {
119 return with_throttle_while(op
, params
, f
);
121 return seastar::make_ready_future
<>();
126 void dump_detail(Formatter
*f
) const final
;
127 const char *get_type_name() const final
{
128 return "OperationThrottler";
132 crimson::osd::scheduler::SchedulerRef scheduler
;
134 uint64_t max_in_progress
= 0;
135 uint64_t in_progress
= 0;
137 uint64_t pending
= 0;
141 blocking_future
<> acquire_throttle(
142 crimson::osd::scheduler::params_t params
);
144 void release_throttle();