From: Alex Ainscow Date: Fri, 25 Apr 2025 08:13:46 +0000 (+0100) Subject: osd: Use correct shard_versions when queuing multiple writes in optimized EC. X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6ab686fefcef4bf83e2b77164c39c9c7d00c567c;p=ceph.git osd: Use correct shard_versions when queuing multiple writes in optimized EC. The problem was that incorrect shard_versions were being detected by scrub. The comment in the code explains the detailed problem and solution. Signed-off-by: Alex Ainscow --- diff --git a/src/osd/ECTransaction.cc b/src/osd/ECTransaction.cc index d727f721de221..cc1abcbebc62b 100644 --- a/src/osd/ECTransaction.cc +++ b/src/osd/ECTransaction.cc @@ -876,7 +876,20 @@ void ECTransaction::Generate::written_and_present_shards() { // written if (op.attr_updates.contains(OI_ATTR)) { object_info_t oi(*(op.attr_updates[OI_ATTR])); - bool update = false; + // The majority of the updates to OI are made before a transaction is + // submitted to ECBackend, these are cached by OBC and are encoded into + // the OI attr update for the transaction. By the time the transaction + // gets here the OBC cached copy may have been advanced by further in + // flight writes that will be committed after this one. + // + // The exception is oi.shard_versions which is updated here. We therefore + // need to update the OI attr update with the latest version from the + // cache here (to account for any modifications made by previous in flight + // transactions), make any required modifications to shard_versions and + // then update the OBC cached copy and the encoded OI attr. + bool update = oi.shard_versions != obc->obs.oi.shard_versions; + oi.shard_versions = obc->obs.oi.shard_versions; + if (entry->written_shards.empty()) { if (!oi.shard_versions.empty()) { oi.shard_versions.clear();