]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/os/seastore/cached_extent.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / crimson / os / seastore / cached_extent.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "crimson/os/seastore/cached_extent.h"
5
6 #include "crimson/common/log.h"
7
8 namespace {
9 [[maybe_unused]] seastar::logger& logger() {
10 return crimson::get_logger(ceph_subsys_seastore_tm);
11 }
12 }
13
14 namespace crimson::os::seastore {
15
16 #ifdef DEBUG_CACHED_EXTENT_REF
17
18 void intrusive_ptr_add_ref(CachedExtent *ptr)
19 {
20 intrusive_ptr_add_ref(
21 static_cast<boost::intrusive_ref_counter<
22 CachedExtent,
23 boost::thread_unsafe_counter>*>(ptr));
24 logger().debug("intrusive_ptr_add_ref: {}", *ptr);
25 }
26
27 void intrusive_ptr_release(CachedExtent *ptr)
28 {
29 logger().debug("intrusive_ptr_release: {}", *ptr);
30 intrusive_ptr_release(
31 static_cast<boost::intrusive_ref_counter<
32 CachedExtent,
33 boost::thread_unsafe_counter>*>(ptr));
34 }
35
36 #endif
37
38 std::ostream &operator<<(std::ostream &out, CachedExtent::extent_state_t state)
39 {
40 switch (state) {
41 case CachedExtent::extent_state_t::INITIAL_WRITE_PENDING:
42 return out << "INITIAL_WRITE_PENDING";
43 case CachedExtent::extent_state_t::MUTATION_PENDING:
44 return out << "MUTATION_PENDING";
45 case CachedExtent::extent_state_t::CLEAN_PENDING:
46 return out << "CLEAN_PENDING";
47 case CachedExtent::extent_state_t::CLEAN:
48 return out << "CLEAN";
49 case CachedExtent::extent_state_t::DIRTY:
50 return out << "DIRTY";
51 case CachedExtent::extent_state_t::INVALID:
52 return out << "INVALID";
53 default:
54 return out << "UNKNOWN";
55 }
56 }
57
58 std::ostream &operator<<(std::ostream &out, const CachedExtent &ext)
59 {
60 return ext.print(out);
61 }
62
63 CachedExtent::~CachedExtent()
64 {
65 if (parent_index) {
66 assert(is_linked());
67 parent_index->erase(*this);
68 }
69 }
70
71 std::ostream &LogicalCachedExtent::print_detail(std::ostream &out) const
72 {
73 out << ", laddr=" << laddr;
74 if (pin) {
75 out << ", pin=" << *pin;
76 } else {
77 out << ", pin=empty";
78 }
79 return print_detail_l(out);
80 }
81
82 std::ostream &operator<<(std::ostream &out, const LBAPin &rhs)
83 {
84 return out << "LBAPin(" << rhs.get_laddr() << "~" << rhs.get_length()
85 << "->" << rhs.get_paddr();
86 }
87
88 std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs)
89 {
90 bool first = true;
91 out << '[';
92 for (const auto &i: rhs) {
93 out << (first ? "" : ",") << *i;
94 first = false;
95 }
96 return out << ']';
97 }
98
99 }