]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/os/seastore/onode_manager/staged-fltree/node_layout_replayable.h
c1499d6093db0bb3d732a764714a4aecf68ea714
[ceph.git] / ceph / src / crimson / os / seastore / onode_manager / staged-fltree / node_layout_replayable.h
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 "node_extent_mutable.h"
7 #include "stages/node_stage.h"
8 #include "stages/stage.h"
9
10 #define STAGE_T node_to_stage_t<node_stage_t>
11
12 namespace crimson::os::seastore::onode {
13
14 /**
15 * NodeLayoutReplayableT
16 *
17 * Contains templated logics to modify the layout of a NodeExtend which are
18 * also replayable. Used by NodeExtentAccessorT at runtime and by
19 * DeltaRecorderT during replay.
20 */
21 template <typename FieldType, node_type_t NODE_TYPE>
22 struct NodeLayoutReplayableT {
23 using node_stage_t = node_extent_t<FieldType, NODE_TYPE>;
24 using position_t = typename STAGE_T::position_t;
25 using StagedIterator = typename STAGE_T::StagedIterator;
26 using value_t = value_type_t<NODE_TYPE>;
27 static constexpr auto FIELD_TYPE = FieldType::FIELD_TYPE;
28
29 template <KeyT KT>
30 static const value_t* insert(
31 NodeExtentMutable& mut,
32 const node_stage_t& node_stage,
33 const full_key_t<KT>& key,
34 const value_t& value,
35 position_t& insert_pos,
36 match_stage_t& insert_stage,
37 node_offset_t& insert_size) {
38 auto p_value = STAGE_T::template proceed_insert<KT, false>(
39 mut, node_stage, key, value, insert_pos, insert_stage, insert_size);
40 return p_value;
41 }
42
43 static void split(
44 NodeExtentMutable& mut,
45 const node_stage_t& node_stage,
46 StagedIterator& split_at) {
47 node_stage_t::update_is_level_tail(mut, node_stage, false);
48 STAGE_T::trim(mut, split_at);
49 }
50
51 template <KeyT KT>
52 static const value_t* split_insert(
53 NodeExtentMutable& mut,
54 const node_stage_t& node_stage,
55 StagedIterator& split_at,
56 const full_key_t<KT>& key,
57 const value_t& value,
58 position_t& insert_pos,
59 match_stage_t& insert_stage,
60 node_offset_t& insert_size) {
61 node_stage_t::update_is_level_tail(mut, node_stage, false);
62 STAGE_T::trim(mut, split_at);
63 auto p_value = STAGE_T::template proceed_insert<KT, true>(
64 mut, node_stage, key, value, insert_pos, insert_stage, insert_size);
65 return p_value;
66 }
67
68 static void update_child_addr(
69 NodeExtentMutable& mut, const laddr_t new_addr, laddr_packed_t* p_addr) {
70 assert(NODE_TYPE == node_type_t::INTERNAL);
71 mut.copy_in_absolute(p_addr, new_addr);
72 }
73 };
74
75 }