]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: refactor _get_pool / _put_pool a little bit
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 17 Dec 2010 20:28:23 +0000 (12:28 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 17 Dec 2010 20:28:23 +0000 (12:28 -0800)
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/osd/OSD.cc
src/osd/OSD.h

index 386ce865893d3b765b21c0e5b0097790c7f555cf..d2590f318d4723a3d8f3801b7177e4376f8d0545 100644 (file)
@@ -840,15 +840,11 @@ void OSD::clear_temp()
 // ======================================================
 // PG's
 
-PGPool *OSD::_lookup_pool(int id)
-{
-  map<int, PGPool*>::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<int, PGPool*>::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();
index 776c1dd6305d43f018bfea93ea318feeb37f8a9e..8fc3fbc346a7ac2ed3be5ac75fe3f4b3a72e22c6 100644 (file)
@@ -499,9 +499,8 @@ protected:
   hash_map<pg_t, PG*> pg_map;
   hash_map<pg_t, list<Message*> > 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);