From: Sage Weil Date: Fri, 7 Feb 2014 17:38:37 +0000 (-0800) Subject: osd/OSDMap: populate *primary when pool dne X-Git-Tag: v0.77~9^2^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3a5fa8765f30ddee86fb3cb2db6a9733fb9dbe78;p=ceph.git osd/OSDMap: populate *primary when pool dne This fixes a valgrind error from OSD::handle_osd_map where primary is not initialized and is compared after the call to pg_to_acting_osds(). We are still not distinguishing from "no mapping" to "pool doesn't exist, no mapping". That is a somewhat larger change, though. Signed-off-by: Sage Weil --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 608177a7149..902717aea53 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -1390,6 +1390,7 @@ void OSDMap::_get_temp_osds(const pg_pool_t& pool, pg_t pg, int OSDMap::pg_to_osds(pg_t pg, vector *raw, int *primary) const { *primary = -1; + raw->clear(); const pg_pool_t *pool = get_pg_pool(pg.pool()); if (!pool) return 0; @@ -1400,8 +1401,13 @@ int OSDMap::pg_to_osds(pg_t pg, vector *raw, int *primary) const void OSDMap::pg_to_raw_up(pg_t pg, vector *up, int *primary) const { const pg_pool_t *pool = get_pg_pool(pg.pool()); - if (!pool) + if (!pool) { + if (primary) + *primary = -1; + if (up) + up->clear(); return; + } vector raw; _pg_to_osds(*pool, pg, &raw, primary); _raw_to_up_osds(pg, raw, up, primary); @@ -1411,8 +1417,17 @@ void OSDMap::_pg_to_up_acting_osds(pg_t pg, vector *up, int *up_primary, vector *acting, int *acting_primary) const { const pg_pool_t *pool = get_pg_pool(pg.pool()); - if (!pool) + if (!pool) { + if (up) + up->clear(); + if (up_primary) + *up_primary = -1; + if (acting) + acting->clear(); + if (acting_primary) + *acting_primary = -1; return; + } vector raw; vector _up; vector _acting;