Skip to content

Commit 1c91120

Browse files
committed
crimson/os/seastore/epm: RandomBlockOolWriter to update extents upon submitting writes
In order to move the ool write futures out of the collection lock, which will be after the transaction prepare phase. Signed-off-by: Yingxin Cheng <[email protected]>
1 parent 48ff8f0 commit 1c91120

File tree

2 files changed

+37
-26
lines changed

2 files changed

+37
-26
lines changed

src/crimson/os/seastore/extent_placement_manager.cc

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,13 +1008,15 @@ RandomBlockOolWriter::do_write(
10081008
assert(!extents.empty());
10091009
DEBUGT("start with {} allocated extents",
10101010
t, extents.size());
1011-
return trans_intr::do_for_each(extents,
1012-
[this, &t, FNAME](auto& ex) {
1011+
std::vector<write_info_t> writes;
1012+
writes.reserve(extents.size());
1013+
for (auto& ex : extents) {
10131014
auto paddr = ex->get_paddr();
10141015
assert(paddr.is_absolute());
10151016
RandomBlockManager * rbm = rb_cleaner->get_rbm(paddr);
10161017
assert(rbm);
1017-
TRACE("extent {}, allocated addr {}", fmt::ptr(ex.get()), paddr);
1018+
TRACE("write extent {}, paddr {} ...",
1019+
fmt::ptr(ex.get()), paddr);
10181020
auto& stats = t.get_ool_write_stats();
10191021
stats.extents.num += 1;
10201022
stats.extents.bytes += ex->get_length();
@@ -1038,29 +1040,33 @@ RandomBlockOolWriter::do_write(
10381040
trans_stats.data_bytes += ex->get_length();
10391041
w_stats.data_bytes += ex->get_length();
10401042
}
1041-
return trans_intr::make_interruptible(
1042-
rbm->write(paddr + offset,
1043-
bp
1044-
).handle_error(
1045-
alloc_write_ertr::pass_further{},
1046-
crimson::ct_error::assert_all{
1047-
"Invalid error when writing record"}
1048-
)
1049-
).si_then([this, &t, &ex, paddr, FNAME] {
1050-
TRACET("ool extent written at {} -- {}",
1051-
t, paddr, *ex);
1052-
if (ex->is_initial_pending()) {
1053-
t.mark_allocated_extent_ool(ex);
1054-
} else if (can_inplace_rewrite(t, ex)) {
1055-
assert(ex->is_logical());
1056-
t.mark_inplace_rewrite_extent_ool(
1057-
ex->template cast<LogicalCachedExtent>());
1058-
} else {
1059-
ceph_assert("impossible");
1060-
}
1061-
return alloc_write_iertr::now();
1062-
});
1063-
});
1043+
writes.push_back(write_info_t{paddr + offset, std::move(bp), rbm});
1044+
1045+
if (ex->is_initial_pending()) {
1046+
t.mark_allocated_extent_ool(ex);
1047+
} else if (can_inplace_rewrite(t, ex)) {
1048+
assert(ex->is_logical());
1049+
t.mark_inplace_rewrite_extent_ool(
1050+
ex->template cast<LogicalCachedExtent>());
1051+
} else {
1052+
ceph_assert("impossible");
1053+
}
1054+
}
1055+
1056+
return trans_intr::make_interruptible(
1057+
seastar::do_with(std::move(writes),
1058+
[](auto& writes) {
1059+
return crimson::do_for_each(writes,
1060+
[](auto& info) {
1061+
return info.rbm->write(info.offset, info.bp
1062+
).handle_error(
1063+
alloc_write_ertr::pass_further{},
1064+
crimson::ct_error::assert_all{
1065+
"Invalid error when writing record"}
1066+
);
1067+
});
1068+
})
1069+
);
10641070
}
10651071

10661072
}

src/crimson/os/seastore/extent_placement_manager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ class RandomBlockOolWriter : public ExtentOolWriter {
190190
}
191191
#endif
192192
private:
193+
struct write_info_t {
194+
paddr_t offset;
195+
ceph::bufferptr bp;
196+
RandomBlockManager* rbm;
197+
};
193198
alloc_write_iertr::future<> do_write(
194199
Transaction& t,
195200
std::list<CachedExtentRef> &extent);

0 commit comments

Comments
 (0)