@@ -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
0 commit comments