]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: ignore PGs from pools of failure-domain OSD
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 5 Mar 2018 04:22:55 +0000 (12:22 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sat, 10 Mar 2018 02:58:12 +0000 (10:58 +0800)
For testing purpose, we may create pools of failure-domain OSD.
In this case get_parent_of_type() will always return 0 and all
parents of these PGs' *up set* are considered as collided, and
hence the relevant pg_upmap/items are incorrectly removed during
the maybe_remove_pg_upmaps() procedure.

Fix the above problem by skipping these PGs and also try to be
more specific if we are unable to load the parent of a specified
PG.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit f9a35aa55853e9c01412bb3593df34bb404a4504)

src/osd/OSDMap.cc

index 3b790cd92a56fe4efbd9cdfed2ae61be86bd4194..fa4a0e56ffd8a5266c282ea408a5c25dfd327741 100644 (file)
@@ -1624,6 +1624,11 @@ void OSDMap::maybe_remove_pg_upmaps(CephContext *cct,
       lderr(cct) << __func__ << " unable to load failure-domain-type of pg "
                  << p.first << dendl;
       continue;
+    } else if (type == 0) {
+      ldout(cct, 10) << __func__ << " failure-domain of pg " << p.first
+                     << " is osd-level, skipping"
+                     << dendl;
+      continue;
     }
     ldout(cct, 10) << __func__ << " pg " << p.first
                    << " crush-rule-id " << crush_rule
@@ -1633,16 +1638,24 @@ void OSDMap::maybe_remove_pg_upmaps(CephContext *cct,
     int primary;
     tmpmap.pg_to_raw_up(p.first, &raw, &primary);
     set<int> parents;
+    bool error = false;
     bool collide = false;
     for (auto osd : raw) {
       auto parent = tmpmap.crush->get_parent_of_type(osd, type);
+      if (parent >= 0) {
+        lderr(cct) << __func__ << " unable to get parent of raw osd." << osd
+                   << ", pg " << p.first
+                   << dendl;
+        error = true;
+        break;
+      }
       auto r = parents.insert(parent);
       if (!r.second) {
         collide = true;
         break;
       }
     }
-    if (collide) {
+    if (!error && collide) {
       ldout(cct, 10) << __func__ << " removing invalid pg_upmap "
                      << "[" << p.first << ":" << p.second << "]"
                      << ", final mapping result will be: " << raw
@@ -1671,6 +1684,11 @@ void OSDMap::maybe_remove_pg_upmaps(CephContext *cct,
       lderr(cct) << __func__ << " unable to load failure-domain-type of pg "
                  << p.first << dendl;
       continue;
+    } else if (type == 0) {
+      ldout(cct, 10) << __func__ << " failure-domain of pg " << p.first
+                     << " is osd-level, skipping"
+                     << dendl;
+      continue;
     }
     ldout(cct, 10) << __func__ << " pg " << p.first
                    << " crush_rule_id " << crush_rule
@@ -1680,16 +1698,24 @@ void OSDMap::maybe_remove_pg_upmaps(CephContext *cct,
     int primary;
     tmpmap.pg_to_raw_up(p.first, &raw, &primary);
     set<int> parents;
+    bool error = false;
     bool collide = false;
     for (auto osd : raw) {
       auto parent = tmpmap.crush->get_parent_of_type(osd, type);
+      if (parent >= 0) {
+        lderr(cct) << __func__ << " unable to get parent of raw osd." << osd
+                   << ", pg " << p.first
+                   << dendl;
+        error = true;
+        break;
+      }
       auto r = parents.insert(parent);
       if (!r.second) {
         collide = true;
         break;
       }
     }
-    if (collide) {
+    if (!error && collide) {
       ldout(cct, 10) << __func__ << " removing invalid pg_upmap_items "
                      << "[" << p.first << ":" << p.second << "]"
                      << ", final mapping result will be: " << raw