From: Kefu Chai Date: Thu, 21 Jan 2021 12:50:12 +0000 (+0800) Subject: crimson/onode-staged-tree: add more constness X-Git-Tag: v17.1.0~3086^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f71a94fdfd44e6ca25cb66b82f10008b6d1082c;p=ceph.git crimson/onode-staged-tree: add more constness Signed-off-by: Kefu Chai --- 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 1d04c77bfec3..a86fbca40d0a 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node.cc @@ -865,7 +865,7 @@ Ref LeafNode::get_or_track_cursor( return p_cursor; } -void LeafNode::validate_cursor(tree_cursor_t& cursor) const +void LeafNode::validate_cursor(const tree_cursor_t& cursor) const { #ifndef NDEBUG assert(this == cursor.get_leaf_node().get()); diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/node.h b/src/crimson/os/seastore/onode_manager/staged-fltree/node.h index 4384e15d8b8c..1abfce4cc38b 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node.h @@ -122,7 +122,7 @@ class tree_cursor_t final tree_cursor_t(Ref); const search_position_t& get_position() const { return position; } - Ref get_leaf_node() { return ref_leaf_node; } + Ref get_leaf_node() const { return ref_leaf_node; } template void update_track(Ref, const search_position_t&); void update_cache(LeafNode&, const key_view_t&, const value_header_t*) const; @@ -466,10 +466,10 @@ class LeafNode final : public Node { validate_cursor(cursor); } auto& cursor_pos = cursor.get_position(); - assert(tracked_cursors.find(cursor_pos) == tracked_cursors.end()); - tracked_cursors[cursor_pos] = &cursor; + assert(tracked_cursors.count(cursor_pos) == 0); + tracked_cursors.emplace(cursor_pos, &cursor); } - void do_untrack_cursor(tree_cursor_t& cursor) { + void do_untrack_cursor(const tree_cursor_t& cursor) { validate_cursor(cursor); auto& cursor_pos = cursor.get_position(); assert(tracked_cursors.find(cursor_pos)->second == &cursor); @@ -517,7 +517,7 @@ class LeafNode final : public Node { } #endif } - void validate_cursor(tree_cursor_t& cursor) const; + void validate_cursor(const tree_cursor_t& cursor) const; // invalidate p_value pointers in tree_cursor_t void on_layout_change() { ++layout_version; }