1
0
mirror of https://github.com/ceph/ceph synced 2025-04-06 17:44:22 +00:00

crimson/os/seastore: expand error type for reads to include eagain

There are cases where reads may detect an invalid cached extent and require
the user to restart the transaction.

As a side effect, clean up errorators to assert cases where construction
is invalid (invalid refcounts, enoent or invarg on node read, etc).  In
such cases, we may eventually want to introduce an internal_error error
type, but asserting is fine for now as we do not expect users to handle
these cases.

Signed-off-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Samuel Just 2021-01-13 23:42:36 -08:00
parent ae9d15f670
commit d244530f92
22 changed files with 168 additions and 124 deletions

View File

@ -354,7 +354,10 @@ Cache::mkfs_ertr::future<> Cache::mkfs(Transaction &t)
return get_root(t).safe_then([this, &t](auto croot) {
duplicate_for_write(t, croot);
return mkfs_ertr::now();
});
}).handle_error(
mkfs_ertr::pass_further{},
crimson::ct_error::assert_all{}
);
}
Cache::close_ertr::future<> Cache::close()
@ -383,22 +386,26 @@ Cache::replay_delta(
return replay_delta_ertr::now();
} else {
auto get_extent_if_cached = [this](paddr_t addr)
-> replay_delta_ertr::future<CachedExtentRef> {
-> get_extent_ertr::future<CachedExtentRef> {
auto retiter = extents.find_offset(addr);
if (retiter != extents.end()) {
return replay_delta_ertr::make_ready_future<CachedExtentRef>(&*retiter);
return seastar::make_ready_future<CachedExtentRef>(&*retiter);
} else {
return replay_delta_ertr::make_ready_future<CachedExtentRef>();
return seastar::make_ready_future<CachedExtentRef>();
}
};
auto extent_fut = delta.pversion == 0 ?
auto extent_fut = (delta.pversion == 0 ?
get_extent_by_type(
delta.type,
delta.paddr,
delta.laddr,
delta.length) :
get_extent_if_cached(
delta.paddr);
delta.paddr)
).handle_error(
replay_delta_ertr::pass_further{},
crimson::ct_error::assert_all{}
);
return extent_fut.safe_then([=, &delta](auto extent) {
if (!extent) {
assert(delta.pversion > 0);

View File

@ -83,6 +83,10 @@ namespace crimson::os::seastore {
*/
class Cache {
public:
using base_ertr = crimson::errorator<
crimson::ct_error::input_output_error,
crimson::ct_error::eagain>;
Cache(SegmentManager &segment_manager);
~Cache();
@ -103,8 +107,7 @@ public:
}
/// Declare paddr retired in t, noop if not cached
using retire_extent_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using retire_extent_ertr = base_ertr;
using retire_extent_ret = retire_extent_ertr::future<>;
retire_extent_ret retire_extent_if_cached(
Transaction &t, paddr_t addr);
@ -114,8 +117,7 @@ public:
*
* returns ref to current root or t.root if modified in t
*/
using get_root_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using get_root_ertr = base_ertr;
using get_root_ret = get_root_ertr::future<RootBlockRef>;
get_root_ret get_root(Transaction &t);
@ -136,8 +138,7 @@ public:
* - extent_set if already in cache
* - disk
*/
using get_extent_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using get_extent_ertr = base_ertr;
template <typename T>
get_extent_ertr::future<TCachedExtentRef<T>> get_extent(
paddr_t offset, ///< [in] starting addr
@ -431,7 +432,10 @@ public:
return crimson::do_for_each(
refs,
[&t, &f](auto &e) { return f(t, e); });
});
}).handle_error(
init_cached_extents_ertr::pass_further{},
crimson::ct_error::assert_all{}
);
}
/**

View File

@ -116,9 +116,7 @@ struct ExtMapNode : LogicalCachedExtent {
});
}
using retire_ertr = crimson::errorator<
crimson::ct_error::enoent,
crimson::ct_error::input_output_error>;
using retire_ertr = TransactionManager::ref_ertr;
using retire_ret = retire_ertr::future<std::list<unsigned>>;
retire_ret
extmap_retire_node(ext_context_t ec, std::list<laddr_t> dec_laddrs) {

View File

@ -28,6 +28,8 @@ namespace crimson::os::seastore {
*/
class LBAManager {
public:
using base_ertr = Cache::get_extent_ertr;
using mkfs_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using mkfs_ret = mkfs_ertr::future<>;
@ -40,8 +42,7 @@ public:
*
* Future will not resolve until all pins have resolved (set_paddr called)
*/
using get_mapping_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using get_mapping_ertr = base_ertr;
using get_mapping_ret = get_mapping_ertr::future<lba_pin_list_t>;
virtual get_mapping_ret get_mapping(
Transaction &t,
@ -52,8 +53,7 @@ public:
*
* Future will not result until all pins have resolved (set_paddr called)
*/
using get_mappings_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using get_mappings_ertr = base_ertr;
using get_mappings_ret = get_mapping_ertr::future<lba_pin_list_t>;
virtual get_mappings_ret get_mappings(
Transaction &t,
@ -66,8 +66,7 @@ public:
* This mapping will block from transaction submission until set_paddr
* is called on the LBAPin.
*/
using alloc_extent_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using alloc_extent_ertr = base_ertr;
using alloc_extent_ret = alloc_extent_ertr::future<LBAPinRef>;
virtual alloc_extent_ret alloc_extent(
Transaction &t,
@ -80,8 +79,7 @@ public:
*
* off~len must be unreferenced
*/
using set_extent_ertr = crimson::errorator<
crimson::ct_error::input_output_error,
using set_extent_ertr = base_ertr::extend<
crimson::ct_error::invarg>;
using set_extent_ret = set_extent_ertr::future<LBAPinRef>;
virtual set_extent_ret set_extent(
@ -93,9 +91,8 @@ public:
unsigned refcount = 0;
paddr_t addr;
};
using ref_ertr = crimson::errorator<
crimson::ct_error::enoent,
crimson::ct_error::input_output_error>;
using ref_ertr = base_ertr::extend<
crimson::ct_error::enoent>;
using ref_ret = ref_ertr::future<ref_update_result_t>;
/**
@ -116,8 +113,7 @@ public:
Transaction &t,
laddr_t addr) = 0;
using complete_transaction_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using complete_transaction_ertr = base_ertr;
using complete_transaction_ret = complete_transaction_ertr::future<>;
virtual complete_transaction_ret complete_transaction(
Transaction &t) = 0;
@ -128,8 +124,7 @@ public:
* LogicalCachedExtent's and may also read in any dependent
* structures, etc.
*/
using init_cached_extent_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using init_cached_extent_ertr = base_ertr;
using init_cached_extent_ret = init_cached_extent_ertr::future<>;
virtual init_cached_extent_ret init_cached_extent(
Transaction &t,
@ -138,7 +133,7 @@ public:
/**
* Calls f for each mapping in [begin, end)
*/
using scan_mappings_ertr = SegmentManager::read_ertr;
using scan_mappings_ertr = base_ertr;
using scan_mappings_ret = scan_mappings_ertr::future<>;
using scan_mappings_func_t = std::function<
void(laddr_t, paddr_t, extent_len_t)>;
@ -151,7 +146,8 @@ public:
/**
* Calls f for each mapped space usage in [begin, end)
*/
using scan_mapped_space_ertr = SegmentManager::read_ertr;
using scan_mapped_space_ertr = base_ertr::extend_ertr<
SegmentManager::read_ertr>;
using scan_mapped_space_ret = scan_mapped_space_ertr::future<>;
using scan_mapped_space_func_t = std::function<
void(paddr_t, extent_len_t)>;
@ -164,8 +160,7 @@ public:
*
* rewrite extent into passed transaction
*/
using rewrite_extent_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using rewrite_extent_ertr = base_ertr;
using rewrite_extent_ret = rewrite_extent_ertr::future<>;
virtual rewrite_extent_ret rewrite_extent(
Transaction &t,
@ -180,8 +175,7 @@ public:
*
* Returns a null CachedExtentRef if extent is not live.
*/
using get_physical_extent_if_live_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using get_physical_extent_if_live_ertr = base_ertr;
using get_physical_extent_if_live_ret =
get_physical_extent_if_live_ertr::future<CachedExtentRef>;
virtual get_physical_extent_if_live_ret get_physical_extent_if_live(

View File

@ -39,7 +39,10 @@ BtreeLBAManager::mkfs_ret BtreeLBAManager::mkfs(
make_record_relative_paddr(0),
L_ADDR_NULL};
return mkfs_ertr::now();
});
}).handle_error(
mkfs_ertr::pass_further{},
crimson::ct_error::assert_all{}
);
}
BtreeLBAManager::get_root_ret

View File

@ -132,7 +132,7 @@ private:
*
* Get a reference to the root LBANode.
*/
using get_root_ertr = Cache::get_extent_ertr;
using get_root_ertr = base_ertr;
using get_root_ret = get_root_ertr::future<LBANodeRef>;
get_root_ret get_root(Transaction &);
@ -141,8 +141,7 @@ private:
*
* Insert a lba mapping into the tree
*/
using insert_mapping_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using insert_mapping_ertr = base_ertr;
using insert_mapping_ret = insert_mapping_ertr::future<LBAPinRef>;
insert_mapping_ret insert_mapping(
Transaction &t, ///< [in,out] transaction

View File

@ -13,6 +13,8 @@
namespace crimson::os::seastore::lba_manager::btree {
using base_ertr = LBAManager::base_ertr;
struct op_context_t {
Cache &cache;
btree_pin_set_t &pins;
@ -65,8 +67,7 @@ struct LBANode : CachedExtent {
* Returns the node at the specified depth responsible
* for laddr
*/
using lookup_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using lookup_ertr = base_ertr;
using lookup_ret = lookup_ertr::future<LBANodeRef>;
virtual lookup_ret lookup(
op_context_t c,
@ -91,9 +92,7 @@ struct LBANode : CachedExtent {
*
* Precondition: !at_max_capacity()
*/
using insert_ertr = crimson::errorator<
crimson::ct_error::input_output_error
>;
using insert_ertr = base_ertr;
using insert_ret = insert_ertr::future<LBAPinRef>;
virtual insert_ret insert(
op_context_t c,
@ -107,8 +106,7 @@ struct LBANode : CachedExtent {
*
* @return addr of hole, L_ADDR_NULL if unfound
*/
using find_hole_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using find_hole_ertr = base_ertr;
using find_hole_ret = find_hole_ertr::future<laddr_t>;
virtual find_hole_ret find_hole(
op_context_t c,
@ -148,9 +146,8 @@ struct LBANode : CachedExtent {
*
* Precondition: !at_min_capacity()
*/
using mutate_mapping_ertr = crimson::errorator<
crimson::ct_error::enoent, ///< mapping does not exist
crimson::ct_error::input_output_error
using mutate_mapping_ertr = base_ertr::extend<
crimson::ct_error::enoent ///< mapping does not exist
>;
using mutate_mapping_ret = mutate_mapping_ertr::future<
lba_map_val_t>;
@ -174,9 +171,8 @@ struct LBANode : CachedExtent {
* updates the mapping to paddr. Returns previous paddr
* (for debugging purposes).
*/
using mutate_internal_address_ertr = crimson::errorator<
crimson::ct_error::enoent, ///< mapping does not exist
crimson::ct_error::input_output_error
using mutate_internal_address_ertr = base_ertr::extend<
crimson::ct_error::enoent ///< mapping does not exist
>;
using mutate_internal_address_ret = mutate_internal_address_ertr::future<
paddr_t>;
@ -258,7 +254,9 @@ using LBANodeRef = LBANode::LBANodeRef;
*
* Fetches node at depth of the appropriate type.
*/
Cache::get_extent_ertr::future<LBANodeRef> get_lba_btree_extent(
using get_lba_node_ertr = base_ertr;
using get_lba_node_ret = get_lba_node_ertr::future<LBANodeRef>;
get_lba_node_ret get_lba_btree_extent(
op_context_t c, ///< [in] context structure
depth_t depth, ///< [in] depth of node to fetch
paddr_t offset, ///< [in] physical addr of node

View File

@ -643,7 +643,7 @@ LBALeafNode::get_leaf_entries(laddr_t addr, extent_len_t len)
return bound(addr, addr + len);
}
Cache::get_extent_ertr::future<LBANodeRef> get_lba_btree_extent(
get_lba_node_ertr::future<LBANodeRef> get_lba_btree_extent(
op_context_t c,
depth_t depth,
paddr_t offset,

View File

@ -271,9 +271,7 @@ struct LBAInternalNode
return std::make_pair(retl, retr);
}
using split_ertr = crimson::errorator<
crimson::ct_error::input_output_error
>;
using split_ertr = base_ertr;
using split_ret = split_ertr::future<LBANodeRef>;
split_ret split_entry(
op_context_t c,
@ -281,9 +279,7 @@ struct LBAInternalNode
internal_iterator_t,
LBANodeRef entry);
using merge_ertr = crimson::errorator<
crimson::ct_error::input_output_error
>;
using merge_ertr = base_ertr;
using merge_ret = merge_ertr::future<LBANodeRef>;
merge_ret merge_entry(
op_context_t c,

View File

@ -52,13 +52,15 @@ class OMapManager {
* until these functions future resolved.
*/
public:
using base_ertr = TransactionManager::base_ertr;
/**
* allocate omap tree root node
*
* @param Transaction &t, current transaction
* @retval return the omap_root_t structure.
*/
using initialize_omap_ertr = TransactionManager::alloc_extent_ertr;
using initialize_omap_ertr = base_ertr;
using initialize_omap_ret = initialize_omap_ertr::future<omap_root_t>;
virtual initialize_omap_ret initialize_omap(Transaction &t) = 0;
@ -70,7 +72,7 @@ public:
* @param string &key, omap string key
* @retval return string key->string value mapping pair.
*/
using omap_get_value_ertr = TransactionManager::read_extent_ertr;
using omap_get_value_ertr = base_ertr;
using omap_get_value_ret = omap_get_value_ertr::future<std::pair<std::string, std::string>>;
virtual omap_get_value_ret omap_get_value(const omap_root_t &omap_root, Transaction &t,
const std::string &key) = 0;
@ -84,7 +86,7 @@ public:
* @param string &value, mapped value corresponding key
* @retval mutation_result_t, status should be success.
*/
using omap_set_key_ertr = TransactionManager::read_extent_ertr;
using omap_set_key_ertr = base_ertr;
using omap_set_key_ret = omap_set_key_ertr::future<bool>;
virtual omap_set_key_ret omap_set_key(omap_root_t &omap_root, Transaction &t,
const std::string &key, const std::string &value) = 0;
@ -97,7 +99,7 @@ public:
* @param string &key, omap string key
* @retval remove success return true, else return false.
*/
using omap_rm_key_ertr = TransactionManager::read_extent_ertr;
using omap_rm_key_ertr = base_ertr;
using omap_rm_key_ret = omap_rm_key_ertr::future<bool>;
virtual omap_rm_key_ret omap_rm_key(omap_root_t &omap_root, Transaction &t,
const std::string &key) = 0;
@ -113,7 +115,7 @@ public:
* it it is not set, list all keys after string start
* @retval list_keys_result_t, listed keys and next key
*/
using omap_list_keys_ertr = TransactionManager::read_extent_ertr;
using omap_list_keys_ertr = base_ertr;
using omap_list_keys_ret = omap_list_keys_ertr::future<list_keys_result_t>;
virtual omap_list_keys_ret omap_list_keys(const omap_root_t &omap_root, Transaction &t,
std::string &start,
@ -130,7 +132,7 @@ public:
* it it is not set, list all keys after string start.
* @retval list_kvs_result_t, listed key->value mapping and next key.
*/
using omap_list_ertr = TransactionManager::read_extent_ertr;
using omap_list_ertr = base_ertr;
using omap_list_ret = omap_list_ertr::future<list_kvs_result_t>;
virtual omap_list_ret omap_list(const omap_root_t &omap_root, Transaction &t,
std::string &start,
@ -142,7 +144,7 @@ public:
* @param omap_root_t &omap_root, omap btree root information
* @param Transaction &t, current transaction
*/
using omap_clear_ertr = TransactionManager::read_extent_ertr;
using omap_clear_ertr = base_ertr;
using omap_clear_ret = omap_clear_ertr::future<>;
virtual omap_clear_ret omap_clear(omap_root_t &omap_root, Transaction &t) = 0;

View File

@ -73,9 +73,15 @@ BtreeOMapManager::handle_root_merge(omap_root_t &omap_root, omap_context_t oc,
omap_root.omap_root_laddr = iter->get_node_key().laddr;
omap_root.depth -= 1;
omap_root.state = omap_root_state_t::MUTATED;
return oc.tm.dec_ref(oc.t, root->get_laddr()).safe_then([] (auto &&ret) {
return oc.tm.dec_ref(oc.t, root->get_laddr()
).safe_then([] (auto &&ret) {
return handle_root_merge_ertr::make_ready_future<bool>(true);
});
}).handle_error(
handle_root_merge_ertr::pass_further{},
crimson::ct_error::assert_all{
"Invalid error in handle_root_merge"
}
);
}
@ -181,7 +187,12 @@ BtreeOMapManager::omap_clear(omap_root_t &omap_root, Transaction &t)
omap_root.omap_root_laddr = L_ADDR_NULL;
return omap_clear_ertr::now();
});
});
}).handle_error(
omap_clear_ertr::pass_further{},
crimson::ct_error::assert_all{
"Invalid error in BtreeOMapManager::omap_clear"
}
);
}
}

View File

@ -33,7 +33,7 @@ class BtreeOMapManager : public OMapManager {
*
* load omap tree root node
*/
using get_root_ertr = TransactionManager::read_extent_ertr;
using get_root_ertr = base_ertr;
using get_root_ret = get_root_ertr::future<OMapNodeRef>;
get_root_ret get_omap_root(const omap_root_t &omap_root, Transaction &t);
@ -41,7 +41,7 @@ class BtreeOMapManager : public OMapManager {
*
* root has been splitted and need update omap_root_t
*/
using handle_root_split_ertr = TransactionManager::read_extent_ertr;
using handle_root_split_ertr = base_ertr;
using handle_root_split_ret = handle_root_split_ertr::future<bool>;
handle_root_split_ret handle_root_split(omap_root_t &omap_root, omap_context_t oc,
OMapNode:: mutation_result_t mresult);
@ -50,7 +50,7 @@ class BtreeOMapManager : public OMapManager {
*
* root node has only one item and it is not leaf node, need remove a layer
*/
using handle_root_merge_ertr = TransactionManager::read_extent_ertr;
using handle_root_merge_ertr = base_ertr;
using handle_root_merge_ret = handle_root_merge_ertr::future<bool>;
handle_root_merge_ret handle_root_merge(omap_root_t &omap_root, omap_context_t oc,
OMapNode:: mutation_result_t mresult);

View File

@ -28,6 +28,8 @@ enum class mutation_status_t : uint8_t {
};
struct OMapNode : LogicalCachedExtent {
using base_ertr = OMapManager::base_ertr;
using OMapNodeRef = TCachedExtentRef<OMapNode>;
struct mutation_result_t {
@ -49,15 +51,15 @@ struct OMapNode : LogicalCachedExtent {
OMapNode(const OMapNode &other)
: LogicalCachedExtent(other) {}
using get_value_ertr = OMapManager::omap_get_value_ertr;
using get_value_ertr = base_ertr;
using get_value_ret = OMapManager::omap_get_value_ret;
virtual get_value_ret get_value(omap_context_t oc, const std::string &key) = 0;
using insert_ertr = TransactionManager::alloc_extent_ertr;
using insert_ertr = base_ertr;
using insert_ret = insert_ertr::future<mutation_result_t>;
virtual insert_ret insert(omap_context_t oc, const std::string &key, const std::string &value) = 0;
using rm_key_ertr = TransactionManager::alloc_extent_ertr;
using rm_key_ertr = base_ertr;
using rm_key_ret = rm_key_ertr::future<mutation_result_t>;
virtual rm_key_ret rm_key(omap_context_t oc, const std::string &key) = 0;
@ -66,19 +68,19 @@ struct OMapNode : LogicalCachedExtent {
virtual list_keys_ret list_keys(omap_context_t oc, std::string &start,
size_t max_result_size) = 0;
using list_ertr = OMapManager::omap_list_ertr;
using list_ertr = base_ertr;
using list_ret = OMapManager::omap_list_ret;
virtual list_ret list(omap_context_t oc, std::string &start, size_t max_result_size) = 0;
using clear_ertr = OMapManager::omap_clear_ertr;
using clear_ertr = base_ertr;
using clear_ret = clear_ertr::future<>;
virtual clear_ret clear(omap_context_t oc) = 0;
using full_merge_ertr = TransactionManager::alloc_extent_ertr;
using full_merge_ertr = base_ertr;
using full_merge_ret = full_merge_ertr::future<OMapNodeRef>;
virtual full_merge_ret make_full_merge(omap_context_t oc, OMapNodeRef right) = 0;
using make_balanced_ertr = TransactionManager::alloc_extent_ertr;
using make_balanced_ertr = base_ertr;
using make_balanced_ret = make_balanced_ertr::future
<std::tuple<OMapNodeRef, OMapNodeRef, std::string>>;
virtual make_balanced_ret make_balanced(omap_context_t oc, OMapNodeRef _right) = 0;
@ -93,7 +95,8 @@ struct OMapNode : LogicalCachedExtent {
using OMapNodeRef = OMapNode::OMapNodeRef;
TransactionManager::read_extent_ertr::future<OMapNodeRef>
using omap_load_extent_ertr = OMapNode::base_ertr;
omap_load_extent_ertr::future<OMapNodeRef>
omap_load_extent(omap_context_t oc, laddr_t laddr, depth_t depth);
}

View File

@ -36,6 +36,19 @@ std::ostream &OMapInnerNode::print_detail_l(std::ostream &out) const
<< ", depth=" << get_meta().depth;
}
using dec_ref_ertr = OMapInnerNode::base_ertr;
using dec_ref_ret = dec_ref_ertr::future<>;
template <typename... T>
dec_ref_ret dec_ref(omap_context_t oc, T&&... addr) {
return oc.tm.dec_ref(oc.t, std::forward<T>(addr)...
).handle_error(
dec_ref_ertr::pass_further{},
crimson::ct_error::assert_all{
"Invalid error in OMapInnerNode helper dec_ref"
}
).safe_then([](auto &&e) {});
}
/**
* make_split_insert
*
@ -88,8 +101,8 @@ OMapInnerNode::handle_split(omap_context_t oc, internal_iterator_t iter,
} else {
return make_split_insert(oc, iter + 1, pivot, right->get_laddr())
.safe_then([this, oc] (auto m_result) {
return oc.tm.dec_ref(oc.t, get_laddr())
.safe_then([m_result = std::move(m_result)] (auto ret) {
return dec_ref(oc, get_laddr())
.safe_then([m_result = std::move(m_result)] {
return insert_ret(
insert_ertr::ready_future_marker{},
m_result);
@ -249,8 +262,8 @@ OMapInnerNode::clear(omap_context_t oc)
[oc] (auto &&extent) {
return extent->clear(oc);
}).safe_then([oc, laddr] {
return oc.tm.dec_ref(oc.t, laddr);
}).safe_then([ref = OMapNodeRef(this)] (auto ret){
return dec_ref(oc, laddr);
}).safe_then([ref = OMapNodeRef(this)] {
return clear_ertr::now();
});
});
@ -326,7 +339,7 @@ OMapInnerNode::merge_entry(omap_context_t oc, internal_iterator_t iter, OMapNode
journal_inner_remove(riter, maybe_get_delta_buffer());
//retire extent
std::vector<laddr_t> dec_laddrs {l->get_laddr(), r->get_laddr()};
return oc.tm.dec_ref(oc.t, dec_laddrs).safe_then([this, oc] (auto &&ret) {
return dec_ref(oc, dec_laddrs).safe_then([this, oc] {
if (extent_is_below_min()) {
return merge_entry_ret(
merge_entry_ertr::ready_future_marker{},
@ -350,7 +363,7 @@ OMapInnerNode::merge_entry(omap_context_t oc, internal_iterator_t iter, OMapNode
journal_inner_replace(riter, replacement_r->get_laddr(),
replacement_pivot, maybe_get_delta_buffer());
std::vector<laddr_t> dec_laddrs{l->get_laddr(), r->get_laddr()};
return oc.tm.dec_ref(oc.t, dec_laddrs).safe_then([] (auto &&ret) {
return dec_ref(oc, dec_laddrs).safe_then([] {
return merge_entry_ret(
merge_entry_ertr::ready_future_marker{},
mutation_result_t(mutation_status_t::SUCCESS, std::nullopt, std::nullopt));
@ -363,8 +376,8 @@ OMapInnerNode::merge_entry(omap_context_t oc, internal_iterator_t iter, OMapNode
return make_split_insert(oc, riter, replacement_pivot, replacement_r->get_laddr())
.safe_then([this, oc, l = l, r = r] (auto mresult) {
std::vector<laddr_t> dec_laddrs{l->get_laddr(), r->get_laddr(), get_laddr()};
return oc.tm.dec_ref(oc.t, dec_laddrs)
.safe_then([mresult = std::move(mresult)] (auto &&ret){
return dec_ref(oc, dec_laddrs)
.safe_then([mresult = std::move(mresult)] {
return merge_entry_ret(
merge_entry_ertr::ready_future_marker{},
mresult);
@ -456,8 +469,8 @@ OMapLeafNode::insert(omap_context_t oc, const std::string &key, const std::strin
right->journal_leaf_insert(mut_iter, key, value, right->maybe_get_delta_buffer());
}
}
return oc.tm.dec_ref(oc.t, get_laddr())
.safe_then([tuple = std::move(tuple)] (auto ret) {
return dec_ref(oc, get_laddr())
.safe_then([tuple = std::move(tuple)] {
return insert_ret(
insert_ertr::ready_future_marker{},
mutation_result_t(mutation_status_t::WAS_SPLIT, tuple, std::nullopt));
@ -592,23 +605,31 @@ OMapLeafNode::make_balanced(omap_context_t oc, OMapNodeRef _right)
}
TransactionManager::read_extent_ertr::future<OMapNodeRef>
omap_load_extent_ertr::future<OMapNodeRef>
omap_load_extent(omap_context_t oc, laddr_t laddr, depth_t depth)
{
ceph_assert(depth > 0);
if (depth > 1) {
return oc.tm.read_extents<OMapInnerNode>(oc.t, laddr, OMAP_BLOCK_SIZE).safe_then(
return oc.tm.read_extents<OMapInnerNode>(oc.t, laddr, OMAP_BLOCK_SIZE
).handle_error(
omap_load_extent_ertr::pass_further{},
crimson::ct_error::assert_all{ "Invalid error in omap_load_extent" }
).safe_then(
[](auto&& extents) {
assert(extents.size() == 1);
[[maybe_unused]] auto [laddr, e] = extents.front();
return TransactionManager::read_extent_ertr::make_ready_future<OMapNodeRef>(std::move(e));
return seastar::make_ready_future<OMapNodeRef>(std::move(e));
});
} else {
return oc.tm.read_extents<OMapLeafNode>(oc.t, laddr, OMAP_BLOCK_SIZE).safe_then(
return oc.tm.read_extents<OMapLeafNode>(oc.t, laddr, OMAP_BLOCK_SIZE
).handle_error(
omap_load_extent_ertr::pass_further{},
crimson::ct_error::assert_all{ "Invalid error in omap_load_extent" }
).safe_then(
[](auto&& extents) {
assert(extents.size() == 1);
[[maybe_unused]] auto [laddr, e] = extents.front();
return TransactionManager::read_extent_ertr::make_ready_future<OMapNodeRef>(std::move(e));
return seastar::make_ready_future<OMapNodeRef>(std::move(e));
});
}
}

View File

@ -68,7 +68,7 @@ struct OMapInnerNode
clear_ret clear(omap_context_t oc) final;
using split_children_ertr = TransactionManager::alloc_extent_ertr;
using split_children_ertr = base_ertr;
using split_children_ret = split_children_ertr::future
<std::tuple<OMapInnerNodeRef, OMapInnerNodeRef, std::string>>;
split_children_ret make_split_children(omap_context_t oc);
@ -78,17 +78,17 @@ struct OMapInnerNode
make_balanced_ret
make_balanced(omap_context_t oc, OMapNodeRef right) final;
using make_split_insert_ertr = TransactionManager::alloc_extent_ertr;
using make_split_insert_ertr = base_ertr;
using make_split_insert_ret = make_split_insert_ertr::future<mutation_result_t>;
make_split_insert_ret make_split_insert(omap_context_t oc, internal_iterator_t iter,
std::string key, laddr_t laddr);
using merge_entry_ertr = TransactionManager::read_extent_ertr;
using merge_entry_ertr = base_ertr;
using merge_entry_ret = merge_entry_ertr::future<mutation_result_t>;
merge_entry_ret merge_entry(omap_context_t oc,
internal_iterator_t iter, OMapNodeRef entry);
using handle_split_ertr = TransactionManager::read_extent_ertr;
using handle_split_ertr = base_ertr;
using handle_split_ret = handle_split_ertr::future<mutation_result_t>;
handle_split_ret handle_split(omap_context_t oc, internal_iterator_t iter,
mutation_result_t mresult);
@ -170,7 +170,7 @@ struct OMapLeafNode
clear_ret clear(omap_context_t oc) final;
using split_children_ertr = TransactionManager::alloc_extent_ertr;
using split_children_ertr = base_ertr;
using split_children_ret = split_children_ertr::future
<std::tuple<OMapLeafNodeRef, OMapLeafNodeRef, std::string>>;
split_children_ret make_split_children(omap_context_t oc);

View File

@ -132,7 +132,8 @@ class Node
crimson::ct_error::input_output_error,
crimson::ct_error::invarg,
crimson::ct_error::enoent,
crimson::ct_error::erange>;
crimson::ct_error::erange,
crimson::ct_error::eagain>;
template <class ValueT=void>
using node_future = node_ertr::future<ValueT>;

View File

@ -64,7 +64,8 @@ class NodeExtentManager {
crimson::ct_error::input_output_error,
crimson::ct_error::invarg,
crimson::ct_error::enoent,
crimson::ct_error::erange>;
crimson::ct_error::erange,
crimson::ct_error::eagain>;
template <class ValueT=void>
using tm_future = tm_ertr::future<ValueT>;

View File

@ -62,7 +62,9 @@ class NodeImpl {
crimson::ct_error::input_output_error,
crimson::ct_error::invarg,
crimson::ct_error::enoent,
crimson::ct_error::erange>;
crimson::ct_error::erange,
crimson::ct_error::eagain
>;
virtual ~NodeImpl() = default;
virtual field_type_t field_type() const = 0;

View File

@ -33,7 +33,8 @@ class Btree {
crimson::ct_error::input_output_error,
crimson::ct_error::invarg,
crimson::ct_error::enoent,
crimson::ct_error::erange>;
crimson::ct_error::erange,
crimson::ct_error::eagain>;
template <class ValueT=void>
using btree_future = btree_ertr::future<ValueT>;

View File

@ -246,7 +246,7 @@ SegmentCleaner::rewrite_dirty_ret SegmentCleaner::rewrite_dirty(
limit
).then([=, &t](auto dirty_list) {
if (dirty_list.empty()) {
return do_immediate_work_ertr::now();
return rewrite_dirty_ertr::now();
} else {
update_journal_tail_target(dirty_list.front()->get_dirty_from());
}

View File

@ -252,6 +252,10 @@ public:
journal_seq_t bound ///< [in] return extents with dirty_from < bound
) = 0;
using extent_mapping_ertr = crimson::errorator<
crimson::ct_error::input_output_error,
crimson::ct_error::eagain>;
/**
* rewrite_extent
*
@ -260,8 +264,7 @@ public:
* handle finding the current instance if it is still alive and
* otherwise ignore it.
*/
using rewrite_extent_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using rewrite_extent_ertr = extent_mapping_ertr;
using rewrite_extent_ret = rewrite_extent_ertr::future<>;
virtual rewrite_extent_ret rewrite_extent(
Transaction &t,
@ -276,8 +279,7 @@ public:
* See TransactionManager::get_extent_if_live and
* LBAManager::get_physical_extent_if_live.
*/
using get_extent_if_live_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using get_extent_if_live_ertr = extent_mapping_ertr;
using get_extent_if_live_ret = get_extent_if_live_ertr::future<
CachedExtentRef>;
virtual get_extent_if_live_ret get_extent_if_live(
@ -455,6 +457,8 @@ public:
return space_tracker->equals(tracker);
}
using work_ertr = ExtentCallbackInterface::extent_mapping_ertr;
/**
* do_immediate_work
*
@ -462,8 +466,7 @@ public:
* will piggy-back work required to maintain deferred work
* constraints.
*/
using do_immediate_work_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using do_immediate_work_ertr = work_ertr;
using do_immediate_work_ret = do_immediate_work_ertr::future<>;
do_immediate_work_ret do_immediate_work(
Transaction &t);
@ -479,8 +482,7 @@ public:
* back into do_deferred_work before returned timespan has elapsed,
* or a foreground operation occurs.
*/
using do_deferred_work_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using do_deferred_work_ertr = work_ertr;
using do_deferred_work_ret = do_deferred_work_ertr::future<
ceph::timespan
>;
@ -496,8 +498,7 @@ private:
*
* Writes out dirty blocks dirtied earlier than limit.
*/
using rewrite_dirty_ertr = crimson::errorator<
crimson::ct_error::input_output_error>;
using rewrite_dirty_ertr = ExtentCallbackInterface::extent_mapping_ertr;
using rewrite_dirty_ret = rewrite_dirty_ertr::future<>;
rewrite_dirty_ret rewrite_dirty(
Transaction &t,
@ -527,7 +528,8 @@ private:
*
* Performs bytes worth of gc work on t.
*/
using do_gc_ertr = SegmentManager::read_ertr;
using do_gc_ertr = ExtentCallbackInterface::extent_mapping_ertr::extend_ertr<
ExtentCallbackInterface::scan_extents_ertr>;
using do_gc_ret = do_gc_ertr::future<>;
do_gc_ret do_gc(
Transaction &t,

View File

@ -38,6 +38,8 @@ class Journal;
*/
class TransactionManager : public SegmentCleaner::ExtentCallbackInterface {
public:
using base_ertr = Cache::base_ertr;
TransactionManager(
SegmentManager &segment_manager,
SegmentCleaner &segment_cleaner,
@ -76,7 +78,8 @@ public:
/**
* Read extents corresponding to specified lba range
*/
using read_extent_ertr = SegmentManager::read_ertr;
using read_extent_ertr = LBAManager::get_mapping_ertr::extend_ertr<
SegmentManager::read_ertr>;
template <typename T>
using read_extent_ret = read_extent_ertr::future<lextent_list_t<T>>;
template <typename T>
@ -189,7 +192,7 @@ public:
* Allocates a new block of type T with the minimum lba range of size len
* greater than hint.
*/
using alloc_extent_ertr = SegmentManager::read_ertr;
using alloc_extent_ertr = LBAManager::alloc_extent_ertr;
template <typename T>
using alloc_extent_ret = alloc_extent_ertr::future<TCachedExtentRef<T>>;
template <typename T>
@ -295,9 +298,7 @@ public:
*
* Get onode-tree root logical address
*/
using read_onode_root_ertr = crimson::errorator<
crimson::ct_error::input_output_error
>;
using read_onode_root_ertr = read_extent_ertr;
using read_onode_root_ret = read_onode_root_ertr::future<laddr_t>;
read_onode_root_ret read_onode_root(Transaction &t) {
return cache.get_root(t).safe_then([](auto croot) {