]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #pragma once | |
5 | ||
6 | #include "crimson/common/type_helpers.h" | |
7 | #include "crimson/os/seastore/cached_extent.h" | |
8 | #include "crimson/os/seastore/transaction_manager.h" | |
9 | ||
10 | #include "fwd.h" | |
f67539c2 TL |
11 | #include "node_extent_mutable.h" |
12 | #include "node_types.h" | |
20effc67 TL |
13 | #include "stages/node_stage_layout.h" |
14 | #include "super.h" | |
f67539c2 TL |
15 | |
16 | /** | |
17 | * node_extent_manager.h | |
18 | * | |
19 | * Contains general interfaces for different backends (Dummy and Seastore). | |
20 | */ | |
21 | ||
22 | namespace crimson::os::seastore::onode { | |
23 | ||
24 | using crimson::os::seastore::LogicalCachedExtent; | |
25 | class NodeExtent : public LogicalCachedExtent { | |
26 | public: | |
27 | virtual ~NodeExtent() = default; | |
20effc67 TL |
28 | const node_header_t& get_header() const { |
29 | return *reinterpret_cast<const node_header_t*>(get_read()); | |
30 | } | |
f67539c2 TL |
31 | const char* get_read() const { |
32 | return get_bptr().c_str(); | |
33 | } | |
34 | NodeExtentMutable get_mutable() { | |
35 | assert(is_pending()); | |
36 | return do_get_mutable(); | |
37 | } | |
38 | ||
39 | virtual DeltaRecorder* get_recorder() const = 0; | |
40 | virtual NodeExtentRef mutate(context_t, DeltaRecorderURef&&) = 0; | |
41 | ||
42 | protected: | |
43 | template <typename... T> | |
44 | NodeExtent(T&&... t) : LogicalCachedExtent(std::forward<T>(t)...) {} | |
45 | ||
46 | NodeExtentMutable do_get_mutable() { | |
20effc67 TL |
47 | return NodeExtentMutable(get_bptr().c_str(), get_length()); |
48 | } | |
49 | ||
50 | std::ostream& print_detail_l(std::ostream& out) const final { | |
51 | return out << ", fltree_header=" << get_header(); | |
f67539c2 TL |
52 | } |
53 | ||
54 | /** | |
55 | * Abstracted interfaces to implement: | |
56 | * - CacheExtent::duplicate_for_write() -> CachedExtentRef | |
57 | * - CacheExtent::get_type() -> extent_types_t | |
58 | * - CacheExtent::get_delta() -> ceph::bufferlist | |
59 | * - LogicalCachedExtent::apply_delta(const ceph::bufferlist) -> void | |
60 | */ | |
f67539c2 TL |
61 | }; |
62 | ||
63 | using crimson::os::seastore::TransactionManager; | |
64 | class NodeExtentManager { | |
20effc67 | 65 | using base_iertr = TransactionManager::base_iertr; |
f67539c2 TL |
66 | public: |
67 | virtual ~NodeExtentManager() = default; | |
20effc67 TL |
68 | |
69 | virtual bool is_read_isolated() const = 0; | |
70 | ||
71 | using read_iertr = base_iertr::extend< | |
f67539c2 TL |
72 | crimson::ct_error::invarg, |
73 | crimson::ct_error::enoent, | |
74 | crimson::ct_error::erange>; | |
20effc67 TL |
75 | virtual read_iertr::future<NodeExtentRef> read_extent( |
76 | Transaction&, laddr_t) = 0; | |
77 | ||
78 | using alloc_iertr = base_iertr; | |
79 | virtual alloc_iertr::future<NodeExtentRef> alloc_extent( | |
80 | Transaction&, laddr_t hint, extent_len_t) = 0; | |
81 | ||
82 | using retire_iertr = base_iertr::extend< | |
83 | crimson::ct_error::enoent>; | |
84 | virtual retire_iertr::future<> retire_extent( | |
85 | Transaction&, NodeExtentRef) = 0; | |
86 | ||
87 | using getsuper_iertr = base_iertr; | |
88 | virtual getsuper_iertr::future<Super::URef> get_super( | |
89 | Transaction&, RootNodeTracker&) = 0; | |
f67539c2 | 90 | |
f67539c2 TL |
91 | virtual std::ostream& print(std::ostream& os) const = 0; |
92 | ||
93 | static NodeExtentManagerURef create_dummy(bool is_sync); | |
94 | static NodeExtentManagerURef create_seastore( | |
20effc67 | 95 | TransactionManager &tm, laddr_t min_laddr = L_ADDR_MIN, double p_eagain = 0.0); |
f67539c2 TL |
96 | }; |
97 | inline std::ostream& operator<<(std::ostream& os, const NodeExtentManager& nm) { | |
98 | return nm.print(os); | |
99 | } | |
100 | ||
101 | } |