]> git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/shec/ErasureCodePluginShec.cc
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / erasure-code / shec / ErasureCodePluginShec.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2014 FUJITSU LIMITED
7 * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
8 * Copyright (C) 2014 Red Hat <contact@redhat.com>
9 *
10 * Author: Takanori Nakao <nakao.takanori@jp.fujitsu.com>
11 * Author: Takeshi Miyamae <miyamae.takeshi@jp.fujitsu.com>
12 * Author: Loic Dachary <loic@dachary.org>
13 *
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 */
20
21 #include "ceph_ver.h"
22 #include "common/debug.h"
23 #include "ErasureCodePluginShec.h"
24 #include "ErasureCodeShecTableCache.h"
25 #include "ErasureCodeShec.h"
26 #include "jerasure_init.h"
27
28 #define dout_context g_ceph_context
29
30 #define dout_subsys ceph_subsys_osd
31 #undef dout_prefix
32 #define dout_prefix _prefix(_dout)
33
34 static ostream& _prefix(std::ostream* _dout)
35 {
36 return *_dout << "ErasureCodePluginShec: ";
37 }
38
39 int ErasureCodePluginShec::factory(const std::string &directory,
40 ErasureCodeProfile &profile,
41 ErasureCodeInterfaceRef *erasure_code,
42 ostream *ss) {
43 ErasureCodeShec *interface;
44
45 if (profile.find("technique") == profile.end())
46 profile["technique"] = "multiple";
47 std::string t = profile.find("technique")->second;
48
49 if (t == "single"){
50 interface = new ErasureCodeShecReedSolomonVandermonde(tcache, ErasureCodeShec::SINGLE);
51 } else if (t == "multiple"){
52 interface = new ErasureCodeShecReedSolomonVandermonde(tcache, ErasureCodeShec::MULTIPLE);
53 } else {
54 *ss << "technique=" << t << " is not a valid coding technique. "
55 << "Choose one of the following: "
56 << "single, multiple ";
57 return -ENOENT;
58 }
59 int r = interface->init(profile, ss);
60 if (r) {
61 delete interface;
62 return r;
63 }
64 *erasure_code = ErasureCodeInterfaceRef(interface);
65
66 dout(10) << "ErasureCodePluginShec: factory() completed" << dendl;
67
68 return 0;
69 }
70
71 #ifndef BUILDING_FOR_EMBEDDED
72
73 const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
74
75 int __erasure_code_init(char *plugin_name, char *directory = (char *)"")
76 {
77 ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
78 int w[] = { 8, 16, 32 };
79 int r = jerasure_init(3, w);
80 if (r) {
81 return -r;
82 }
83 return instance.add(plugin_name, new ErasureCodePluginShec());
84 }
85
86 #endif