});
}
- ref_ret remove_mapping(
- Transaction &t,
- laddr_t addr) final {
- auto result = co_await update_refcount(t, addr, -1);
- ceph_assert(result.refcount == 0);
- if (result.addr.is_paddr()) {
- co_return ref_update_result_t{std::move(result), std::nullopt};
- }
-
- auto direct_result = co_await update_refcount(t, result.key, -1);
- result.mapping = co_await result.mapping.refresh();
- co_return ref_update_result_t{
- std::move(result),
- std::move(direct_result)
- };
- }
-
- ref_ret remove_mapping(
- Transaction &t,
- LBAMapping mapping) final {
- assert(mapping.is_viewable());
- assert(mapping.is_complete());
- return seastar::do_with(
- std::move(mapping),
- [&t, this](auto &mapping) {
- auto &cursor = mapping.get_effective_cursor();
- return update_refcount(t, &cursor, -1
- ).si_then([this, &t, &mapping](auto res) {
- ceph_assert(res.refcount == 0);
- if (res.addr.is_paddr()) {
- assert(!mapping.is_indirect());
- return ref_iertr::make_ready_future<
- ref_update_result_t>(ref_update_result_t{
- std::move(res), std::nullopt});
- }
- assert(mapping.is_indirect());
- auto &cursor = *mapping.direct_cursor;
- return cursor.refresh().si_then([this, &t, &cursor] {
- return update_refcount(t, &cursor, -1);
- }).si_then([indirect_result=std::move(res)]
- (auto direct_result) mutable {
- return indirect_result.mapping.refresh(
- ).si_then([direct_result=std::move(direct_result),
- indirect_result=std::move(indirect_result)](auto) {
- return ref_iertr::make_ready_future<
- ref_update_result_t>(ref_update_result_t{
- std::move(indirect_result),
- std::move(direct_result)});
- });
- });
- });
- });
- }
-
base_iertr::future<LBACursorRef> update_mapping_refcount(
Transaction &t,
LBACursorRef cursor,
return refcount == 0 && addr.is_paddr() && !addr.get_paddr().is_zero();
}
};
- struct ref_update_result_t {
- mapping_update_result_t result;
- std::optional<mapping_update_result_t> direct_result;
- };
using ref_iertr = base_iertr::extend<
crimson::ct_error::enoent>;
- using ref_ret = ref_iertr::future<ref_update_result_t>;
-
- /**
- * Removes a mapping and deal with indirection
- *
- * @return returns the information about the removed
- * mappings including the corresponding direct mapping
- * if the mapping of laddr is indirect.
- */
- virtual ref_ret remove_mapping(
- Transaction &t,
- laddr_t addr) = 0;
-
- /*
- * Removes the mapping and deal with indirection
- *
- * @return returns the information about the removed
- * mappings including the corresponding direct mapping
- * if the mapping of laddr is indirect.
- */
- virtual ref_ret remove_mapping(
- Transaction &t,
- LBAMapping mapping) = 0;
/**
* Update ref count on mapping
(void) with_trans_intr(
*t.t,
- [=, this](auto &t) {
- return lba_manager->remove_mapping(
+ seastar::coroutine::lambda([=, this](auto &t)
+ -> LBAManager::ref_iertr::future<> {
+
+ auto cursor = co_await lba_manager->get_cursor(
t,
- target->first
- ).si_then([this, &t, target](auto result) {
- EXPECT_EQ(result.result.refcount, target->second.refcount);
- if (result.result.refcount == 0) {
- return cache->retire_extent_addr(
- t, result.result.addr.get_paddr(), result.result.length);
- }
- return Cache::retire_extent_iertr::now();
- });
- }).unsafe_get();
+ target->first);
+ auto refcount = cursor->get_refcount() - 1;
+ co_await lba_manager->update_mapping_refcount(
+ t,
+ cursor,
+ -1
+ );
+ EXPECT_EQ(refcount, target->second.refcount);
+ if (refcount == 0) {
+ co_await cache->retire_extent_addr(
+ t, cursor->get_paddr(), cursor->get_length());
+ }
+ })).unsafe_get();
if (target->second.refcount == 0) {
t.mappings.erase(target);
}