Skip to content

Commit 454ea7c

Browse files
committed
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 <[email protected]>
1 parent ac8816c commit 454ea7c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/osd/ECUtil.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,10 @@ class stripe_info_t {
766766
return ((len + stripe_width - 1) / stripe_width) * chunk_size;
767767
}
768768

769-
uint64_t chunk_aligned_shard_offset_to_ro_offset(uint64_t offset) const {
770-
ceph_assert(offset % chunk_size == 0);
771-
return (offset / chunk_size) * stripe_width;
769+
uint64_t shard_offset_to_ro_offset(shard_id_t shard, uint64_t offset) const {
770+
raw_shard_id_t raw_shard = get_raw_shard(shard);
771+
auto result = std::lldiv(offset, chunk_size);
772+
return result.quot * stripe_width + (int)raw_shard * chunk_size + result.rem;
772773
}
773774

774775
std::pair<uint64_t, uint64_t> chunk_aligned_ro_range_to_shard_ro_range(

src/test/osd/TestECBackend.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ TEST(ECUtil, stripe_info_t)
5656

5757
ASSERT_EQ(s.aligned_ro_offset_to_chunk_offset(2*swidth),
5858
2*s.get_chunk_size());
59-
ASSERT_EQ(s.chunk_aligned_shard_offset_to_ro_offset(2*s.get_chunk_size()),
59+
ASSERT_EQ(s.shard_offset_to_ro_offset(shard_id_t(0), 2*s.get_chunk_size()),
6060
2*s.get_stripe_width());
6161

6262
// Stripe 1 + 1 chunk for 10 stripes needs to read 11 stripes starting

0 commit comments

Comments
 (0)