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 <aainscow@uk.ibm.com>
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<uint64_t, uint64_t> chunk_aligned_ro_range_to_shard_ro_range(
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