]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: move default bucket choice into CrushWrapper helper
authorSage Weil <sage@redhat.com>
Wed, 3 Dec 2014 01:17:10 +0000 (17:17 -0800)
committerSage Weil <sage@redhat.com>
Thu, 22 Jan 2015 18:16:39 +0000 (10:16 -0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc

index 1ef4458e1b611ed755dd21fbc847a35a0c20e038..1d00b994bb05d5b25bda693c4201f3b47196d17e 100644 (file)
@@ -544,7 +544,8 @@ int CrushWrapper::insert_item(CephContext *cct, int item, float weight, string n
     if (!name_exists(q->second)) {
       ldout(cct, 5) << "insert_item creating bucket " << q->second << dendl;
       int empty = 0, newid;
-      int r = add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT, p->first, 1, &cur, &empty, &newid);
+      int r = add_bucket(0, 0,
+                        CRUSH_HASH_DEFAULT, p->first, 1, &cur, &empty, &newid);
       if (r < 0) {
         ldout(cct, 1) << "add_bucket failure error: " << cpp_strerror(r) << dendl;
         return r;
index d5deed8d9f2cd231c39935293555c3c648a63855..5b7124b908bba8541eb15bd51f5f8f59cf518724 100644 (file)
@@ -249,6 +249,11 @@ public:
   bool is_v2_rule(unsigned ruleid) const;
   bool is_v3_rule(unsigned ruleid) const;
 
+  // default bucket types
+  unsigned get_default_bucket_alg() const {
+    return CRUSH_BUCKET_STRAW;
+  }
+
   // bucket types
   int get_num_type_names() const {
     return type_map.size();
@@ -904,8 +909,11 @@ public:
   /* modifiers */
   int add_bucket(int bucketno, int alg, int hash, int type, int size,
                 int *items, int *weights, int *idout) {
-    if (type == 0)
-      return -EINVAL;
+    if (alg == 0) {
+      alg = get_default_bucket_alg();
+      if (alg == 0)
+       return -EINVAL;
+    }
     crush_bucket *b = crush_make_bucket(crush, alg, hash, type, size, items, weights);
     assert(b);
     return crush_add_bucket(crush, bucketno, b, idout);
index 6029bf0a3dfddead0d84bf710f0a653dace09429..5794d4b2257cbfab8cd99efb1398f339f99d6d96 100644 (file)
@@ -4507,9 +4507,9 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m,
       goto reply;
     }
     int bucketno;
-    err = newcrush.add_bucket(0, CRUSH_BUCKET_STRAW,
-                                      CRUSH_HASH_DEFAULT, type, 0, NULL,
-                                      NULL, &bucketno);
+    err = newcrush.add_bucket(0, 0,
+                             CRUSH_HASH_DEFAULT, type, 0, NULL,
+                             NULL, &bucketno);
     if (err < 0) {
       ss << "add_bucket error: '" << cpp_strerror(err) << "'";
       goto reply;
index cc158617575f838d14fbdd0b7bfc4cc682333d1a..a9ab413d1617f7e2bf6a3baf623b096388b18636 100644 (file)
@@ -2730,7 +2730,7 @@ int OSDMap::build_simple_crush_map(CephContext *cct, CrushWrapper& crush,
   // root
   int root_type = _build_crush_types(crush);
   int rootid;
-  int r = crush.add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT,
+  int r = crush.add_bucket(0, 0, CRUSH_HASH_DEFAULT,
                           root_type, 0, NULL, NULL, &rootid);
   assert(r == 0);
   crush.set_item_name(rootid, "default");
@@ -2766,7 +2766,8 @@ int OSDMap::build_simple_crush_map_from_conf(CephContext *cct,
   // root
   int root_type = _build_crush_types(crush);
   int rootid;
-  int r = crush.add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT,
+  int r = crush.add_bucket(0, 0,
+                          CRUSH_HASH_DEFAULT,
                           root_type, 0, NULL, NULL, &rootid);
   assert(r == 0);
   crush.set_item_name(rootid, "default");