]>
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 | #include "node_impl.h" | |
5 | #include "node_layout.h" | |
6 | ||
7 | namespace crimson::os::seastore::onode { | |
8 | ||
9 | #ifdef UNIT_TESTS_BUILT | |
10 | last_split_info_t last_split = {}; | |
11 | #endif | |
12 | ||
13 | // XXX: branchless allocation | |
20effc67 | 14 | eagain_ifuture<InternalNodeImpl::fresh_impl_t> |
f67539c2 | 15 | InternalNodeImpl::allocate( |
20effc67 TL |
16 | context_t c, laddr_t hint, field_type_t type, bool is_level_tail, level_t level) |
17 | { | |
f67539c2 | 18 | if (type == field_type_t::N0) { |
20effc67 | 19 | return InternalNode0::allocate(c, hint, is_level_tail, level); |
f67539c2 | 20 | } else if (type == field_type_t::N1) { |
20effc67 | 21 | return InternalNode1::allocate(c, hint, is_level_tail, level); |
f67539c2 | 22 | } else if (type == field_type_t::N2) { |
20effc67 | 23 | return InternalNode2::allocate(c, hint, is_level_tail, level); |
f67539c2 | 24 | } else if (type == field_type_t::N3) { |
20effc67 | 25 | return InternalNode3::allocate(c, hint, is_level_tail, level); |
f67539c2 TL |
26 | } else { |
27 | ceph_abort("impossible path"); | |
28 | } | |
29 | } | |
30 | ||
20effc67 | 31 | eagain_ifuture<LeafNodeImpl::fresh_impl_t> |
f67539c2 | 32 | LeafNodeImpl::allocate( |
20effc67 TL |
33 | context_t c, laddr_t hint, field_type_t type, bool is_level_tail) |
34 | { | |
f67539c2 | 35 | if (type == field_type_t::N0) { |
20effc67 | 36 | return LeafNode0::allocate(c, hint, is_level_tail, 0); |
f67539c2 | 37 | } else if (type == field_type_t::N1) { |
20effc67 | 38 | return LeafNode1::allocate(c, hint, is_level_tail, 0); |
f67539c2 | 39 | } else if (type == field_type_t::N2) { |
20effc67 | 40 | return LeafNode2::allocate(c, hint, is_level_tail, 0); |
f67539c2 | 41 | } else if (type == field_type_t::N3) { |
20effc67 | 42 | return LeafNode3::allocate(c, hint, is_level_tail, 0); |
f67539c2 TL |
43 | } else { |
44 | ceph_abort("impossible path"); | |
45 | } | |
46 | } | |
47 | ||
48 | InternalNodeImplURef InternalNodeImpl::load( | |
20effc67 TL |
49 | NodeExtentRef extent, field_type_t type) |
50 | { | |
f67539c2 | 51 | if (type == field_type_t::N0) { |
20effc67 | 52 | return InternalNode0::load(extent); |
f67539c2 | 53 | } else if (type == field_type_t::N1) { |
20effc67 | 54 | return InternalNode1::load(extent); |
f67539c2 | 55 | } else if (type == field_type_t::N2) { |
20effc67 | 56 | return InternalNode2::load(extent); |
f67539c2 | 57 | } else if (type == field_type_t::N3) { |
20effc67 | 58 | return InternalNode3::load(extent); |
f67539c2 TL |
59 | } else { |
60 | ceph_abort("impossible path"); | |
61 | } | |
62 | } | |
63 | ||
64 | LeafNodeImplURef LeafNodeImpl::load( | |
20effc67 TL |
65 | NodeExtentRef extent, field_type_t type) |
66 | { | |
f67539c2 | 67 | if (type == field_type_t::N0) { |
20effc67 | 68 | return LeafNode0::load(extent); |
f67539c2 | 69 | } else if (type == field_type_t::N1) { |
20effc67 | 70 | return LeafNode1::load(extent); |
f67539c2 | 71 | } else if (type == field_type_t::N2) { |
20effc67 | 72 | return LeafNode2::load(extent); |
f67539c2 | 73 | } else if (type == field_type_t::N3) { |
20effc67 | 74 | return LeafNode3::load(extent); |
f67539c2 TL |
75 | } else { |
76 | ceph_abort("impossible path"); | |
77 | } | |
78 | } | |
79 | ||
80 | } |