From: Myoungwon Oh Date: Tue, 12 Dec 2023 09:55:47 +0000 (+0900) Subject: crimson/os/seastore/cache: reset version to 1 if inplace write occurs before in prepa... X-Git-Tag: v19.3.0~272^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1b29691318b93dd3e2a20cae0bc7b878f3a837c3;p=ceph.git crimson/os/seastore/cache: reset version to 1 if inplace write occurs before in prepare_record Signed-off-by: Myoungwon Oh --- diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index 8645a3071062..fe42efa74ad7 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -1096,6 +1096,20 @@ record_t Cache::prepare_record( if (!i->is_exist_mutation_pending()) { DEBUGT("commit replace extent ... -- {}, prior={}", t, *i, *i->prior_instance); + // If inplace rewrite occurs during mutation, prev->version will + // be zero. Although this results in the version mismatch here, we can + // correct this by changing version to 1. This is because the inplace rewrite + // does not introduce any actual modification that could negatively + // impact system reliability + if (i->prior_instance->version == 0 && i->version > 1) { + assert(can_inplace_rewrite(i->get_type())); + assert(can_inplace_rewrite(i->prior_instance->get_type())); + assert(i->prior_instance->dirty_from_or_retired_at == JOURNAL_SEQ_MIN); + assert(i->prior_instance->state == CachedExtent::extent_state_t::CLEAN); + assert(i->prior_instance->get_paddr().get_addr_type() == + paddr_types_t::RANDOM_BLOCK); + i->version = 1; + } // extent with EXIST_MUTATION_PENDING doesn't have // prior_instance field so skip these extents. // the existing extents should be added into Cache