Skip to content

Commit

Permalink
erasure-code: implement ErasureCode::sanity_check_k
Browse files Browse the repository at this point in the history
Implement the ErasureCode::sanity_check_k helper for plugins
that need to verify k >= 2.

http://tracker.ceph.com/issues/10358 Fixes: ceph#10358

Signed-off-by: Loic Dachary <[email protected]>
  • Loading branch information
ldachary committed Jun 6, 2015
1 parent a8500ce commit 37f7360
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/erasure-code/ErasureCode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@

const unsigned ErasureCode::SIMD_ALIGN = 32;

int ErasureCode::sanity_check_k(int k, ostream *ss)
{
if (k < 2) {
*ss << "k=" << k << " must be >= 2" << std::endl;
return -EINVAL;
} else {
return 0;
}
}

int ErasureCode::chunk_index(unsigned int i) const
{
return chunk_mapping.size() > i ? chunk_mapping[i] : i;
Expand Down
2 changes: 2 additions & 0 deletions src/erasure-code/ErasureCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace ceph {
return _profile;
}

int sanity_check_k(int k, ostream *ss);

virtual unsigned int get_coding_chunk_count() const {
return get_chunk_count() - get_data_chunk_count();
}
Expand Down

0 comments on commit 37f7360

Please sign in to comment.