]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crush/CrushWrapper: reclassify: handle to-be-created buckets that we need twice
authorSage Weil <sage@redhat.com>
Tue, 23 Oct 2018 19:15:25 +0000 (14:15 -0500)
committerSage Weil <sage@redhat.com>
Wed, 28 Nov 2018 02:36:43 +0000 (20:36 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/crush/CrushWrapper.cc

index c428fade86b64abb0535048f6eb7f5ede101f4b8..e98f1a6cfefd18ddd6b9069e0af696cc01796775 100644 (file)
@@ -1813,6 +1813,7 @@ int CrushWrapper::reclassify(
   map<int,map<int,int>> new_class_bucket;
   map<int,string> new_bucket_names;
   map<int,map<string,string>> new_buckets;
+  map<string,int> new_bucket_by_name;
   for (auto& i : classify_bucket) {
     const string& match = i.first;  // prefix% or %suffix
     const string& new_class = i.second.first;
@@ -1878,6 +1879,9 @@ int CrushWrapper::reclassify(
       if (name_exists(basename)) {
        base_id = get_item_id(basename);
        cout << "  have base " << base_id << std::endl;
+      } else if (new_bucket_by_name.count(basename)) {
+       base_id = new_bucket_by_name[basename];
+       cout << "  already creating base " << base_id << std::endl;
       } else {
        base_id = get_new_bucket_id();
        crush->buckets[-1-base_id] = crush_make_bucket(crush,
@@ -1887,6 +1891,7 @@ int CrushWrapper::reclassify(
                                                       0, NULL, NULL);
        crush->buckets[-1-base_id]->id = base_id;
        name_map[base_id] = basename;
+       new_bucket_by_name[basename] = base_id;
        cout << "  created base " << base_id << std::endl;
 
        new_buckets[base_id][default_parent_type_name] = default_parent;