1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
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>
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>
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.
22 #include "common/debug.h"
23 #include "ErasureCodePluginShec.h"
24 #include "ErasureCodeShecTableCache.h"
25 #include "ErasureCodeShec.h"
26 #include "jerasure_init.h"
28 #define dout_context g_ceph_context
30 #define dout_subsys ceph_subsys_osd
32 #define dout_prefix _prefix(_dout)
34 static ostream& _prefix(std::ostream* _dout)
36 return *_dout << "ErasureCodePluginShec: ";
39 int ErasureCodePluginShec::factory(const std::string &directory,
40 ErasureCodeProfile &profile,
41 ErasureCodeInterfaceRef *erasure_code,
43 ErasureCodeShec *interface;
45 if (profile.find("technique") == profile.end())
46 profile["technique"] = "multiple";
47 std::string t = profile.find("technique")->second;
50 interface = new ErasureCodeShecReedSolomonVandermonde(tcache, ErasureCodeShec::SINGLE);
51 } else if (t == "multiple"){
52 interface = new ErasureCodeShecReedSolomonVandermonde(tcache, ErasureCodeShec::MULTIPLE);
54 *ss << "technique=" << t << " is not a valid coding technique. "
55 << "Choose one of the following: "
56 << "single, multiple ";
59 int r = interface->init(profile, ss);
64 *erasure_code = ErasureCodeInterfaceRef(interface);
66 dout(10) << "ErasureCodePluginShec: factory() completed" << dendl;
71 #ifndef BUILDING_FOR_EMBEDDED
73 const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
75 int __erasure_code_init(char *plugin_name, char *directory = (char *)"")
77 ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
78 int w[] = { 8, 16, 32 };
79 int r = jerasure_init(3, w);
83 return instance.add(plugin_name, new ErasureCodePluginShec());