Skip to content

Commit 739139b

Browse files
authored
Merge pull request ceph#60817 from cyx1231st/wip-seastore-improve-get_extents_if_live
crimson/os/seastore/transaction_manager: improve get_extents_if_live() Reviewed-by: Xuehan Xu <[email protected]>
2 parents 63e69b8 + a783081 commit 739139b

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/crimson/os/seastore/transaction_manager.cc

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ TransactionManager::get_extents_if_live(
726726
ceph_assert(paddr.get_addr_type() == paddr_types_t::SEGMENT);
727727

728728
return cache->get_extent_if_cached(t, paddr, type
729-
).si_then([=, this, &t](auto extent)
729+
).si_then([this, FNAME, type, paddr, laddr, len, &t](auto extent)
730730
-> get_extents_if_live_ret {
731731
if (extent && extent->get_length() == len) {
732732
DEBUGT("{} {}~0x{:x} {} is cached and alive -- {}",
@@ -743,19 +743,24 @@ TransactionManager::get_extents_if_live(
743743
t,
744744
laddr,
745745
len
746-
).si_then([=, this, &t](lba_pin_list_t pin_list) {
746+
).si_then([this, FNAME, type, paddr, laddr, len, &t](lba_pin_list_t pin_list) {
747747
return seastar::do_with(
748748
std::list<CachedExtentRef>(),
749-
[=, this, &t, pin_list=std::move(pin_list)](
750-
std::list<CachedExtentRef> &list) mutable
749+
std::move(pin_list),
750+
[this, FNAME, type, paddr, laddr, len, &t]
751+
(std::list<CachedExtentRef> &extent_list, auto& pin_list)
751752
{
752753
auto paddr_seg_id = paddr.as_seg_paddr().get_segment_id();
753754
return trans_intr::parallel_for_each(
754755
pin_list,
755-
[=, this, &list, &t](
756-
LBAMappingRef &pin) -> Cache::get_extent_iertr::future<>
756+
[this, FNAME, type, paddr_seg_id, &extent_list, &t](
757+
LBAMappingRef& pin) -> Cache::get_extent_iertr::future<>
757758
{
759+
DEBUGT("got pin, try read in parallel ... -- {}", t, *pin);
758760
auto pin_paddr = pin->get_val();
761+
if (pin_paddr.get_addr_type() != paddr_types_t::SEGMENT) {
762+
return seastar::now();
763+
}
759764
auto &pin_seg_paddr = pin_paddr.as_seg_paddr();
760765
auto pin_paddr_seg_id = pin_seg_paddr.get_segment_id();
761766
// auto pin_len = pin->get_length();
@@ -779,16 +784,16 @@ TransactionManager::get_extents_if_live(
779784
// ceph_assert(pin_seg_paddr >= paddr &&
780785
// pin_seg_paddr.add_offset(pin_len) <= paddr.add_offset(len));
781786
return read_pin_by_type(t, std::move(pin), type
782-
).si_then([&list](auto ret) {
783-
list.emplace_back(std::move(ret));
787+
).si_then([&extent_list](auto ret) {
788+
extent_list.emplace_back(std::move(ret));
784789
return seastar::now();
785790
});
786-
}).si_then([&list, &t, FNAME, type, laddr, len, paddr] {
791+
}).si_then([&extent_list, &t, FNAME, type, laddr, len, paddr] {
787792
DEBUGT("{} {}~0x{:x} {} is alive as {} extents",
788-
t, type, laddr, len, paddr, list.size());
793+
t, type, laddr, len, paddr, extent_list.size());
789794
return get_extents_if_live_ret(
790795
interruptible::ready_future_marker{},
791-
std::move(list));
796+
std::move(extent_list));
792797
});
793798
});
794799
}).handle_error_interruptible(crimson::ct_error::enoent::handle([] {

src/crimson/os/seastore/transaction_manager.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,11 @@ class TransactionManager : public ExtentCallbackInterface {
993993
// checking the lba child must be atomic with creating
994994
// and linking the absent child
995995
if (v.has_child()) {
996-
return std::move(v.get_child_fut());
996+
return std::move(v.get_child_fut()
997+
).si_then([type](auto ext) {
998+
ceph_assert(ext->get_type() == type);
999+
return ext;
1000+
});
9971001
} else {
9981002
return pin_to_extent_by_type(t, std::move(pin), type);
9991003
}

0 commit comments

Comments
 (0)