]>
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 | ||
9f95a23c | 29 | static std::ostream& _prefix(std::ostream* _dout) |
7c673cae FG |
30 | { |
31 | return *_dout << "ErasureCodePluginJerasure: "; | |
32 | } | |
33 | ||
34 | int ErasureCodePluginJerasure::factory(const std::string& directory, | |
9f95a23c TL |
35 | ceph::ErasureCodeProfile &profile, |
36 | ceph::ErasureCodeInterfaceRef *erasure_code, | |
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 { | |
11fdf7f2 | 57 | *ss << "technique=" << t << " is not a valid coding technique. " |
7c673cae FG |
58 | << " Choose one of the following: " |
59 | << "reed_sol_van, reed_sol_r6_op, cauchy_orig, " | |
11fdf7f2 | 60 | << "cauchy_good, liberation, blaum_roth, liber8tion"; |
7c673cae FG |
61 | return -ENOENT; |
62 | } | |
63 | dout(20) << __func__ << ": " << profile << dendl; | |
64 | int r = interface->init(profile, ss); | |
65 | if (r) { | |
66 | delete interface; | |
67 | return r; | |
68 | } | |
9f95a23c | 69 | *erasure_code = ceph::ErasureCodeInterfaceRef(interface); |
7c673cae FG |
70 | return 0; |
71 | } | |
72 | ||
7c673cae FG |
73 | const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } |
74 | ||
75 | int __erasure_code_init(char *plugin_name, char *directory) | |
76 | { | |
9f95a23c | 77 | auto& instance = ceph::ErasureCodePluginRegistry::instance(); |
7c673cae FG |
78 | int w[] = { 4, 8, 16, 32 }; |
79 | int r = jerasure_init(4, w); | |
80 | if (r) { | |
81 | return -r; | |
82 | } | |
83 | return instance.add(plugin_name, new ErasureCodePluginJerasure()); | |
84 | } |