Skip to content

Commit

Permalink
osd: fix partial reading during multi-region EC reads
Browse files Browse the repository at this point in the history
Fixes: https://tracker.ceph.com/issues/67087
Signed-off-by: Radoslaw Zarzynski <[email protected]>
  • Loading branch information
rzarzynski committed Jul 31, 2024
1 parent 51fd35d commit beb4d22
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/osd/ECCommon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,14 @@ void ECCommon::ReadPipeline::get_min_want_to_read_shards(
{
const auto [left_chunk_index, right_chunk_index] =
sinfo.offset_length_to_data_chunk_indices(offset, length);
for(uint64_t i = left_chunk_index; i < right_chunk_index; i++) {
auto raw_chunk = i % sinfo.get_data_chunk_count();
const auto distance =
std::min(right_chunk_index - left_chunk_index,
sinfo.get_data_chunk_count());
for(uint64_t i = 0; i < distance; i++) {
auto raw_chunk = (left_chunk_index + i) % sinfo.get_data_chunk_count();
auto chunk = chunk_mapping.size() > raw_chunk ?
chunk_mapping[raw_chunk] : static_cast<int>(raw_chunk);
if (auto [_, inserted] = want_to_read->insert(chunk); !inserted) {
// aready processed all chunks
ceph_assert(want_to_read->size() == sinfo.get_data_chunk_count());
break;
}
want_to_read->insert(chunk);
}
}

Expand Down
25 changes: 25 additions & 0 deletions src/test/osd/TestECBackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,28 @@ TEST(ECCommon, get_min_want_to_read_shards)
ASSERT_TRUE(want_to_read == (std::set<int>{0, 1, 2, 3}));
}
}

TEST(ECCommon, get_min_want_to_read_shards_bug67087)
{
const uint64_t swidth = 4096;
const uint64_t ssize = 4;

ECUtil::stripe_info_t s(ssize, swidth);
ASSERT_EQ(s.get_stripe_width(), swidth);
ASSERT_EQ(s.get_chunk_size(), 1024);

const std::vector<int> chunk_mapping = {}; // no remapping

std::set<int> want_to_read;

// multitple calls with the same want_to_read can happen during
// multi-region reads.
{
ECCommon::ReadPipeline::get_min_want_to_read_shards(
512, 512, s, chunk_mapping, &want_to_read);
ASSERT_EQ(want_to_read, std::set<int>{0});
ECCommon::ReadPipeline::get_min_want_to_read_shards(
512+16*1024, 512, s, chunk_mapping, &want_to_read);
ASSERT_EQ(want_to_read, std::set<int>{0});
}
}

0 comments on commit beb4d22

Please sign in to comment.