1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph distributed storage system
6 * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
7 * Copyright (C) 2014 Red Hat <contact@redhat.com>
9 * Author: Loic Dachary <loic@dachary.org>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
19 #include "common/debug.h"
20 #include "ErasureCodeJerasure.h"
21 #include "ErasureCodePluginJerasure.h"
22 #include "jerasure_init.h"
24 #define dout_context g_ceph_context
25 #define dout_subsys ceph_subsys_osd
27 #define dout_prefix _prefix(_dout)
29 static ostream
& _prefix(std::ostream
* _dout
)
31 return *_dout
<< "ErasureCodePluginJerasure: ";
34 int ErasureCodePluginJerasure::factory(const std::string
& directory
,
35 ErasureCodeProfile
&profile
,
36 ErasureCodeInterfaceRef
*erasure_code
,
38 ErasureCodeJerasure
*interface
;
40 if (profile
.find("technique") != profile
.end())
41 t
= profile
.find("technique")->second
;
42 if (t
== "reed_sol_van") {
43 interface
= new ErasureCodeJerasureReedSolomonVandermonde();
44 } else if (t
== "reed_sol_r6_op") {
45 interface
= new ErasureCodeJerasureReedSolomonRAID6();
46 } else if (t
== "cauchy_orig") {
47 interface
= new ErasureCodeJerasureCauchyOrig();
48 } else if (t
== "cauchy_good") {
49 interface
= new ErasureCodeJerasureCauchyGood();
50 } else if (t
== "liberation") {
51 interface
= new ErasureCodeJerasureLiberation();
52 } else if (t
== "blaum_roth") {
53 interface
= new ErasureCodeJerasureBlaumRoth();
54 } else if (t
== "liber8tion") {
55 interface
= new ErasureCodeJerasureLiber8tion();
57 derr
<< "technique=" << t
<< " is not a valid coding technique. "
58 << " Choose one of the following: "
59 << "reed_sol_van, reed_sol_r6_op, cauchy_orig, "
60 << "cauchy_good, liberation, blaum_roth, liber8tion"
64 dout(20) << __func__
<< ": " << profile
<< dendl
;
65 int r
= interface
->init(profile
, ss
);
70 *erasure_code
= ErasureCodeInterfaceRef(interface
);
74 #ifndef BUILDING_FOR_EMBEDDED
76 const char *__erasure_code_version() { return CEPH_GIT_NICE_VER
; }
78 int __erasure_code_init(char *plugin_name
, char *directory
)
80 ErasureCodePluginRegistry
&instance
= ErasureCodePluginRegistry::instance();
81 int w
[] = { 4, 8, 16, 32 };
82 int r
= jerasure_init(4, w
);
86 return instance
.add(plugin_name
, new ErasureCodePluginJerasure());