From: Colin Patrick McCabe Date: Fri, 17 Dec 2010 20:28:23 +0000 (-0800) Subject: osd: refactor _get_pool / _put_pool a little bit X-Git-Tag: v0.25~437 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c3a24fc5d31d53e3db911be900b9067584f0e07e;p=ceph.git osd: refactor _get_pool / _put_pool a little bit Signed-off-by: Colin McCabe --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 386ce865893d..d2590f318d47 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -840,15 +840,11 @@ void OSD::clear_temp() // ====================================================== // PG's -PGPool *OSD::_lookup_pool(int id) -{ - map::iterator p = pool_map.find(id); - return (p == pool_map.end()) ? NULL : p->second; -} - PGPool* OSD::_get_pool(int id) { - PGPool *p = _lookup_pool(id); + map::iterator pm = pool_map.find(id); + PGPool *p = (pm == pool_map.end()) ? NULL : pm->second; + if (!p) { if (!osdmap->have_pg_pool(id)) { dout(5) << __func__ << ": the OSDmap does not contain a PG pool with id = " @@ -872,18 +868,18 @@ PGPool* OSD::_get_pool(int id) return p; } -void OSD::_put_pool(int id) +void OSD::_put_pool(PGPool *p) { - PGPool *p = _lookup_pool(id); - dout(10) << "_put_pool " << id << " " << p->num_pg << " -> " << (p->num_pg-1) << dendl; + dout(10) << "_put_pool " << p->id << " " << p->num_pg + << " -> " << (p->num_pg-1) << dendl; + assert(p->num_pg > 0); p->num_pg--; if (!p->num_pg) { - pool_map.erase(id); + pool_map.erase(p->id); p->put(); } } - PG *OSD::_open_lock_pg(pg_t pgid, bool no_lockdep_check) { assert(osd_lock.is_locked()); @@ -4608,7 +4604,7 @@ void OSD::_remove_pg(PG *pg) pg_map.erase(pgid); unreg_last_pg_scrub(pg->info.pgid, pg->info.history.last_scrub_stamp); - _put_pool(pgid.pool()); + _put_pool(pg->pool); // unlock, and probably delete pg->unlock(); diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 776c1dd6305d..8fc3fbc346a7 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -499,9 +499,8 @@ protected: hash_map pg_map; hash_map > waiting_for_pg; - PGPool *_lookup_pool(int id); PGPool *_get_pool(int id); - void _put_pool(int id); + void _put_pool(PGPool *p); bool _have_pg(pg_t pgid); PG *_lookup_lock_pg(pg_t pgid);