From: xie xingguo Date: Wed, 21 Nov 2018 01:36:21 +0000 (+0800) Subject: osd/OSDMap: add pg-existence sanity check X-Git-Tag: v14.1.0~752^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=79ef3bea7550559b7ea4e2b68dc407c7eb25defa;p=ceph.git osd/OSDMap: add pg-existence sanity check The reason why __get_pg_pool_size(pg)__ or __get_pg_pool_crush_rule(pg)__ fails is that the pg does not exist anymore. So it generally makes sense to check __pg_exists(pg)__ before moving further. Signed-off-by: xie xingguo --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 1000bbcfb519..87d388ccca8b 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -1755,12 +1755,12 @@ void OSDMap::maybe_remove_pg_upmaps(CephContext *cct, to_check.insert(p.first); } for (auto& pg : to_check) { - auto crush_rule = nextmap.get_pg_pool_crush_rule(pg); - if (crush_rule < 0) { - lderr(cct) << __func__ << " unable to load crush-rule of pg " - << pg << dendl; + if (!nextmap.pg_exists(pg)) { + ldout(cct, 0) << __func__ << " pg " << pg << " is gone" << dendl; + to_cancel.insert(pg); continue; } + auto crush_rule = nextmap.get_pg_pool_crush_rule(pg); map weight_map; auto it = rule_weight_map.find(crush_rule); if (it == rule_weight_map.end()) {