From: Yingxin Cheng Date: Thu, 21 Jan 2021 05:56:17 +0000 (+0800) Subject: crimson/onode-staged-tree: cleanup, reformat .cc files X-Git-Tag: v17.1.0~3086^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=577ea6f9b3079dccb3a90506a044de893e343531;p=ceph.git crimson/onode-staged-tree: cleanup, reformat .cc files Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/node.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/node.cc index 5e13fe72cf5e..1d04c77bfec3 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node.cc @@ -14,9 +14,12 @@ #include "stages/node_stage_layout.h" namespace { - seastar::logger& logger() { - return crimson::get_logger(ceph_subsys_filestore); - } + +seastar::logger& logger() +{ + return crimson::get_logger(ceph_subsys_filestore); +} + } namespace crimson::os::seastore::onode { @@ -30,7 +33,8 @@ using node_future = Node::node_future; */ tree_cursor_t::tree_cursor_t(Ref node, const search_position_t& pos) - : ref_leaf_node{node}, position{pos} { + : ref_leaf_node{node}, position{pos} +{ assert(!is_end()); ref_leaf_node->do_track_cursor(*this); } @@ -38,35 +42,41 @@ tree_cursor_t::tree_cursor_t(Ref node, const search_position_t& pos) tree_cursor_t::tree_cursor_t( Ref node, const search_position_t& pos, const key_view_t& key_view, const value_header_t* p_value_header) - : ref_leaf_node{node}, position{pos} { + : ref_leaf_node{node}, position{pos} +{ assert(!is_end()); update_cache(*node, key_view, p_value_header); ref_leaf_node->do_track_cursor(*this); } tree_cursor_t::tree_cursor_t(Ref node) - : ref_leaf_node{node}, position{search_position_t::end()} { + : ref_leaf_node{node}, position{search_position_t::end()} +{ assert(is_end()); assert(ref_leaf_node->is_level_tail()); } -tree_cursor_t::~tree_cursor_t() { +tree_cursor_t::~tree_cursor_t() +{ if (!is_end()) { ref_leaf_node->do_untrack_cursor(*this); } } -node_future<> tree_cursor_t::extend_value(context_t c, value_size_t extend_size) { +node_future<> tree_cursor_t::extend_value(context_t c, value_size_t extend_size) +{ return ref_leaf_node->extend_value(c, position, extend_size); } -node_future<> tree_cursor_t::trim_value(context_t c, value_size_t trim_size) { +node_future<> tree_cursor_t::trim_value(context_t c, value_size_t trim_size) +{ return ref_leaf_node->trim_value(c, position, trim_size); } template void tree_cursor_t::update_track( - Ref node, const search_position_t& pos) { + Ref node, const search_position_t& pos) +{ // the cursor must be already untracked // track the new node and new pos assert(!pos.is_end()); @@ -81,14 +91,16 @@ template void tree_cursor_t::update_track(Ref, const search_pos void tree_cursor_t::update_cache(LeafNode& node, const key_view_t& key_view, - const value_header_t* p_value_header) const { + const value_header_t* p_value_header) const +{ assert(!is_end()); assert(ref_leaf_node.get() == &node); cache.update(node, key_view, p_value_header); cache.validate_is_latest(node, position); } -void tree_cursor_t::maybe_update_cache(value_magic_t magic) const { +void tree_cursor_t::maybe_update_cache(value_magic_t magic) const +{ assert(!is_end()); if (!cache.is_latest()) { auto [key_view, p_value_header] = ref_leaf_node->get_kv(position); @@ -104,13 +116,15 @@ void tree_cursor_t::maybe_update_cache(value_magic_t magic) const { tree_cursor_t::Cache::Cache() = default; -bool tree_cursor_t::Cache::is_latest() const { +bool tree_cursor_t::Cache::is_latest() const +{ return (valid && (version == p_leaf_node->get_layout_version())); } void tree_cursor_t::Cache::update(LeafNode& node, const key_view_t& _key_view, - const value_header_t* _p_value_header) { + const value_header_t* _p_value_header) +{ assert(_p_value_header); p_leaf_node = &node; version = node.get_layout_version(); @@ -123,7 +137,8 @@ void tree_cursor_t::Cache::update(LeafNode& node, } void tree_cursor_t::Cache::validate_is_latest(const LeafNode& node, - const search_position_t& pos) const { + const search_position_t& pos) const +{ assert(p_leaf_node == &node); assert(is_latest()); #ifndef NDEBUG @@ -134,7 +149,8 @@ void tree_cursor_t::Cache::validate_is_latest(const LeafNode& node, } std::pair -tree_cursor_t::Cache::prepare_mutate_value_payload(context_t c) { +tree_cursor_t::Cache::prepare_mutate_value_payload(context_t c) +{ assert(is_latest()); assert(p_leaf_node && p_value_header); assert(p_value_header->magic == c.vb.get_header_magic()); @@ -152,7 +168,8 @@ tree_cursor_t::Cache::prepare_mutate_value_payload(context_t c) { Node::Node(NodeImplURef&& impl) : impl{std::move(impl)} {} -Node::~Node() { +Node::~Node() +{ // XXX: tolerate failure between allocate() and as_child() if (is_root()) { super->do_untrack_root(*this); @@ -161,12 +178,14 @@ Node::~Node() { } } -level_t Node::level() const { +level_t Node::level() const +{ return impl->level(); } node_future Node::lower_bound( - context_t c, const key_hobj_t& key) { + context_t c, const key_hobj_t& key) +{ return seastar::do_with( MatchHistory(), [this, c, &key](auto& history) { return lower_bound_tracked(c, key, history); @@ -175,7 +194,8 @@ node_future Node::lower_bound( } node_future, bool>> Node::insert( - context_t c, const key_hobj_t& key, value_config_t vconf) { + context_t c, const key_hobj_t& key, value_config_t vconf) +{ return seastar::do_with( MatchHistory(), [this, c, &key, vconf](auto& history) { return lower_bound_tracked(c, key, history @@ -197,7 +217,8 @@ node_future, bool>> Node::insert( ); } -node_future Node::get_tree_stats(context_t c) { +node_future Node::get_tree_stats(context_t c) +{ return seastar::do_with( tree_stats_t(), [this, c](auto& stats) { return do_get_tree_stats(c, stats).safe_then([&stats] { @@ -207,26 +228,31 @@ node_future Node::get_tree_stats(context_t c) { ); } -std::ostream& Node::dump(std::ostream& os) const { +std::ostream& Node::dump(std::ostream& os) const +{ return impl->dump(os); } -std::ostream& Node::dump_brief(std::ostream& os) const { +std::ostream& Node::dump_brief(std::ostream& os) const +{ return impl->dump_brief(os); } void Node::test_make_destructable( - context_t c, NodeExtentMutable& mut, Super::URef&& _super) { + context_t c, NodeExtentMutable& mut, Super::URef&& _super) +{ impl->test_set_tail(mut); make_root(c, std::move(_super)); } -node_future<> Node::mkfs(context_t c, RootNodeTracker& root_tracker) { +node_future<> Node::mkfs(context_t c, RootNodeTracker& root_tracker) +{ return LeafNode::allocate_root(c, root_tracker ).safe_then([](auto ret) { /* FIXME: discard_result(); */ }); } -node_future> Node::load_root(context_t c, RootNodeTracker& root_tracker) { +node_future> Node::load_root(context_t c, RootNodeTracker& root_tracker) +{ return c.nm.get_super(c.t, root_tracker ).safe_then([c, &root_tracker](auto&& _super) { auto root_addr = _super->get_root_laddr(); @@ -244,12 +270,14 @@ node_future> Node::load_root(context_t c, RootNodeTracker& root_tracke }); } -void Node::make_root(context_t c, Super::URef&& _super) { +void Node::make_root(context_t c, Super::URef&& _super) +{ _super->write_root_laddr(c, impl->laddr()); as_root(std::move(_super)); } -void Node::as_root(Super::URef&& _super) { +void Node::as_root(Super::URef&& _super) +{ assert(!super && !_parent_info); assert(_super->get_root_laddr() == impl->laddr()); assert(impl->is_level_tail()); @@ -257,7 +285,8 @@ void Node::as_root(Super::URef&& _super) { super->do_track_root(*this); } -node_future<> Node::upgrade_root(context_t c) { +node_future<> Node::upgrade_root(context_t c) +{ assert(is_root()); assert(impl->is_level_tail()); assert(impl->field_type() == field_type_t::N0); @@ -269,7 +298,8 @@ node_future<> Node::upgrade_root(context_t c) { } template -void Node::as_child(const search_position_t& pos, Ref parent_node) { +void Node::as_child(const search_position_t& pos, Ref parent_node) +{ assert(!super); _parent_info = parent_info_t{pos, parent_node}; parent_info().ptr->do_track_child(*this); @@ -277,7 +307,8 @@ void Node::as_child(const search_position_t& pos, Ref parent_node) template void Node::as_child(const search_position_t&, Ref); template void Node::as_child(const search_position_t&, Ref); -node_future<> Node::insert_parent(context_t c, Ref right_node) { +node_future<> Node::insert_parent(context_t c, Ref right_node) +{ assert(!is_root()); // TODO(cross-node string dedup) return parent_info().ptr->apply_child_split( @@ -285,7 +316,8 @@ node_future<> Node::insert_parent(context_t c, Ref right_node) { } node_future> Node::load( - context_t c, laddr_t addr, bool expect_is_level_tail) { + context_t c, laddr_t addr, bool expect_is_level_tail) +{ // NOTE: // *option1: all types of node have the same length; // option2: length is defined by node/field types; @@ -314,7 +346,8 @@ InternalNode::InternalNode(InternalNodeImpl* impl, NodeImplURef&& impl_ref) node_future<> InternalNode::apply_child_split( context_t c, const search_position_t& pos, - Ref left_child, Ref right_child) { + Ref left_child, Ref right_child) +{ #ifndef NDEBUG if (pos.is_end()) { assert(impl->is_level_tail()); @@ -380,7 +413,8 @@ node_future<> InternalNode::apply_child_split( node_future> InternalNode::allocate_root( context_t c, level_t old_root_level, - laddr_t old_root_addr, Super::URef&& super) { + laddr_t old_root_addr, Super::URef&& super) +{ return InternalNode::allocate(c, field_type_t::N0, true, old_root_level + 1 ).safe_then([c, old_root_addr, super = std::move(super)](auto fresh_node) mutable { @@ -394,7 +428,8 @@ node_future> InternalNode::allocate_root( } node_future> -InternalNode::lookup_smallest(context_t c) { +InternalNode::lookup_smallest(context_t c) +{ auto position = search_position_t::begin(); laddr_t child_addr = impl->get_p_value(position)->value; return get_or_track_child(c, position, child_addr @@ -404,7 +439,8 @@ InternalNode::lookup_smallest(context_t c) { } node_future> -InternalNode::lookup_largest(context_t c) { +InternalNode::lookup_largest(context_t c) +{ // NOTE: unlike LeafNode::lookup_largest(), this only works for the tail // internal node to return the tail child address. auto position = search_position_t::end(); @@ -416,7 +452,8 @@ InternalNode::lookup_largest(context_t c) { node_future InternalNode::lower_bound_tracked( - context_t c, const key_hobj_t& key, MatchHistory& history) { + context_t c, const key_hobj_t& key, MatchHistory& history) +{ auto result = impl->lower_bound(key, history); return get_or_track_child(c, result.position, result.p_value->value ).safe_then([c, &key, &history](auto child) { @@ -426,7 +463,8 @@ InternalNode::lower_bound_tracked( } node_future<> InternalNode::do_get_tree_stats( - context_t c, tree_stats_t& stats) { + context_t c, tree_stats_t& stats) +{ auto nstats = impl->get_stats(); stats.size_persistent_internal += nstats.size_persistent; stats.size_filled_internal += nstats.size_filled; @@ -468,7 +506,8 @@ node_future<> InternalNode::do_get_tree_stats( } node_future<> InternalNode::test_clone_root( - context_t c_other, RootNodeTracker& tracker_other) const { + context_t c_other, RootNodeTracker& tracker_other) const +{ assert(is_root()); assert(impl->is_level_tail()); assert(impl->field_type() == field_type_t::N0); @@ -498,7 +537,8 @@ node_future<> InternalNode::test_clone_root( } node_future> InternalNode::get_or_track_child( - context_t c, const search_position_t& position, laddr_t child_addr) { + context_t c, const search_position_t& position, laddr_t child_addr) +{ bool level_tail = position.is_end(); Ref child; auto found = tracked_child_nodes.find(position); @@ -526,7 +566,8 @@ node_future> InternalNode::get_or_track_child( void InternalNode::track_insert( const search_position_t& insert_pos, match_stage_t insert_stage, - Ref insert_child, Ref nxt_child) { + Ref insert_child, Ref nxt_child) +{ // update tracks auto pos_upper_bound = insert_pos; pos_upper_bound.index_by_stage(insert_stage) = INDEX_UPPER_BOUND; @@ -557,7 +598,8 @@ void InternalNode::track_insert( } void InternalNode::replace_track( - const search_position_t& position, Ref new_child, Ref old_child) { + const search_position_t& position, Ref new_child, Ref old_child) +{ assert(tracked_child_nodes[position] == old_child); tracked_child_nodes.erase(position); new_child->as_child(position, this); @@ -565,7 +607,8 @@ void InternalNode::replace_track( } void InternalNode::track_split( - const search_position_t& split_pos, Ref right_node) { + const search_position_t& split_pos, Ref right_node) +{ auto first = tracked_child_nodes.lower_bound(split_pos); auto iter = first; while (iter != tracked_child_nodes.end()) { @@ -577,7 +620,8 @@ void InternalNode::track_split( tracked_child_nodes.erase(first, tracked_child_nodes.end()); } -void InternalNode::validate_child(const Node& child) const { +void InternalNode::validate_child(const Node& child) const +{ #ifndef NDEBUG assert(impl->level() - 1 == child.impl->level()); assert(this == child.parent_info().ptr); @@ -596,7 +640,8 @@ void InternalNode::validate_child(const Node& child) const { } node_future InternalNode::allocate( - context_t c, field_type_t field_type, bool is_level_tail, level_t level) { + context_t c, field_type_t field_type, bool is_level_tail, level_t level) +{ return InternalNodeImpl::allocate(c, field_type, is_level_tail, level ).safe_then([](auto&& fresh_impl) { auto node = Ref(new InternalNode( @@ -612,36 +657,42 @@ node_future InternalNode::allocate( LeafNode::LeafNode(LeafNodeImpl* impl, NodeImplURef&& impl_ref) : Node(std::move(impl_ref)), impl{impl} {} -bool LeafNode::is_level_tail() const { +bool LeafNode::is_level_tail() const +{ return impl->is_level_tail(); } std::tuple -LeafNode::get_kv(const search_position_t& pos) const { +LeafNode::get_kv(const search_position_t& pos) const +{ key_view_t key_view; auto p_value_header = impl->get_p_value(pos, &key_view); return {key_view, p_value_header}; } node_future<> LeafNode::extend_value( - context_t c, const search_position_t& pos, value_size_t extend_size) { + context_t c, const search_position_t& pos, value_size_t extend_size) +{ ceph_abort("not implemented"); return node_ertr::now(); } node_future<> LeafNode::trim_value( - context_t c, const search_position_t& pos, value_size_t trim_size) { + context_t c, const search_position_t& pos, value_size_t trim_size) +{ ceph_abort("not implemented"); return node_ertr::now(); } std::pair -LeafNode::prepare_mutate_value_payload(context_t c) { +LeafNode::prepare_mutate_value_payload(context_t c) +{ return impl->prepare_mutate_value_payload(c); } node_future> -LeafNode::lookup_smallest(context_t) { +LeafNode::lookup_smallest(context_t) +{ if (unlikely(impl->is_empty())) { assert(is_root()); return node_ertr::make_ready_future>( @@ -655,7 +706,8 @@ LeafNode::lookup_smallest(context_t) { } node_future> -LeafNode::lookup_largest(context_t) { +LeafNode::lookup_largest(context_t) +{ if (unlikely(impl->is_empty())) { assert(is_root()); return node_ertr::make_ready_future>( @@ -671,7 +723,8 @@ LeafNode::lookup_largest(context_t) { node_future LeafNode::lower_bound_tracked( - context_t c, const key_hobj_t& key, MatchHistory& history) { + context_t c, const key_hobj_t& key, MatchHistory& history) +{ key_view_t index_key; auto result = impl->lower_bound(key, history, &index_key); Ref cursor; @@ -685,7 +738,8 @@ LeafNode::lower_bound_tracked( search_result_t{cursor, result.mstat}); } -node_future<> LeafNode::do_get_tree_stats(context_t, tree_stats_t& stats) { +node_future<> LeafNode::do_get_tree_stats(context_t, tree_stats_t& stats) +{ auto nstats = impl->get_stats(); stats.size_persistent_leaf += nstats.size_persistent; stats.size_filled_leaf += nstats.size_filled; @@ -698,7 +752,8 @@ node_future<> LeafNode::do_get_tree_stats(context_t, tree_stats_t& stats) { } node_future<> LeafNode::test_clone_root( - context_t c_other, RootNodeTracker& tracker_other) const { + context_t c_other, RootNodeTracker& tracker_other) const +{ assert(is_root()); assert(impl->is_level_tail()); assert(impl->field_type() == field_type_t::N0); @@ -717,7 +772,8 @@ node_future<> LeafNode::test_clone_root( node_future> LeafNode::insert_value( context_t c, const key_hobj_t& key, value_config_t vconf, const search_position_t& pos, const MatchHistory& history, - match_stat_t mstat) { + match_stat_t mstat) +{ #ifndef NDEBUG if (pos.is_end()) { assert(impl->is_level_tail()); @@ -777,7 +833,8 @@ node_future> LeafNode::insert_value( } node_future> LeafNode::allocate_root( - context_t c, RootNodeTracker& root_tracker) { + context_t c, RootNodeTracker& root_tracker) +{ return LeafNode::allocate(c, field_type_t::N0, true ).safe_then([c, &root_tracker](auto fresh_node) { auto root = fresh_node.node; @@ -791,7 +848,8 @@ node_future> LeafNode::allocate_root( Ref LeafNode::get_or_track_cursor( const search_position_t& position, - const key_view_t& key, const value_header_t* p_value_header) { + const key_view_t& key, const value_header_t* p_value_header) +{ assert(!position.is_end()); assert(p_value_header); Ref p_cursor; @@ -807,7 +865,8 @@ Ref LeafNode::get_or_track_cursor( return p_cursor; } -void LeafNode::validate_cursor(tree_cursor_t& cursor) const { +void LeafNode::validate_cursor(tree_cursor_t& cursor) const +{ #ifndef NDEBUG assert(this == cursor.get_leaf_node().get()); assert(!cursor.is_end()); @@ -820,7 +879,8 @@ void LeafNode::validate_cursor(tree_cursor_t& cursor) const { Ref LeafNode::track_insert( const search_position_t& insert_pos, match_stage_t insert_stage, - const value_header_t* p_value_header) { + const value_header_t* p_value_header) +{ // update cursor position auto pos_upper_bound = insert_pos; pos_upper_bound.index_by_stage(insert_stage) = INDEX_UPPER_BOUND; @@ -844,7 +904,8 @@ Ref LeafNode::track_insert( } void LeafNode::track_split( - const search_position_t& split_pos, Ref right_node) { + const search_position_t& split_pos, Ref right_node) +{ // update cursor ownership and position auto first = tracked_cursors.lower_bound(split_pos); auto iter = first; @@ -858,7 +919,8 @@ void LeafNode::track_split( } node_future LeafNode::allocate( - context_t c, field_type_t field_type, bool is_level_tail) { + context_t c, field_type_t field_type, bool is_level_tail) +{ return LeafNodeImpl::allocate(c, field_type, is_level_tail ).safe_then([](auto&& fresh_impl) { auto node = Ref(new LeafNode( diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager.cc index bd22d4b67512..c379aad3139b 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager.cc @@ -9,7 +9,8 @@ namespace crimson::os::seastore::onode { -std::pair NodeExtent::get_types() const { +std::pair NodeExtent::get_types() const +{ const auto header = reinterpret_cast(get_read()); auto node_type = header->get_node_type(); auto field_type = header->get_field_type(); @@ -19,7 +20,8 @@ std::pair NodeExtent::get_types() const { return {node_type, *field_type}; } -NodeExtentManagerURef NodeExtentManager::create_dummy(bool is_sync) { +NodeExtentManagerURef NodeExtentManager::create_dummy(bool is_sync) +{ if (is_sync) { return NodeExtentManagerURef(new DummyNodeExtentManager()); } else { @@ -28,7 +30,8 @@ NodeExtentManagerURef NodeExtentManager::create_dummy(bool is_sync) { } NodeExtentManagerURef NodeExtentManager::create_seastore( - TransactionManager& tm, laddr_t min_laddr) { + TransactionManager& tm, laddr_t min_laddr) +{ return NodeExtentManagerURef(new SeastoreNodeExtentManager(tm, min_laddr)); } diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/seastore.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/seastore.cc index dc9333295b77..24286f8b584c 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/seastore.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/seastore.cc @@ -8,7 +8,8 @@ namespace { -seastar::logger& logger() { +seastar::logger& logger() +{ return crimson::get_logger(ceph_subsys_filestore); } @@ -17,7 +18,8 @@ seastar::logger& logger() { namespace crimson::os::seastore::onode { static DeltaRecorderURef create_replay_recorder( - node_type_t node_type, field_type_t field_type) { + node_type_t node_type, field_type_t field_type) +{ if (node_type == node_type_t::LEAF) { if (field_type == field_type_t::N0) { return DeltaRecorderT::create_for_replay(); @@ -47,7 +49,8 @@ static DeltaRecorderURef create_replay_recorder( } } -void SeastoreSuper::write_root_laddr(context_t c, laddr_t addr) { +void SeastoreSuper::write_root_laddr(context_t c, laddr_t addr) +{ logger().info("OTree::Seastore: update root {:#x} ...", addr); root_addr = addr; auto nm = static_cast(&c.nm); @@ -55,7 +58,8 @@ void SeastoreSuper::write_root_laddr(context_t c, laddr_t addr) { } NodeExtentRef SeastoreNodeExtent::mutate( - context_t c, DeltaRecorderURef&& _recorder) { + context_t c, DeltaRecorderURef&& _recorder) +{ logger().debug("OTree::Seastore: mutate {:#x} ...", get_laddr()); auto nm = static_cast(&c.nm); auto extent = nm->get_tm().get_mutable_extent(c.t, this); @@ -67,7 +71,8 @@ NodeExtentRef SeastoreNodeExtent::mutate( return ret; } -void SeastoreNodeExtent::apply_delta(const ceph::bufferlist& bl) { +void SeastoreNodeExtent::apply_delta(const ceph::bufferlist& bl) +{ logger().debug("OTree::Seastore: replay {:#x} ...", get_laddr()); if (!recorder) { auto [node_type, field_type] = get_types(); diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/node_impl.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/node_impl.cc index 59d792b1a4ea..fd3f93b53f1b 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node_impl.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node_impl.cc @@ -13,7 +13,8 @@ last_split_info_t last_split = {}; // XXX: branchless allocation InternalNodeImpl::alloc_ertr::future InternalNodeImpl::allocate( - context_t c, field_type_t type, bool is_level_tail, level_t level) { + 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) { @@ -29,7 +30,8 @@ InternalNodeImpl::allocate( LeafNodeImpl::alloc_ertr::future LeafNodeImpl::allocate( - context_t c, field_type_t type, bool is_level_tail) { + 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) { @@ -44,7 +46,8 @@ LeafNodeImpl::allocate( } InternalNodeImplURef InternalNodeImpl::load( - NodeExtentRef extent, field_type_t type, bool expect_is_level_tail) { + 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) { @@ -59,7 +62,8 @@ InternalNodeImplURef InternalNodeImpl::load( } LeafNodeImplURef LeafNodeImpl::load( - NodeExtentRef extent, field_type_t type, bool expect_is_level_tail) { + 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) { diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.cc index 443c6cabdeb8..2ca2b28e92b8 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.cc @@ -14,7 +14,8 @@ template template memory_range_t ITER_T::insert_prefix( NodeExtentMutable& mut, const ITER_T& iter, const full_key_t& key, - bool is_end, node_offset_t size, const char* p_left_bound) { + bool is_end, node_offset_t size, const char* p_left_bound) +{ // 1. insert range char* p_insert; if (is_end) { @@ -51,7 +52,8 @@ IP_TEMPLATE(node_type_t::INTERNAL, KeyT::HOBJ); template void ITER_T::update_size( - NodeExtentMutable& mut, const ITER_T& iter, int change) { + NodeExtentMutable& mut, const ITER_T& iter, int change) +{ node_offset_t offset = iter.get_back_offset(); int new_size = change + offset; assert(new_size > 0 && new_size < NODE_BLOCK_SIZE); @@ -60,7 +62,8 @@ void ITER_T::update_size( } template -node_offset_t ITER_T::trim_until(NodeExtentMutable&, const ITER_T& iter) { +node_offset_t ITER_T::trim_until(NodeExtentMutable&, const ITER_T& iter) +{ assert(iter.index() != 0); size_t ret = iter.p_end() - iter.p_items_start; assert(ret < NODE_BLOCK_SIZE); @@ -69,7 +72,8 @@ node_offset_t ITER_T::trim_until(NodeExtentMutable&, const ITER_T& iter) { template node_offset_t ITER_T::trim_at( - NodeExtentMutable& mut, const ITER_T& iter, node_offset_t trimmed) { + NodeExtentMutable& mut, const ITER_T& iter, node_offset_t trimmed) +{ size_t trim_size = iter.p_start() - iter.p_items_start + trimmed; assert(trim_size < NODE_BLOCK_SIZE); assert(iter.get_back_offset() > trimmed); @@ -86,7 +90,8 @@ ITER_TEMPLATE(node_type_t::INTERNAL); template template -bool APPEND_T::append(const ITER_T& src, index_t& items) { +bool APPEND_T::append(const ITER_T& src, index_t& items) +{ auto p_end = src.p_end(); bool append_till_end = false; if (is_valid_index(items)) { @@ -130,7 +135,8 @@ bool APPEND_T::append(const ITER_T& src, index_t& items) { template template std::tuple -APPEND_T::open_nxt(const key_get_type& partial_key) { +APPEND_T::open_nxt(const key_get_type& partial_key) +{ p_append -= sizeof(node_offset_t); p_offset_while_open = p_append; ns_oid_view_t::append(*p_mut, partial_key, p_append); @@ -140,7 +146,8 @@ APPEND_T::open_nxt(const key_get_type& partial_key) { template template std::tuple -APPEND_T::open_nxt(const full_key_t& key) { +APPEND_T::open_nxt(const full_key_t& key) +{ p_append -= sizeof(node_offset_t); p_offset_while_open = p_append; ns_oid_view_t::append(*p_mut, key, p_append); @@ -149,7 +156,8 @@ APPEND_T::open_nxt(const full_key_t& key) { template template -void APPEND_T::wrap_nxt(char* _p_append) { +void APPEND_T::wrap_nxt(char* _p_append) +{ assert(_p_append < p_append); p_mut->copy_in_absolute( p_offset_while_open, node_offset_t(p_offset_while_open - _p_append)); diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.cc index d60bb8d09f9d..dab2c0d1b8f7 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.cc @@ -8,7 +8,8 @@ namespace crimson::os::seastore::onode { void string_key_view_t::append_str( - NodeExtentMutable& mut, std::string_view str, char*& p_append) { + NodeExtentMutable& mut, std::string_view str, char*& p_append) +{ assert(is_valid_size(str.length())); p_append -= sizeof(string_size_t); string_size_t len = str.length(); @@ -18,7 +19,8 @@ void string_key_view_t::append_str( } void string_key_view_t::append_dedup( - NodeExtentMutable& mut, const Type& dedup_type, char*& p_append) { + NodeExtentMutable& mut, const Type& dedup_type, char*& p_append) +{ p_append -= sizeof(string_size_t); if (dedup_type == Type::MIN) { mut.copy_in_absolute(p_append, MIN); diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.cc index c39c640e949e..88378713b705 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.cc @@ -12,7 +12,8 @@ namespace crimson::os::seastore::onode { #define NODE_INST(FT, NT) node_extent_t template -const char* NODE_T::p_left_bound() const { +const char* NODE_T::p_left_bound() const +{ if constexpr (std::is_same_v) { // N3 internal node doesn't have the right part return nullptr; @@ -28,7 +29,8 @@ const char* NODE_T::p_left_bound() const { } template -node_offset_t NODE_T::size_to_nxt_at(index_t index) const { +node_offset_t NODE_T::size_to_nxt_at(index_t index) const +{ assert(index < keys()); if constexpr (FIELD_TYPE == field_type_t::N0 || FIELD_TYPE == field_type_t::N1) { @@ -42,7 +44,8 @@ node_offset_t NODE_T::size_to_nxt_at(index_t index) const { } template -memory_range_t NODE_T::get_nxt_container(index_t index) const { +memory_range_t NODE_T::get_nxt_container(index_t index) const +{ if constexpr (std::is_same_v) { ceph_abort("N3 internal node doesn't have the right part"); } else { @@ -66,7 +69,8 @@ template void NODE_T::bootstrap_extent( NodeExtentMutable& mut, field_type_t field_type, node_type_t node_type, - bool is_level_tail, level_t level) { + bool is_level_tail, level_t level) +{ node_header_t::bootstrap_extent( mut, field_type, node_type, is_level_tail, level); mut.copy_in_relative( @@ -75,7 +79,8 @@ void NODE_T::bootstrap_extent( template void NODE_T::update_is_level_tail( - NodeExtentMutable& mut, const node_extent_t& extent, bool value) { + NodeExtentMutable& mut, const node_extent_t& extent, bool value) +{ node_header_t::update_is_level_tail(mut, extent.p_fields->header, value); } @@ -83,7 +88,8 @@ template template memory_range_t NODE_T::insert_prefix_at( NodeExtentMutable& mut, const node_extent_t& node, const full_key_t& key, - index_t index, node_offset_t size, const char* p_left_bound) { + index_t index, node_offset_t size, const char* p_left_bound) +{ if constexpr (FIELD_TYPE == field_type_t::N0 || FIELD_TYPE == field_type_t::N1) { assert(index <= node.keys()); @@ -122,14 +128,16 @@ IPA_TEMPLATE(node_fields_2_t, node_type_t::LEAF, KeyT::HOBJ); template void NODE_T::update_size_at( - NodeExtentMutable& mut, const node_extent_t& node, index_t index, int change) { + NodeExtentMutable& mut, const node_extent_t& node, index_t index, int change) +{ assert(index < node.keys()); FieldType::update_size_at(mut, node.fields(), index, change); } template node_offset_t NODE_T::trim_until( - NodeExtentMutable& mut, const node_extent_t& node, index_t index) { + NodeExtentMutable& mut, const node_extent_t& node, index_t index) +{ assert(!node.is_level_tail()); auto keys = node.keys(); assert(index <= keys); @@ -149,7 +157,8 @@ node_offset_t NODE_T::trim_until( template node_offset_t NODE_T::trim_at( NodeExtentMutable& mut, const node_extent_t& node, - index_t index, node_offset_t trimmed) { + index_t index, node_offset_t trimmed) +{ assert(!node.is_level_tail()); assert(index < node.keys()); if constexpr (std::is_same_v) { @@ -181,7 +190,8 @@ NODE_TEMPLATE(leaf_fields_3_t, node_type_t::LEAF); template template -void APPEND_T::append(const node_extent_t& src, index_t from, index_t items) { +void APPEND_T::append(const node_extent_t& src, index_t from, index_t items) +{ assert(from <= src.keys()); if (p_src == nullptr) { p_src = &src; @@ -242,7 +252,8 @@ void APPEND_T::append(const node_extent_t& src, index_t from, index_t items) { template template void APPEND_T::append( - const full_key_t& key, const value_input_t& value, const value_t*& p_value) { + const full_key_t& key, const value_input_t& value, const value_t*& p_value) +{ if constexpr (FIELD_TYPE == field_type_t::N3) { ceph_abort("not implemented"); } else { @@ -253,7 +264,8 @@ void APPEND_T::append( template template std::tuple -APPEND_T::open_nxt(const key_get_type& partial_key) { +APPEND_T::open_nxt(const key_get_type& partial_key) +{ if constexpr (FIELD_TYPE == field_type_t::N0 || FIELD_TYPE == field_type_t::N1) { FieldType::append_key(*p_mut, partial_key, p_append_left); @@ -268,7 +280,8 @@ APPEND_T::open_nxt(const key_get_type& partial_key) { template template std::tuple -APPEND_T::open_nxt(const full_key_t& key) { +APPEND_T::open_nxt(const full_key_t& key) +{ if constexpr (FIELD_TYPE == field_type_t::N0 || FIELD_TYPE == field_type_t::N1) { FieldType::template append_key(*p_mut, key, p_append_left); @@ -282,7 +295,8 @@ APPEND_T::open_nxt(const full_key_t& key) { template template -char* APPEND_T::wrap() { +char* APPEND_T::wrap() +{ assert(p_append_left <= p_append_right); assert(p_src); if constexpr (NODE_TYPE == node_type_t::INTERNAL) { diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage_layout.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage_layout.cc index 81bfac72a77a..ef16143f9944 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage_layout.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage_layout.cc @@ -10,7 +10,8 @@ namespace crimson::os::seastore::onode { void node_header_t::bootstrap_extent( NodeExtentMutable& mut, field_type_t field_type, node_type_t node_type, - bool is_level_tail, level_t level) { + bool is_level_tail, level_t level) +{ node_header_t header; header.set_field_type(field_type); header.set_node_type(node_type); @@ -20,7 +21,8 @@ void node_header_t::bootstrap_extent( } void node_header_t::update_is_level_tail( - NodeExtentMutable& mut, const node_header_t& header, bool value) { + NodeExtentMutable& mut, const node_header_t& header, bool value) +{ auto& _header = const_cast(header); _header.set_is_level_tail(value); mut.validate_inplace_update(_header); @@ -31,7 +33,8 @@ void node_header_t::update_is_level_tail( template void F013_T::update_size_at( - NodeExtentMutable& mut, const me_t& node, index_t index, int change) { + NodeExtentMutable& mut, const me_t& node, index_t index, int change) +{ assert(index <= node.num_keys); for (const auto* p_slot = &node.slots[index]; p_slot < &node.slots[node.num_keys]; @@ -45,14 +48,16 @@ void F013_T::update_size_at( template void F013_T::append_key( - NodeExtentMutable& mut, const key_t& key, char*& p_append) { + NodeExtentMutable& mut, const key_t& key, char*& p_append) +{ mut.copy_in_absolute(p_append, key); p_append += sizeof(key_t); } template void F013_T::append_offset( - NodeExtentMutable& mut, node_offset_t offset_to_right, char*& p_append) { + NodeExtentMutable& mut, node_offset_t offset_to_right, char*& p_append) +{ mut.copy_in_absolute(p_append, offset_to_right); p_append += sizeof(node_offset_t); } @@ -61,7 +66,8 @@ template template void F013_T::insert_at( NodeExtentMutable& mut, const full_key_t& key, - const me_t& node, index_t index, node_offset_t size_right) { + const me_t& node, index_t index, node_offset_t size_right) +{ assert(index <= node.num_keys); update_size_at(mut, node, index, size_right); auto p_insert = const_cast(fields_start(node)) + @@ -88,7 +94,8 @@ F013_TEMPLATE(slot_1_t); F013_TEMPLATE(slot_3_t); void node_fields_2_t::append_offset( - NodeExtentMutable& mut, node_offset_t offset_to_right, char*& p_append) { + NodeExtentMutable& mut, node_offset_t offset_to_right, char*& p_append) +{ mut.copy_in_absolute(p_append, offset_to_right); p_append += sizeof(node_offset_t); } diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.cc index dd98c230e100..c36776ccbdb8 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.cc @@ -11,7 +11,8 @@ template const laddr_packed_t* internal_sub_items_t::insert_at( NodeExtentMutable& mut, const internal_sub_items_t& sub_items, const full_key_t& key, const laddr_t& value, - index_t index, node_offset_t size, const char* p_left_bound) { + index_t index, node_offset_t size, const char* p_left_bound) +{ assert(index <= sub_items.keys()); assert(size == estimate_insert(key, value)); const char* p_shift_start = p_left_bound; @@ -33,7 +34,8 @@ IA_TEMPLATE(KeyT::VIEW); IA_TEMPLATE(KeyT::HOBJ); node_offset_t internal_sub_items_t::trim_until( - NodeExtentMutable&, internal_sub_items_t& items, index_t index) { + NodeExtentMutable&, internal_sub_items_t& items, index_t index) +{ assert(index != 0); auto keys = items.keys(); assert(index <= keys); @@ -44,7 +46,8 @@ node_offset_t internal_sub_items_t::trim_until( template void internal_sub_items_t::Appender::append( - const internal_sub_items_t& src, index_t from, index_t items) { + const internal_sub_items_t& src, index_t from, index_t items) +{ assert(from <= src.keys()); if (items == 0) { return; @@ -59,7 +62,8 @@ void internal_sub_items_t::Appender::append( template void internal_sub_items_t::Appender::append( const full_key_t& key, const laddr_t& value, - const laddr_packed_t*& p_value) { + const laddr_packed_t*& p_value) +{ p_append -= sizeof(internal_sub_item_t); auto item = internal_sub_item_t{ snap_gen_t::from_key(key), laddr_packed_t{value}}; @@ -71,7 +75,8 @@ template const value_header_t* leaf_sub_items_t::insert_at( NodeExtentMutable& mut, const leaf_sub_items_t& sub_items, const full_key_t& key, const value_config_t& value, - index_t index, node_offset_t size, const char* p_left_bound) { + index_t index, node_offset_t size, const char* p_left_bound) +{ assert(index <= sub_items.keys()); assert(size == estimate_insert(key, value)); // a. [... item(index)] << size @@ -117,7 +122,8 @@ template const value_header_t* leaf_sub_items_t::insert_at( const value_config_t&, index_t, node_offset_t, const char*); node_offset_t leaf_sub_items_t::trim_until( - NodeExtentMutable& mut, leaf_sub_items_t& items, index_t index) { + NodeExtentMutable& mut, leaf_sub_items_t& items, index_t index) +{ assert(index != 0); auto keys = items.keys(); assert(index <= keys); @@ -146,7 +152,8 @@ template struct overloaded : Ts... { using Ts::operator()...; }; template overloaded(Ts...) -> overloaded; template -char* leaf_sub_items_t::Appender::wrap() { +char* leaf_sub_items_t::Appender::wrap() +{ auto p_cur = p_append; num_keys_t num_keys = 0; for (auto i = 0u; i < cnt; ++i) { diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/super.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/super.cc index 5a28f5097c2a..09f20db3a77e 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/super.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/super.cc @@ -6,7 +6,8 @@ namespace crimson::os::seastore::onode { -Ref RootNodeTrackerIsolated::get_root(Transaction& t) const { +Ref RootNodeTrackerIsolated::get_root(Transaction& t) const +{ auto iter = tracked_supers.find(&t); if (iter == tracked_supers.end()) { return nullptr; @@ -15,7 +16,8 @@ Ref RootNodeTrackerIsolated::get_root(Transaction& t) const { } } -Ref RootNodeTrackerShared::get_root(Transaction&) const { +Ref RootNodeTrackerShared::get_root(Transaction&) const +{ if (is_clean()) { return nullptr; } else { diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/value.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/value.cc index 96ebb20d0acd..ed37ae0eb764 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/value.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/value.cc @@ -16,7 +16,8 @@ template using future = Value::future; ceph::bufferlist& -ValueDeltaRecorder::get_encoded(NodeExtentMutable& payload_mut) { +ValueDeltaRecorder::get_encoded(NodeExtentMutable& payload_mut) +{ ceph::encode(node_delta_op_t::SUBOP_UPDATE_VALUE, encoded); node_offset_t offset = payload_mut.get_node_offset(); assert(offset > sizeof(value_header_t)); @@ -32,7 +33,8 @@ Value::Value(NodeExtentManager& nm, Value::~Value() {} -future<> Value::extend(Transaction& t, value_size_t extend_size) { +future<> Value::extend(Transaction& t, value_size_t extend_size) +{ auto target_size = get_payload_size() + extend_size; return p_cursor->extend_value(get_context(t), extend_size ).safe_then([this, target_size] { @@ -40,7 +42,8 @@ future<> Value::extend(Transaction& t, value_size_t extend_size) { }); } -future<> Value::trim(Transaction& t, value_size_t trim_size) { +future<> Value::trim(Transaction& t, value_size_t trim_size) +{ assert(get_payload_size() > trim_size); auto target_size = get_payload_size() - trim_size; return p_cursor->trim_value(get_context(t), trim_size @@ -49,18 +52,21 @@ future<> Value::trim(Transaction& t, value_size_t trim_size) { }); } -const value_header_t* Value::read_value_header() const { +const value_header_t* Value::read_value_header() const +{ return p_cursor->read_value_header(vb.get_header_magic()); } std::pair -Value::do_prepare_mutate_payload(Transaction& t) { +Value::do_prepare_mutate_payload(Transaction& t) +{ return p_cursor->prepare_mutate_value_payload(get_context(t)); } std::unique_ptr build_value_recorder_by_type(ceph::bufferlist& encoded, - const value_magic_t& magic) { + const value_magic_t& magic) +{ std::unique_ptr ret; switch (magic) { case value_magic_t::TEST: