From: Xuehan Xu Date: Wed, 28 Jun 2023 07:18:27 +0000 (+0800) Subject: crimson/os/seastore/collection_manager: fill CollectionNode::decoded on X-Git-Tag: v18.2.1~149^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=618ec97e50fd6c66c94429fe7c691e7cd7a063c4;p=ceph-ci.git crimson/os/seastore/collection_manager: fill CollectionNode::decoded on clean reads Otherwise, deltas of collection nodes can't be replayed correctly, because the data of nodes is not loaded to CollectionNode::decoded Signed-off-by: Xuehan Xu (cherry picked from commit 5eb473b99c1ea75fd6c3807d3f54eaec1018d383) --- diff --git a/src/crimson/os/seastore/collection_manager/collection_flat_node.cc b/src/crimson/os/seastore/collection_manager/collection_flat_node.cc index 9eaeefc72a6..ed17e2b12ef 100644 --- a/src/crimson/os/seastore/collection_manager/collection_flat_node.cc +++ b/src/crimson/os/seastore/collection_manager/collection_flat_node.cc @@ -46,7 +46,6 @@ std::ostream &CollectionNode::print_detail_l(std::ostream &out) const CollectionNode::list_ret CollectionNode::list() { - read_to_local(); logger().debug("CollectionNode:{}, {}", __func__, *this); CollectionManager::list_ret_bare list_result; for (auto &[coll, bits] : decoded) { @@ -60,7 +59,6 @@ CollectionNode::list() CollectionNode::create_ret CollectionNode::create(coll_context_t cc, coll_t coll, unsigned bits) { - read_to_local(); logger().debug("CollectionNode:{}", __func__); if (!is_mutable()) { auto mut = cc.tm.get_mutable_extent(cc.t, this)->cast(); @@ -88,8 +86,8 @@ CollectionNode::create(coll_context_t cc, coll_t coll, unsigned bits) CollectionNode::update_ret CollectionNode::update(coll_context_t cc, coll_t coll, unsigned bits) { - read_to_local(); - logger().debug("CollectionNode:{}", __func__); + logger().debug("trans.{} CollectionNode:{} {} {}", + cc.t.get_trans_id(), __func__, coll, bits); if (!is_mutable()) { auto mut = cc.tm.get_mutable_extent(cc.t, this)->cast(); return mut->update(cc, coll, bits); @@ -105,8 +103,8 @@ CollectionNode::update(coll_context_t cc, coll_t coll, unsigned bits) CollectionNode::remove_ret CollectionNode::remove(coll_context_t cc, coll_t coll) { - read_to_local(); - logger().debug("CollectionNode:{}", __func__); + logger().debug("trans.{} CollectionNode:{} {}", + cc.t.get_trans_id(),__func__, coll); if (!is_mutable()) { auto mut = cc.tm.get_mutable_extent(cc.t, this)->cast(); return mut->remove(cc, coll); diff --git a/src/crimson/os/seastore/collection_manager/collection_flat_node.h b/src/crimson/os/seastore/collection_manager/collection_flat_node.h index 1652eb92f22..2690fb5fdf4 100644 --- a/src/crimson/os/seastore/collection_manager/collection_flat_node.h +++ b/src/crimson/os/seastore/collection_manager/collection_flat_node.h @@ -94,11 +94,11 @@ struct CollectionNode : LogicalCachedExtent { using CollectionNodeRef = TCachedExtentRef; - bool loaded = false; - - template - CollectionNode(T&&... t) - : LogicalCachedExtent(std::forward(t)...) {} + explicit CollectionNode(ceph::bufferptr &&ptr) + : LogicalCachedExtent(std::move(ptr)) {} + explicit CollectionNode(const CollectionNode &other) + : LogicalCachedExtent(other), + decoded(other.decoded) {} static constexpr extent_types_t type = extent_types_t::COLL_BLOCK; @@ -134,13 +134,11 @@ struct CollectionNode using update_ret = CollectionManager::update_ret; update_ret update(coll_context_t cc, coll_t coll, unsigned bits); - void read_to_local() { - if (loaded) return; + void on_clean_read() final { bufferlist bl; bl.append(get_bptr()); auto iter = bl.cbegin(); decode((base_coll_map_t&)decoded, iter); - loaded = true; } void copy_to_node() { diff --git a/src/crimson/os/seastore/collection_manager/flat_collection_manager.cc b/src/crimson/os/seastore/collection_manager/flat_collection_manager.cc index 15ce920ec0a..decb095f6f9 100644 --- a/src/crimson/os/seastore/collection_manager/flat_collection_manager.cc +++ b/src/crimson/os/seastore/collection_manager/flat_collection_manager.cc @@ -80,7 +80,6 @@ FlatCollectionManager::create(coll_root_t &coll_root, Transaction &t, coll_root.update(root_extent->get_laddr(), root_extent->get_length()); root_extent->decoded = extent->decoded; - root_extent->loaded = true; return root_extent->create( get_coll_context(t), cid, info.split_bits ).si_then([=, this, &t](auto result) {