]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph distributed storage system | |
5 | * | |
6 | * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com> | |
7 | * Copyright (C) 2014 Red Hat <contact@redhat.com> | |
8 | * | |
9 | * Author: Loic Dachary <loic@dachary.org> | |
10 | * | |
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. | |
15 | * | |
16 | */ | |
17 | ||
18 | #include "ceph_ver.h" | |
19 | #include "common/debug.h" | |
20 | #include "ErasureCodeJerasure.h" | |
21 | #include "ErasureCodePluginJerasure.h" | |
22 | #include "jerasure_init.h" | |
23 | ||
24 | #define dout_context g_ceph_context | |
25 | #define dout_subsys ceph_subsys_osd | |
26 | #undef dout_prefix | |
27 | #define dout_prefix _prefix(_dout) | |
28 | ||
29 | static ostream& _prefix(std::ostream* _dout) | |
30 | { | |
31 | return *_dout << "ErasureCodePluginJerasure: "; | |
32 | } | |
33 | ||
34 | int ErasureCodePluginJerasure::factory(const std::string& directory, | |
35 | ErasureCodeProfile &profile, | |
36 | ErasureCodeInterfaceRef *erasure_code, | |
31f18b77 | 37 | std::ostream *ss) { |
7c673cae FG |
38 | ErasureCodeJerasure *interface; |
39 | std::string t; | |
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(); | |
56 | } else { | |
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" | |
61 | << dendl; | |
62 | return -ENOENT; | |
63 | } | |
64 | dout(20) << __func__ << ": " << profile << dendl; | |
65 | int r = interface->init(profile, ss); | |
66 | if (r) { | |
67 | delete interface; | |
68 | return r; | |
69 | } | |
70 | *erasure_code = ErasureCodeInterfaceRef(interface); | |
71 | return 0; | |
72 | } | |
73 | ||
7c673cae FG |
74 | const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } |
75 | ||
76 | int __erasure_code_init(char *plugin_name, char *directory) | |
77 | { | |
78 | ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); | |
79 | int w[] = { 4, 8, 16, 32 }; | |
80 | int r = jerasure_init(4, w); | |
81 | if (r) { | |
82 | return -r; | |
83 | } | |
84 | return instance.add(plugin_name, new ErasureCodePluginJerasure()); | |
85 | } |