diff options
author | chunmei-liu <chunmei.liu@intel.com> | 2021-08-07 22:39:45 +0200 |
---|---|---|
committer | Chunmei Liu <chunmei.liu@intel.com> | 2021-08-16 22:54:48 +0200 |
commit | 6633e30a32b2e78cd61a824720d9b51f7f304da0 (patch) | |
tree | d22336b41c7183b51852d5096138d3b5e8869fad /src/crimson/os | |
parent | crimson/seastore: use get_hint in object_data_handler (diff) | |
download | ceph-6633e30a32b2e78cd61a824720d9b51f7f304da0.tar.xz ceph-6633e30a32b2e78cd61a824720d9b51f7f304da0.zip |
crimson/seastore: replace L_ADDR_MIN by hint in omap
Signed-off-by: chunmei-liu <chunmei.liu@intel.com>
Diffstat (limited to 'src/crimson/os')
8 files changed, 61 insertions, 45 deletions
diff --git a/src/crimson/os/seastore/omap_manager.h b/src/crimson/os/seastore/omap_manager.h index 86e4b285309..4107cb2d401 100644 --- a/src/crimson/os/seastore/omap_manager.h +++ b/src/crimson/os/seastore/omap_manager.h @@ -37,7 +37,7 @@ public: */ using initialize_omap_iertr = base_iertr; using initialize_omap_ret = initialize_omap_iertr::future<omap_root_t>; - virtual initialize_omap_ret initialize_omap(Transaction &t) = 0; + virtual initialize_omap_ret initialize_omap(Transaction &t, laddr_t hint) = 0; /** * get value(string) by key(string) diff --git a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc index 09c03aa4314..8753ad40370 100644 --- a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc +++ b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc @@ -22,17 +22,17 @@ BtreeOMapManager::BtreeOMapManager( : tm(tm) {} BtreeOMapManager::initialize_omap_ret -BtreeOMapManager::initialize_omap(Transaction &t) +BtreeOMapManager::initialize_omap(Transaction &t, laddr_t hint) { logger().debug("{}", __func__); - return tm.alloc_extent<OMapLeafNode>(t, L_ADDR_MIN, OMAP_BLOCK_SIZE) - .si_then([](auto&& root_extent) { + return tm.alloc_extent<OMapLeafNode>(t, hint, OMAP_BLOCK_SIZE) + .si_then([hint](auto&& root_extent) { root_extent->set_size(0); omap_node_meta_t meta{1}; root_extent->set_meta(meta); omap_root_t omap_root; - omap_root.update(root_extent->get_laddr(), 1); + omap_root.update(root_extent->get_laddr(), 1, hint); return initialize_omap_iertr::make_ready_future<omap_root_t>(omap_root); }); } @@ -51,7 +51,7 @@ BtreeOMapManager::handle_root_split( omap_root_t &omap_root, const OMapNode::mutation_result_t& mresult) { - return oc.tm.alloc_extent<OMapInnerNode>(oc.t, L_ADDR_MIN, OMAP_BLOCK_SIZE) + return oc.tm.alloc_extent<OMapInnerNode>(oc.t, omap_root.hint, OMAP_BLOCK_SIZE) .si_then([&omap_root, mresult](auto&& nroot) -> handle_root_split_ret { auto [left, right, pivot] = *(mresult.split_tuple); omap_node_meta_t meta{omap_root.depth + 1}; @@ -60,7 +60,7 @@ BtreeOMapManager::handle_root_split( "", nroot->maybe_get_delta_buffer()); nroot->journal_inner_insert(nroot->iter_begin() + 1, right->get_laddr(), pivot, nroot->maybe_get_delta_buffer()); - omap_root.update(nroot->get_laddr(), omap_root.get_depth() + 1); + omap_root.update(nroot->get_laddr(), omap_root.get_depth() + 1, omap_root.hint); return seastar::now(); }); } @@ -75,7 +75,8 @@ BtreeOMapManager::handle_root_merge( auto iter = root->cast<OMapInnerNode>()->iter_begin(); omap_root.update( iter->get_val(), - omap_root.depth -= 1); + omap_root.depth -= 1, + omap_root.hint); return oc.tm.dec_ref(oc.t, root->get_laddr() ).si_then([](auto &&ret) -> handle_root_merge_ret { return seastar::now(); @@ -95,10 +96,10 @@ BtreeOMapManager::omap_get_value( { logger().debug("{}: {}", __func__, key); return get_omap_root( - get_omap_context(t), + get_omap_context(t, omap_root.hint), omap_root - ).si_then([this, &t, &key](auto&& extent) { - return extent->get_value(get_omap_context(t), key); + ).si_then([this, &t, &key, &omap_root](auto&& extent) { + return extent->get_value(get_omap_context(t, omap_root.hint), key); }).si_then([](auto &&e) { return omap_get_value_ret( interruptible::ready_future_marker{}, @@ -131,15 +132,15 @@ BtreeOMapManager::omap_set_key( { logger().debug("{}: {} -> {}", __func__, key, value); return get_omap_root( - get_omap_context(t), + get_omap_context(t, omap_root.hint), omap_root - ).si_then([this, &t, &key, &value](auto root) { - return root->insert(get_omap_context(t), key, value); + ).si_then([this, &t, &key, &value, &omap_root](auto root) { + return root->insert(get_omap_context(t, omap_root.hint), key, value); }).si_then([this, &omap_root, &t](auto mresult) -> omap_set_key_ret { if (mresult.status == mutation_status_t::SUCCESS) return seastar::now(); else if (mresult.status == mutation_status_t::WAS_SPLIT) - return handle_root_split(get_omap_context(t), omap_root, mresult); + return handle_root_split(get_omap_context(t, omap_root.hint), omap_root, mresult); else return seastar::now(); }); @@ -153,19 +154,19 @@ BtreeOMapManager::omap_rm_key( { logger().debug("{}: {}", __func__, key); return get_omap_root( - get_omap_context(t), + get_omap_context(t, omap_root.hint), omap_root - ).si_then([this, &t, &key](auto root) { - return root->rm_key(get_omap_context(t), key); + ).si_then([this, &t, &key, &omap_root](auto root) { + return root->rm_key(get_omap_context(t, omap_root.hint), key); }).si_then([this, &omap_root, &t](auto mresult) -> omap_rm_key_ret { if (mresult.status == mutation_status_t::SUCCESS) { return seastar::now(); } else if (mresult.status == mutation_status_t::WAS_SPLIT) { - return handle_root_split(get_omap_context(t), omap_root, mresult); + return handle_root_split(get_omap_context(t, omap_root.hint), omap_root, mresult); } else if (mresult.status == mutation_status_t::NEED_MERGE) { auto root = *(mresult.need_merge); if (root->get_node_size() == 1 && omap_root.depth != 1) { - return handle_root_merge(get_omap_context(t), omap_root, mresult); + return handle_root_merge(get_omap_context(t, omap_root.hint), omap_root, mresult); } else { return seastar::now(); } @@ -185,11 +186,11 @@ BtreeOMapManager::omap_list( { logger().debug("{}", __func__); return get_omap_root( - get_omap_context(t), + get_omap_context(t, omap_root.hint), omap_root - ).si_then([this, config, &t, &start](auto extent) { + ).si_then([this, config, &t, &start, &omap_root](auto extent) { return extent->list( - get_omap_context(t), + get_omap_context(t, omap_root.hint), start, config); }); @@ -202,17 +203,17 @@ BtreeOMapManager::omap_clear( { logger().debug("{}", __func__); return get_omap_root( - get_omap_context(t), + get_omap_context(t, omap_root.hint), omap_root - ).si_then([this, &t](auto extent) { - return extent->clear(get_omap_context(t)); + ).si_then([this, &t, &omap_root](auto extent) { + return extent->clear(get_omap_context(t, omap_root.hint)); }).si_then([this, &omap_root, &t] { return tm.dec_ref( t, omap_root.get_location() ).si_then([&omap_root] (auto ret) { omap_root.update( L_ADDR_NULL, - 0); + 0, L_ADDR_MIN); return omap_clear_iertr::now(); }); }).handle_error_interruptible( diff --git a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h index 3f155d69707..87ce68235a0 100644 --- a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h +++ b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h @@ -26,8 +26,8 @@ class BtreeOMapManager : public OMapManager { TransactionManager &tm; omap_context_t get_omap_context( - Transaction &t) { - return omap_context_t{tm, t}; + Transaction &t, laddr_t addr_min) { + return omap_context_t{tm, t, addr_min}; } /* get_omap_root @@ -65,7 +65,7 @@ class BtreeOMapManager : public OMapManager { public: explicit BtreeOMapManager(TransactionManager &tm); - initialize_omap_ret initialize_omap(Transaction &t) final; + initialize_omap_ret initialize_omap(Transaction &t, laddr_t hint) final; omap_get_value_ret omap_get_value( const omap_root_t &omap_root, diff --git a/src/crimson/os/seastore/omap_manager/btree/omap_btree_node.h b/src/crimson/os/seastore/omap_manager/btree/omap_btree_node.h index d59b82ca35a..5280e73c496 100644 --- a/src/crimson/os/seastore/omap_manager/btree/omap_btree_node.h +++ b/src/crimson/os/seastore/omap_manager/btree/omap_btree_node.h @@ -18,6 +18,7 @@ namespace crimson::os::seastore::omap_manager{ struct omap_context_t { TransactionManager &tm; Transaction &t; + laddr_t hint; }; enum class mutation_status_t : uint8_t { diff --git a/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc b/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc index ad8e468bb54..66aea6a4427 100644 --- a/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc +++ b/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc @@ -281,7 +281,7 @@ OMapInnerNode::full_merge_ret OMapInnerNode::make_full_merge(omap_context_t oc, OMapNodeRef right) { logger().debug("OMapInnerNode: {}", __func__); - return oc.tm.alloc_extent<OMapInnerNode>(oc.t, L_ADDR_MIN, OMAP_BLOCK_SIZE) + return oc.tm.alloc_extent<OMapInnerNode>(oc.t, oc.hint, OMAP_BLOCK_SIZE) .si_then([this, right] (auto &&replacement) { replacement->merge_from(*this, *right->cast<OMapInnerNode>()); return full_merge_ret( @@ -569,7 +569,7 @@ OMapLeafNode::make_full_merge(omap_context_t oc, OMapNodeRef right) { ceph_assert(right->get_type() == TYPE); logger().debug("OMapLeafNode: {}", __func__); - return oc.tm.alloc_extent<OMapLeafNode>(oc.t, L_ADDR_MIN, OMAP_BLOCK_SIZE) + return oc.tm.alloc_extent<OMapLeafNode>(oc.t, oc.hint, OMAP_BLOCK_SIZE) .si_then([this, right] (auto &&replacement) { replacement->merge_from(*this, *right->cast<OMapLeafNode>()); return full_merge_ret( diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index 75140368351..3973da181b2 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -301,7 +301,7 @@ SeaStore::get_attr_errorator::future<ceph::bufferlist> SeaStore::get_attr( } return _omap_get_value( t, - layout.xattr_root.get(), + layout.xattr_root.get(onode.get_hint()), name); } ).handle_error(crimson::ct_error::input_output_error::handle([FNAME] { @@ -324,7 +324,7 @@ SeaStore::get_attrs_ertr::future<SeaStore::attrs_t> SeaStore::get_attrs( op_type_t::GET_ATTRS, [=](auto &t, auto& onode) { auto& layout = onode.get_layout(); - return _omap_list(layout.xattr_root, t, std::nullopt, + return _omap_list(onode, layout.xattr_root, t, std::nullopt, OMapManager::omap_list_config_t::with_inclusive(false) ).si_then([&layout](auto p) { auto& attrs = std::get<1>(p); @@ -396,7 +396,7 @@ SeaStore::omap_get_values( Transaction::src_t::READ, op_type_t::OMAP_GET_VALUES, [this, keys](auto &t, auto &onode) { - omap_root_t omap_root = onode.get_layout().omap_root.get(); + omap_root_t omap_root = onode.get_layout().omap_root.get(onode.get_hint()); return _omap_get_values( t, std::move(omap_root), @@ -468,12 +468,13 @@ SeaStore::_omap_get_values_ret SeaStore::_omap_get_values( } SeaStore::_omap_list_ret SeaStore::_omap_list( + Onode &onode, const omap_root_le_t& omap_root, Transaction& t, const std::optional<std::string>& start, OMapManager::omap_list_config_t config) const { - auto root = omap_root.get(); + auto root = omap_root.get(onode.get_hint()); if (root.is_null()) { return seastar::make_ready_future<_omap_list_bare_ret>( true, omap_values_t{} @@ -505,6 +506,7 @@ SeaStore::omap_get_values_ret_t SeaStore::omap_list( op_type_t::OMAP_LIST, [this, config, &start](auto &t, auto &onode) { return _omap_list( + onode, onode.get_layout().omap_root, t, start, config ); @@ -860,6 +862,7 @@ SeaStore::tm_ret SeaStore::_write( SeaStore::omap_set_kvs_ret SeaStore::_omap_set_kvs( + OnodeRef &onode, const omap_root_le_t& omap_root, Transaction& t, omap_root_le_t& mutable_omap_root, @@ -867,13 +870,13 @@ SeaStore::_omap_set_kvs( { return seastar::do_with( BtreeOMapManager(*transaction_manager), - omap_root.get(), + omap_root.get(onode->get_hint()), [&, keys=std::move(kvs)](auto &omap_manager, auto &root) { tm_iertr::future<> maybe_create_root = !root.is_null() ? tm_iertr::now() : omap_manager.initialize_omap( - t + t, onode->get_hint() ).si_then([&root](auto new_root) { root = new_root; }); @@ -899,6 +902,7 @@ SeaStore::tm_ret SeaStore::_omap_set_values( LOG_PREFIX(SeaStore::_omap_set_values); DEBUGT("{} {} keys", *ctx.transaction, *onode, aset.size()); return _omap_set_kvs( + onode, onode->get_layout().omap_root, *ctx.transaction, onode->get_mutable_layout(*ctx.transaction).omap_root, @@ -923,13 +927,13 @@ SeaStore::tm_ret SeaStore::_omap_rmkeys( { LOG_PREFIX(SeaStore::_omap_rmkeys); DEBUGT("{} {} keys", *ctx.transaction, *onode, keys.size()); - auto omap_root = onode->get_layout().omap_root.get(); + auto omap_root = onode->get_layout().omap_root.get(onode->get_hint()); if (omap_root.is_null()) { return seastar::now(); } else { return seastar::do_with( BtreeOMapManager(*transaction_manager), - onode->get_layout().omap_root.get(), + onode->get_layout().omap_root.get(onode->get_hint()), std::move(keys), [&ctx, &onode]( auto &omap_manager, @@ -1027,6 +1031,7 @@ SeaStore::tm_ret SeaStore::_setattrs( } return _omap_set_kvs( + onode, onode->get_layout().xattr_root, *ctx.transaction, layout.xattr_root, diff --git a/src/crimson/os/seastore/seastore.h b/src/crimson/os/seastore/seastore.h index f757d9b8a3a..471328c8a3a 100644 --- a/src/crimson/os/seastore/seastore.h +++ b/src/crimson/os/seastore/seastore.h @@ -250,6 +250,7 @@ private: using _omap_list_bare_ret = OMapManager::omap_list_bare_ret; using _omap_list_ret = OMapManager::omap_list_ret; _omap_list_ret _omap_list( + Onode &onode, const omap_root_le_t& omap_root, Transaction& t, const std::optional<std::string>& start, @@ -319,6 +320,7 @@ private: const coll_t& cid); using omap_set_kvs_ret = tm_iertr::future<>; omap_set_kvs_ret _omap_set_kvs( + OnodeRef &onode, const omap_root_le_t& omap_root, Transaction& t, omap_root_le_t& mutable_omap_root, diff --git a/src/crimson/os/seastore/seastore_types.h b/src/crimson/os/seastore/seastore_types.h index 7d485e7ccd3..43386a54a3b 100644 --- a/src/crimson/os/seastore/seastore_types.h +++ b/src/crimson/os/seastore/seastore_types.h @@ -484,12 +484,14 @@ struct __attribute__((packed)) object_data_le_t { struct omap_root_t { laddr_t addr = L_ADDR_NULL; depth_t depth = 0; + laddr_t hint = L_ADDR_MIN; bool mutated = false; omap_root_t() = default; - omap_root_t(laddr_t addr, depth_t depth) + omap_root_t(laddr_t addr, depth_t depth, laddr_t addr_min) : addr(addr), - depth(depth) {} + depth(depth), + hint(addr_min) {} omap_root_t(const omap_root_t &o) = default; omap_root_t(omap_root_t &&o) = default; @@ -504,10 +506,11 @@ struct omap_root_t { return mutated; } - void update(laddr_t _addr, depth_t _depth) { + void update(laddr_t _addr, depth_t _depth, laddr_t _hint) { mutated = true; addr = _addr; depth = _depth; + hint = _hint; } laddr_t get_location() const { @@ -517,6 +520,10 @@ struct omap_root_t { depth_t get_depth() const { return depth; } + + laddr_t get_hint() const { + return hint; + } }; class __attribute__((packed)) omap_root_le_t { @@ -539,8 +546,8 @@ public: depth = init_depth_le(nroot.get_depth()); } - omap_root_t get() const { - return omap_root_t(addr, depth); + omap_root_t get(laddr_t hint) const { + return omap_root_t(addr, depth, hint); } }; |