]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code/lrc: implement crush-device-class property
authorSage Weil <sage@redhat.com>
Fri, 30 Jun 2017 20:55:02 +0000 (16:55 -0400)
committerSage Weil <sage@redhat.com>
Thu, 6 Jul 2017 19:01:03 +0000 (15:01 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/erasure-code/lrc/ErasureCodeLrc.cc
src/erasure-code/lrc/ErasureCodeLrc.h

index 6a1080ea3c73e789d30217479d4a78745e4d4bd5..05cd6ed7580d53fba1d3f0fa63b98a9936961a16 100644 (file)
@@ -56,6 +56,20 @@ int ErasureCodeLrc::create_rule(const string &name,
     return -ENOENT;
   }
   int root = crush.get_item_id(rule_root);
+  if (rule_device_class.size()) {
+    if (!crush.class_exists(rule_device_class)) {
+      *ss << "device class " << rule_device_class << " does not exist";
+      return -ENOENT;
+    }
+    int c = crush.get_class_id(rule_device_class);
+    if (crush.class_bucket.count(root) == 0 ||
+       crush.class_bucket[root].count(c) == 0) {
+      *ss << "root item " << rule_root << " has no devices with class "
+         << rule_device_class;
+      return -EINVAL;
+    }
+    root = crush.class_bucket[root][c];
+  }
 
   int rule = 0;
   int rno = 0;
@@ -393,6 +407,9 @@ int ErasureCodeLrc::parse_rule(ErasureCodeProfile &profile,
   err |= to_string("crush-root", profile,
                   &rule_root,
                   "default", ss);
+  err |= to_string("crush-device-class", profile,
+                  &rule_device_class,
+                  "", ss);
 
   if (profile.count("crush-steps") != 0) {
     rule_steps.clear();
index a92bff23986282f57dc61a2458ddfce05a8195d2..3cd6c849e08f7776d31e1497fcf7f8d91d6f5769 100644 (file)
@@ -63,6 +63,7 @@ public:
   unsigned int chunk_count;
   unsigned int data_chunk_count;
   std::string rule_root;
+  std::string rule_device_class;
   struct Step {
     Step(std::string _op, std::string _type, int _n) :
       op(_op),