From: xie xingguo Date: Mon, 5 Mar 2018 04:22:55 +0000 (+0800) Subject: osd/OSDMap: ignore PGs from pools of failure-domain OSD X-Git-Tag: v12.2.5~28^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=50716c93b07820a76a5ae6564779d451f94fad64;p=ceph.git osd/OSDMap: ignore PGs from pools of failure-domain OSD 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 (cherry picked from commit f9a35aa55853e9c01412bb3593df34bb404a4504) --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 3b790cd92a56..fa4a0e56ffd8 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -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 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 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