X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ferasure-code%2Fshec%2FErasureCodePluginShec.cc;fp=src%2Fceph%2Fsrc%2Ferasure-code%2Fshec%2FErasureCodePluginShec.cc;h=eb967f8d4637a73709af0492d43196f8c02d0384;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/erasure-code/shec/ErasureCodePluginShec.cc b/src/ceph/src/erasure-code/shec/ErasureCodePluginShec.cc new file mode 100644 index 0000000..eb967f8 --- /dev/null +++ b/src/ceph/src/erasure-code/shec/ErasureCodePluginShec.cc @@ -0,0 +1,86 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2014 FUJITSU LIMITED + * Copyright (C) 2013,2014 Cloudwatt + * Copyright (C) 2014 Red Hat + * + * Author: Takanori Nakao + * Author: Takeshi Miyamae + * Author: Loic Dachary + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + */ + +#include "ceph_ver.h" +#include "common/debug.h" +#include "ErasureCodePluginShec.h" +#include "ErasureCodeShecTableCache.h" +#include "ErasureCodeShec.h" +#include "jerasure_init.h" + +#define dout_context g_ceph_context + +#define dout_subsys ceph_subsys_osd +#undef dout_prefix +#define dout_prefix _prefix(_dout) + +static ostream& _prefix(std::ostream* _dout) +{ + return *_dout << "ErasureCodePluginShec: "; +} + +int ErasureCodePluginShec::factory(const std::string &directory, + ErasureCodeProfile &profile, + ErasureCodeInterfaceRef *erasure_code, + std::ostream *ss) { + ErasureCodeShec *interface; + + if (profile.find("technique") == profile.end()) + profile["technique"] = "multiple"; + std::string t = profile.find("technique")->second; + + if (t == "single"){ + interface = new ErasureCodeShecReedSolomonVandermonde(tcache, ErasureCodeShec::SINGLE); + } else if (t == "multiple"){ + interface = new ErasureCodeShecReedSolomonVandermonde(tcache, ErasureCodeShec::MULTIPLE); + } else { + *ss << "technique=" << t << " is not a valid coding technique. " + << "Choose one of the following: " + << "single, multiple "; + return -ENOENT; + } + int r = interface->init(profile, ss); + if (r) { + delete interface; + return r; + } + *erasure_code = ErasureCodeInterfaceRef(interface); + + dout(10) << "ErasureCodePluginShec: factory() completed" << dendl; + + return 0; +} + +#ifndef BUILDING_FOR_EMBEDDED + +const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } + +int __erasure_code_init(char *plugin_name, char *directory = (char *)"") +{ + ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); + int w[] = { 8, 16, 32 }; + int r = jerasure_init(3, w); + if (r) { + return -r; + } + return instance.add(plugin_name, new ErasureCodePluginShec()); +} + +#endif \ No newline at end of file