]>
git.proxmox.com Git - ceph.git/blob - ceph/src/os/filestore/JournalThrottle.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "JournalThrottle.h"
5 #include "include/assert.h"
7 bool JournalThrottle::set_params(
8 double _low_threshhold
,
9 double _high_threshhold
,
10 double _expected_throughput
,
11 double _high_multiple
,
13 uint64_t _throttle_max
,
14 std::ostream
*errstream
)
16 return throttle
.set_params(
26 std::chrono::duration
<double> JournalThrottle::get(uint64_t c
)
28 return throttle
.get(c
);
31 uint64_t JournalThrottle::take(uint64_t c
)
33 return throttle
.take(c
);
36 void JournalThrottle::register_throttle_seq(uint64_t seq
, uint64_t c
)
39 journaled_ops
.push_back(std::make_pair(seq
, c
));
42 std::pair
<uint64_t, uint64_t> JournalThrottle::flush(uint64_t mono_id
)
44 uint64_t to_put_bytes
= 0;
45 uint64_t to_put_ops
= 0;
48 while (!journaled_ops
.empty() &&
49 journaled_ops
.front().first
<= mono_id
) {
50 to_put_bytes
+= journaled_ops
.front().second
;
52 journaled_ops
.pop_front();
55 throttle
.put(to_put_bytes
);
56 return make_pair(to_put_ops
, to_put_bytes
);
59 uint64_t JournalThrottle::get_current()
61 return throttle
.get_current();
64 uint64_t JournalThrottle::get_max()
66 return throttle
.get_max();