]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #include "Request.h" | |
5 | ||
6 | #define dout_subsys ceph_subsys_rbd_pwl | |
7 | #undef dout_prefix | |
8 | #define dout_prefix *_dout << "librbd::cache::pwl::ssd::Request: " << this << " " \ | |
9 | << __func__ << ": " | |
10 | ||
11 | namespace librbd { | |
12 | namespace cache { | |
13 | namespace pwl { | |
14 | namespace ssd { | |
15 | ||
16 | template <typename T> | |
17 | void C_WriteRequest<T>::setup_buffer_resources( | |
18 | uint64_t *bytes_cached, uint64_t *bytes_dirtied, uint64_t *bytes_allocated, | |
19 | uint64_t *number_lanes, uint64_t *number_log_entries, | |
20 | uint64_t *number_unpublished_reserves) { | |
21 | ||
f67539c2 TL |
22 | *bytes_cached = 0; |
23 | *bytes_allocated = 0; | |
a4b75251 | 24 | *number_log_entries = this->image_extents.size(); |
f67539c2 TL |
25 | |
26 | for (auto &extent : this->image_extents) { | |
27 | *bytes_cached += extent.second; | |
28 | *bytes_allocated += round_up_to(extent.second, MIN_WRITE_ALLOC_SSD_SIZE); | |
29 | } | |
30 | *bytes_dirtied = *bytes_cached; | |
31 | } | |
32 | ||
33 | template <typename T> | |
34 | std::ostream &operator<<(std::ostream &os, | |
35 | const C_CompAndWriteRequest<T> &req) { | |
36 | os << (C_WriteRequest<T>&)req | |
37 | << "cmp_bl=" << req.cmp_bl << ", " | |
38 | << "read_bl=" << req.read_bl << ", " | |
39 | << "compare_succeeded=" << req.compare_succeeded << ", " | |
40 | << "mismatch_offset=" << req.mismatch_offset; | |
41 | return os; | |
42 | } | |
43 | ||
44 | template <typename T> | |
45 | void C_WriteSameRequest<T>::setup_buffer_resources( | |
46 | uint64_t *bytes_cached, uint64_t *bytes_dirtied, uint64_t *bytes_allocated, | |
47 | uint64_t *number_lanes, uint64_t *number_log_entries, | |
48 | uint64_t *number_unpublished_reserves) { | |
49 | ceph_assert(this->image_extents.size() == 1); | |
a4b75251 | 50 | *number_log_entries = 1; |
f67539c2 TL |
51 | *bytes_dirtied = this->image_extents[0].second; |
52 | *bytes_cached = this->bl.length(); | |
53 | *bytes_allocated = round_up_to(*bytes_cached, MIN_WRITE_ALLOC_SSD_SIZE); | |
54 | } | |
55 | ||
56 | } // namespace ssd | |
57 | } // namespace pwl | |
58 | } // namespace cache | |
59 | } // namespace librbd | |
60 | ||
61 | template class librbd::cache::pwl::ssd::C_WriteRequest<librbd::cache::pwl::AbstractWriteLog<librbd::ImageCtx> >; | |
62 | template class librbd::cache::pwl::ssd::C_WriteSameRequest<librbd::cache::pwl::AbstractWriteLog<librbd::ImageCtx> >; | |
63 | template class librbd::cache::pwl::ssd::C_CompAndWriteRequest<librbd::cache::pwl::AbstractWriteLog<librbd::ImageCtx> >; |