]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: remove PGMap::pg_set
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 25 Jan 2011 17:40:18 +0000 (09:40 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 25 Jan 2011 17:40:18 +0000 (09:40 -0800)
We don't need an additional data structure to hold the keys to pg_stat.
We can just look at the keys of pg_stat.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/mon/PGMap.h
src/mon/PGMonitor.cc
src/tools/gui.cc

index 50aeecc75448b5c632822f528d59378bd3df6f10..ddd45cd096cd83944b1601ce76bdfb5c772b1aa1 100644 (file)
@@ -31,7 +31,6 @@ public:
   epoch_t last_osdmap_epoch;   // last osdmap epoch i applied to the pgmap
   epoch_t last_pg_scan;  // osdmap epoch
   hash_map<pg_t,pg_stat_t> pg_stat;
-  set<pg_t>                pg_set;
   hash_map<int,osd_stat_t> osd_stat;
   set<int> full_osds;
   set<int> nearfull_osds;
@@ -81,7 +80,6 @@ public:
         ++p) {
       const pg_t &update_pg(p->first);
       const pg_stat_t &update_stat(p->second);
-      pg_set.insert(update_pg);
       hash_map<pg_t,pg_stat_t>::iterator t = pg_stat.find(update_pg);
       if (t == pg_stat.end()) {
        hash_map<pg_t,pg_stat_t>::value_type v(update_pg, update_stat);
@@ -131,14 +129,10 @@ public:
         p != inc.pg_remove.end();
         p++) {
       const pg_t &removed_pg(*p);
-      set<pg_t>::iterator t = pg_set.find(removed_pg);
-      if (t != pg_set.end()) {
-       hash_map<pg_t,pg_stat_t>::iterator s = pg_stat.find(removed_pg);
-       if (s != pg_stat.end()) {
-         stat_pg_sub(removed_pg, s->second);
-         pg_stat.erase(s);
-       }
-       pg_set.erase(t);
+      hash_map<pg_t,pg_stat_t>::iterator s = pg_stat.find(removed_pg);
+      if (s != pg_stat.end()) {
+       stat_pg_sub(removed_pg, s->second);
+       pg_stat.erase(s);
       }
     }
 
@@ -233,7 +227,6 @@ public:
         p != pg_stat.end();
         ++p) {
       stat_pg_add(p->first, p->second);
-      pg_set.insert(p->first);
     }
     for (hash_map<int,osd_stat_t>::iterator p = osd_stat.begin();
         p != osd_stat.end();
@@ -249,16 +242,10 @@ public:
     ss << "full_ratio " << full_ratio << std::endl;
     ss << "nearfull_ratio " << nearfull_ratio << std::endl;
     ss << "pg_stat\tobjects\tmip\tunf\tdegr\tkb\tbytes\tlog\tdisklog\tstate\tv\treported\tup\tacting\tlast_scrub" << std::endl;
-    for (set<pg_t>::const_iterator p = pg_set.begin();
-        p != pg_set.end();
-        p++) {
-      hash_map<pg_t,pg_stat_t>::const_iterator i = pg_stat.find(*p);
-      if (i == pg_stat.end()) {
-       ss << *p << ": ERROR: no pg_stat information found" << std::endl;
-       continue;
-      }
+    for (hash_map<pg_t,pg_stat_t>::const_iterator i = pg_stat.begin();
+        i != pg_stat.end(); ++i) {
       const pg_stat_t &st(i->second);
-      ss << *p 
+      ss << i->first
         << "\t" << st.num_objects
        //<< "\t" << st.num_object_copies
         << "\t" << st.num_objects_missing_on_primary
index 772f2c80e62e4f3dea993c38fd21592fe4609c73..d86ea874f07ec36456aec788588edc389bf9207d 100644 (file)
@@ -640,12 +640,12 @@ bool PGMonitor::register_new_pgs()
   }
 
   // deleted pools?
-  for (set<pg_t>::iterator p = pg_map.pg_set.begin();
-       p != pg_map.pg_set.end();
-       p++) {
-    if (!osdmap->have_pg_pool(p->pool())) {
-      dout(20) << " removing creating_pg " << *p << " because containing pool deleted" << dendl;
-      pending_inc.pg_remove.insert(*p);
+  for (hash_map<pg_t,pg_stat_t>::const_iterator p = pg_map.pg_stat.begin();
+       p != pg_map.pg_stat.end(); ++p) {
+    if (!osdmap->have_pg_pool(p->first.pool())) {
+      dout(20) << " removing creating_pg " << p->first << " because "
+              << "containing pool deleted" << dendl;
+      pending_inc.pg_remove.insert(p->first);
       ++removed;
     }
   }
index 33418aa9dfb33cb691b2f9973a21972ffe37028c..5106b62c7b7b0e9e2216e3747e7f57d740207021 100644 (file)
@@ -774,8 +774,10 @@ view_pg_nodes(unsigned int begin, unsigned int end, bool view_all)
     pg_cluster_zoom = 0;
 
     current_pgs.clear();
-    std::copy(g.pgmap.pg_set.begin(), g.pgmap.pg_set.end(),
-       std::inserter(current_pgs, current_pgs.begin() ) );
+    for (hash_map<pg_t,pg_stat_t>::const_iterator p = g.pgmap.pg_stat.begin();
+        p != g.pgmap.pg_stat.end(); ++p) {
+      current_pgs.push_back(p->first);
+    }
   }
   else
     size = end - begin;