using ceph::bufferlist;
using ceph::ErasureCodeProfile;
+ceph::mutex ErasureCodeJerasure::jerasure_init_mutex =
+ ceph::make_mutex("ErasureCodeJerasure::jerasure_init_mutex");
+
+
static ostream& _prefix(std::ostream* _dout)
{
return *_dout << "ErasureCodeJerasure: ";
void ErasureCodeJerasureReedSolomonVandermonde::prepare()
{
+ std::lock_guard lock(jerasure_init_mutex);
matrix = reed_sol_vandermonde_coding_matrix(k, m, w);
}
void ErasureCodeJerasureReedSolomonRAID6::prepare()
{
+ std::lock_guard lock(jerasure_init_mutex);
matrix = reed_sol_r6_coding_matrix(k, w);
}
//
void ErasureCodeJerasureCauchyOrig::prepare()
{
+ std::lock_guard lock(jerasure_init_mutex);
int *matrix = cauchy_original_coding_matrix(k, m, w);
prepare_schedule(matrix);
free(matrix);
//
void ErasureCodeJerasureCauchyGood::prepare()
{
+ std::lock_guard lock(jerasure_init_mutex);
int *matrix = cauchy_good_general_coding_matrix(k, m, w);
prepare_schedule(matrix);
free(matrix);
void ErasureCodeJerasureLiberation::prepare()
{
+ std::lock_guard lock(jerasure_init_mutex);
bitmatrix = liberation_coding_bitmatrix(k, w);
schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix);
simple_schedule = jerasure_dumb_bitmatrix_to_schedule(k, m, w, bitmatrix);
void ErasureCodeJerasureBlaumRoth::prepare()
{
+ std::lock_guard lock(jerasure_init_mutex);
bitmatrix = blaum_roth_coding_bitmatrix(k, w);
schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix);
simple_schedule = jerasure_dumb_bitmatrix_to_schedule(k, m, w, bitmatrix);
void ErasureCodeJerasureLiber8tion::prepare()
{
+ std::lock_guard lock(jerasure_init_mutex);
bitmatrix = liber8tion_coding_bitmatrix(k);
schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix);
simple_schedule = jerasure_dumb_bitmatrix_to_schedule(k, m, w, bitmatrix);
#include <string_view>
+#include "common/ceph_mutex.h"
#include "erasure-code/ErasureCode.h"
using namespace std::literals;
protected:
virtual int parse(ceph::ErasureCodeProfile &profile, std::ostream *ss);
+
+ // The Jerasure library has thread safety issues in functions
+ // like cauchy_good_general_coding_matrix() which use global variables
+ // without proper synchronization. This mutex serializes all prepare()
+ // calls to prevent race conditions during initialization.
+ static ceph::mutex jerasure_init_mutex;
};
class ErasureCodeJerasureReedSolomonVandermonde : public ErasureCodeJerasure {
public: