Skip to content

Commit 7d2cade

Browse files
authored
Merge pull request ceph#59392 from cyx1231st/wip-inplace-rewrite-comments
crimson/os/seastore: refine documents related to inplace rewrite Reviewed-by: Myoungwon Oh <[email protected]>
2 parents 8ae876c + f74b8bb commit 7d2cade

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/crimson/os/seastore/cache.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,11 +1148,14 @@ record_t Cache::prepare_record(
11481148
if (!i->is_exist_mutation_pending()) {
11491149
DEBUGT("commit replace extent ... -- {}, prior={}",
11501150
t, *i, *i->prior_instance);
1151-
// If inplace rewrite occurs during mutation, prev->version will
1152-
// be zero. Although this results in the version mismatch here, we can
1153-
// correct this by changing version to 1. This is because the inplace rewrite
1154-
// does not introduce any actual modification that could negatively
1155-
// impact system reliability
1151+
1152+
// If inplace rewrite happens from a concurrent transaction,
1153+
// i->prior_instance will be changed from DIRTY to CLEAN implicitly, thus
1154+
// i->prior_instance->version become 0. This won't cause conflicts
1155+
// intentionally because inplace rewrite won't modify the shared extent.
1156+
//
1157+
// However, this leads to version mismatch below, thus we reset the
1158+
// version to 1 in this case.
11561159
if (i->prior_instance->version == 0 && i->version > 1) {
11571160
assert(can_inplace_rewrite(i->get_type()));
11581161
assert(can_inplace_rewrite(i->prior_instance->get_type()));
@@ -1162,6 +1165,7 @@ record_t Cache::prepare_record(
11621165
paddr_types_t::RANDOM_BLOCK);
11631166
i->version = 1;
11641167
}
1168+
11651169
// extent with EXIST_MUTATION_PENDING doesn't have
11661170
// prior_instance field so skip these extents.
11671171
// the existing extents should be added into Cache
@@ -1926,6 +1930,7 @@ Cache::replay_delta(
19261930
ceph_assert_always(extent->last_committed_crc == delta.final_crc);
19271931
} else {
19281932
assert(delta.paddr.get_addr_type() == paddr_types_t::RANDOM_BLOCK);
1933+
// see prepare_record(), inplace rewrite might cause version mismatch
19291934
extent->apply_delta_and_adjust_crc(record_base, delta.bl);
19301935
extent->set_modify_time(modify_time);
19311936
// crc will be checked after journal replay is done

src/crimson/os/seastore/transaction_manager.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ TransactionManager::rewrite_extent_ret TransactionManager::rewrite_extent(
639639
assert(extent->is_valid() && !extent->is_initial_pending());
640640
if (extent->is_dirty()) {
641641
if (epm->can_inplace_rewrite(t, extent)) {
642+
// FIXME: is_dirty() is true for mutation pending extents
643+
// which shouldn't do inplace rewrite because a pending transaction
644+
// may fail.
642645
DEBUGT("delta overwriting extent -- {}", t, *extent);
643646
t.add_inplace_rewrite_extent(extent);
644647
extent->set_inplace_rewrite_generation();

0 commit comments

Comments
 (0)