From: Alex Ainscow Date: Fri, 3 Oct 2025 12:53:33 +0000 (+0100) Subject: osd: Replace unused EC offset translation function with useful one. X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=454ea7cdee30df29deeadcfe0a2d8f488931a40b;p=ceph.git osd: Replace unused EC offset translation function with useful one. The old chunk_aligned_shard_offset_to_ro_offset was not only unused, it didn't actually have the correct logic. We replace it here with similar, but more useful function that will be used in sparse reads for EC Signed-off-by: Alex Ainscow --- diff --git a/src/osd/ECUtil.h b/src/osd/ECUtil.h index deaf39cd53fa..342101829a67 100644 --- a/src/osd/ECUtil.h +++ b/src/osd/ECUtil.h @@ -766,9 +766,10 @@ public: return ((len + stripe_width - 1) / stripe_width) * chunk_size; } - uint64_t chunk_aligned_shard_offset_to_ro_offset(uint64_t offset) const { - ceph_assert(offset % chunk_size == 0); - return (offset / chunk_size) * stripe_width; + uint64_t shard_offset_to_ro_offset(shard_id_t shard, uint64_t offset) const { + raw_shard_id_t raw_shard = get_raw_shard(shard); + auto result = std::lldiv(offset, chunk_size); + return result.quot * stripe_width + (int)raw_shard * chunk_size + result.rem; } std::pair chunk_aligned_ro_range_to_shard_ro_range( diff --git a/src/test/osd/TestECBackend.cc b/src/test/osd/TestECBackend.cc index 082a7dd1d52e..697f4a1a9951 100644 --- a/src/test/osd/TestECBackend.cc +++ b/src/test/osd/TestECBackend.cc @@ -56,7 +56,7 @@ TEST(ECUtil, stripe_info_t) ASSERT_EQ(s.aligned_ro_offset_to_chunk_offset(2*swidth), 2*s.get_chunk_size()); - ASSERT_EQ(s.chunk_aligned_shard_offset_to_ro_offset(2*s.get_chunk_size()), + ASSERT_EQ(s.shard_offset_to_ro_offset(shard_id_t(0), 2*s.get_chunk_size()), 2*s.get_stripe_width()); // Stripe 1 + 1 chunk for 10 stripes needs to read 11 stripes starting