summaryrefslogtreecommitdiffstats
path: root/src/crimson/os/seastore/onode_manager/staged-fltree/node_impl.cc
blob: 59d792b1a4ea6e083c3e150a674e630386de0495 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
// vim: ts=8 sw=2 smarttab

#include "node_impl.h"
#include "node_layout.h"

namespace crimson::os::seastore::onode {

#ifdef UNIT_TESTS_BUILT
last_split_info_t last_split = {};
#endif

// XXX: branchless allocation
InternalNodeImpl::alloc_ertr::future<InternalNodeImpl::fresh_impl_t>
InternalNodeImpl::allocate(
    context_t c, field_type_t type, bool is_level_tail, level_t level) {
  if (type == field_type_t::N0) {
    return InternalNode0::allocate(c, is_level_tail, level);
  } else if (type == field_type_t::N1) {
    return InternalNode1::allocate(c, is_level_tail, level);
  } else if (type == field_type_t::N2) {
    return InternalNode2::allocate(c, is_level_tail, level);
  } else if (type == field_type_t::N3) {
    return InternalNode3::allocate(c, is_level_tail, level);
  } else {
    ceph_abort("impossible path");
  }
}

LeafNodeImpl::alloc_ertr::future<LeafNodeImpl::fresh_impl_t>
LeafNodeImpl::allocate(
    context_t c, field_type_t type, bool is_level_tail) {
  if (type == field_type_t::N0) {
    return LeafNode0::allocate(c, is_level_tail, 0);
  } else if (type == field_type_t::N1) {
    return LeafNode1::allocate(c, is_level_tail, 0);
  } else if (type == field_type_t::N2) {
    return LeafNode2::allocate(c, is_level_tail, 0);
  } else if (type == field_type_t::N3) {
    return LeafNode3::allocate(c, is_level_tail, 0);
  } else {
    ceph_abort("impossible path");
  }
}

InternalNodeImplURef InternalNodeImpl::load(
    NodeExtentRef extent, field_type_t type, bool expect_is_level_tail) {
  if (type == field_type_t::N0) {
    return InternalNode0::load(extent, expect_is_level_tail);
  } else if (type == field_type_t::N1) {
    return InternalNode1::load(extent, expect_is_level_tail);
  } else if (type == field_type_t::N2) {
    return InternalNode2::load(extent, expect_is_level_tail);
  } else if (type == field_type_t::N3) {
    return InternalNode3::load(extent, expect_is_level_tail);
  } else {
    ceph_abort("impossible path");
  }
}

LeafNodeImplURef LeafNodeImpl::load(
    NodeExtentRef extent, field_type_t type, bool expect_is_level_tail) {
  if (type == field_type_t::N0) {
    return LeafNode0::load(extent, expect_is_level_tail);
  } else if (type == field_type_t::N1) {
    return LeafNode1::load(extent, expect_is_level_tail);
  } else if (type == field_type_t::N2) {
    return LeafNode2::load(extent, expect_is_level_tail);
  } else if (type == field_type_t::N3) {
    return LeafNode3::load(extent, expect_is_level_tail);
  } else {
    ceph_abort("impossible path");
  }
}

}