]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: use kb instead of blocks for pg, osd utilization
authorSage Weil <sage@newdream.net>
Wed, 8 Oct 2008 18:43:08 +0000 (11:43 -0700)
committerSage Weil <sage@newdream.net>
Wed, 8 Oct 2008 18:43:08 +0000 (11:43 -0700)
src/mon/PGMap.h
src/mon/PGMonitor.cc
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h
src/osd/osd_types.h

index c83d6b5491cf76f03e3e37af42925eb8fb0e304b..e1d43bda99562840ba6bc6db9aa932d08eaf09a1 100644 (file)
@@ -100,11 +100,11 @@ public:
   hash_map<int,int> num_pg_by_state;
   int64_t num_pg;
   int64_t total_pg_num_bytes;
-  int64_t total_pg_num_blocks;
+  int64_t total_pg_num_kb;
   int64_t total_pg_num_objects;
   int64_t num_osd;
-  int64_t total_osd_num_blocks;
-  int64_t total_osd_num_blocks_avail;
+  int64_t total_osd_kb;
+  int64_t total_osd_kb_avail;
   int64_t total_osd_num_objects;
 
   set<pg_t> creating_pgs;   // lru: front = new additions, back = recently pinged
@@ -113,18 +113,18 @@ public:
     num_pg = 0;
     num_pg_by_state.clear();
     total_pg_num_bytes = 0;
-    total_pg_num_blocks = 0;
+    total_pg_num_kb = 0;
     total_pg_num_objects = 0;
     num_osd = 0;
-    total_osd_num_blocks = 0;
-    total_osd_num_blocks_avail = 0;
+    total_osd_kb = 0;
+    total_osd_kb_avail = 0;
     total_osd_num_objects = 0;
   }
   void stat_pg_add(pg_t pgid, pg_stat_t &s) {
     num_pg++;
     num_pg_by_state[s.state]++;
     total_pg_num_bytes += s.num_bytes;
-    total_pg_num_blocks += s.num_blocks;
+    total_pg_num_kb += s.num_kb;
     total_pg_num_objects += s.num_objects;
     if (s.state & PG_STATE_CREATING)
       creating_pgs.insert(pgid);
@@ -134,37 +134,37 @@ public:
     if (--num_pg_by_state[s.state] == 0)
       num_pg_by_state.erase(s.state);
     total_pg_num_bytes -= s.num_bytes;
-    total_pg_num_blocks -= s.num_blocks;
+    total_pg_num_kb -= s.num_kb;
     total_pg_num_objects -= s.num_objects;
     if (s.state & PG_STATE_CREATING)
       creating_pgs.erase(pgid);
   }
   void stat_osd_add(osd_stat_t &s) {
     num_osd++;
-    total_osd_num_blocks += s.num_blocks;
-    total_osd_num_blocks_avail += s.num_blocks_avail;
+    total_osd_kb += s.kb;
+    total_osd_kb_avail += s.kb_avail;
     total_osd_num_objects += s.num_objects;
   }
   void stat_osd_sub(osd_stat_t &s) {
     num_osd--;
-    total_osd_num_blocks -= s.num_blocks;
-    total_osd_num_blocks_avail -= s.num_blocks_avail;
+    total_osd_kb -= s.kb;
+    total_osd_kb_avail -= s.kb_avail;
     total_osd_num_objects -= s.num_objects;
   }
 
-  uint64_t total_kb() { return 4*total_osd_num_blocks; }
-  uint64_t total_avail_kb() { return 4*total_osd_num_blocks_avail; }
+  uint64_t total_kb() { return total_osd_kb; }
+  uint64_t total_avail_kb() { return total_osd_kb_avail; }
   uint64_t total_used_kb() { return total_kb() - total_avail_kb(); }
 
   PGMap() : version(0),
            last_osdmap_epoch(0), last_pg_scan(0),
            num_pg(0), 
            total_pg_num_bytes(0), 
-           total_pg_num_blocks(0), 
+           total_pg_num_kb(0), 
            total_pg_num_objects(0), 
            num_osd(0),
-           total_osd_num_blocks(0),
-           total_osd_num_blocks_avail(0),
+           total_osd_kb(0),
+           total_osd_kb_avail(0),
            total_osd_num_objects(0) {}
 
   void encode(bufferlist &bl) {
index 7bbe0a2f3aaf8cc691ba9780a73c82bacc291fdd..44f37ee1a5e33e335eeca2beae620651f55f9cac 100644 (file)
@@ -266,12 +266,15 @@ bool PGMonitor::prepare_pg_stats(MPGStats *stats)
   }
       
   // osd stat
-  dout(10) << " got " << stats->osd_stat << dendl;
   pending_inc.osd_stat_updates[from] = stats->osd_stat;
   
   // apply to live map too (screw consistency)
-  if (pg_map.osd_stat.count(from))
+  if (pg_map.osd_stat.count(from)) {
+    dout(10) << " got " << stats->osd_stat << " (was " << pg_map.osd_stat[from] << ")" << dendl;
     pg_map.stat_osd_sub(pg_map.osd_stat[from]);
+  } else {
+    dout(10) << " got " << stats->osd_stat << " (first report)" << dendl;
+  }
   pg_map.osd_stat[from] = stats->osd_stat;
   pg_map.stat_osd_add(stats->osd_stat);
 
@@ -567,8 +570,8 @@ bool PGMonitor::preprocess_command(MMonCommand *m)
       for (hash_map<int,osd_stat_t>::iterator p = pg_map.osd_stat.begin();
           p != pg_map.osd_stat.end();
           p++)
-       ss << p->first << "\t" << p->second.num_blocks
-          << "\t" << p->second.num_blocks_avail 
+       ss << p->first << "\t" << p->second.kb
+          << "\t" << p->second.kb_avail 
           << "\t" << p->second.num_objects
           << std::endl;
       while (!ss.eof()) {
index 381d688d05efab2f2b21cee7a71ccec0a936106b..c010b5f2a7f92d4aa719e2a0b21166c0c504f59b 100644 (file)
@@ -1163,8 +1163,8 @@ void OSD::send_pg_stats()
     // fill in osd stats too
     struct statfs stbuf;
     store->statfs(&stbuf);
-    m->osd_stat.num_blocks = stbuf.f_blocks;
-    m->osd_stat.num_blocks_avail = stbuf.f_bavail;
+    m->osd_stat.kb = stbuf.f_blocks * stbuf.f_bsize / 1024;
+    m->osd_stat.kb_avail = stbuf.f_bavail * stbuf.f_bsize / 1024;
     m->osd_stat.num_objects = stbuf.f_files;
     dout(20) << " osd_stat " << m->osd_stat << dendl;
     
index c1d2022d3f3a7368df8b8bc01dfe7b9ea79cf6be..6aaec544dae4d53779f6df4304b96b662afe3a8a 100644 (file)
@@ -1217,7 +1217,7 @@ void PG::update_stats()
     pg_stats.reported = info.last_update;
     pg_stats.state = state;
     pg_stats.num_bytes = stat_num_bytes;
-    pg_stats.num_blocks = stat_num_blocks;
+    pg_stats.num_kb = stat_num_kb;
   } else {
     pg_stats_valid = false;
   }
index 3626494ad816a3e4d14deaf766e2a4aeda3bb524..ae970bd9fce5b3053742da5f26c28c1643a0be5e 100644 (file)
@@ -555,7 +555,7 @@ protected:
 
   // stats
   loff_t stat_num_bytes;
-  loff_t stat_num_blocks;
+  loff_t stat_num_kb;
 
   hash_map<object_t, DecayCounter> stat_object_temp_rd;
 
@@ -638,7 +638,7 @@ public:
     pending_snap_removal_item(this),
     have_master_log(true),
     must_notify_mon(false),
-    stat_num_bytes(0), stat_num_blocks(0),
+    stat_num_bytes(0), stat_num_kb(0),
     pg_stats_valid(false),
     finish_sync_event(NULL)
   { }
index 574a7d28fc80ff5d9a4a54d54106cc227d5accd2..a22685a7530e11b655b154210e7ed4c13f7af9e5 100644 (file)
@@ -243,20 +243,20 @@ inline ostream& operator<<(ostream& out, const eversion_t e) {
  * aggregate stats for an osd
  */
 struct osd_stat_t {
-  int64_t num_blocks;
-  int64_t num_blocks_avail;
+  int64_t kb;
+  int64_t kb_avail;
   int64_t num_objects;
 
-  osd_stat_t() : num_blocks(0), num_blocks_avail(0), num_objects(0) {}
+  osd_stat_t() : kb(0), kb_avail(0), num_objects(0) {}
 
   void encode(bufferlist &bl) const {
-    ::encode(num_blocks, bl);
-    ::encode(num_blocks_avail, bl);
+    ::encode(kb, bl);
+    ::encode(kb_avail, bl);
     ::encode(num_objects, bl);
   }
   void decode(bufferlist::iterator &bl) {
-    ::decode(num_blocks, bl);
-    ::decode(num_blocks_avail, bl);
+    ::decode(kb, bl);
+    ::decode(kb_avail, bl);
     ::decode(num_objects, bl);
   }
 };
@@ -264,7 +264,7 @@ WRITE_CLASS_ENCODER(osd_stat_t)
 
 
 inline ostream& operator<<(ostream& out, const osd_stat_t& s) {
-  return out << "osd_stat(" << (s.num_blocks-s.num_blocks_avail) << "/" << s.num_blocks << " used, " 
+  return out << "osd_stat(" << (s.kb-s.kb_avail) << "/" << s.kb << " KB used, " 
             << s.num_objects << " objects)";
 }
 
@@ -312,7 +312,7 @@ struct pg_stat_t {
   int32_t parent_split_bits;
   int32_t state;
   int64_t num_bytes;    // in bytes
-  int64_t num_blocks;   // in 4k blocks
+  int64_t num_kb;       // in KB
   int64_t num_objects;
   
   void encode(bufferlist &bl) const {
@@ -322,7 +322,7 @@ struct pg_stat_t {
     ::encode(parent_split_bits, bl);
     ::encode(state, bl);
     ::encode(num_bytes, bl);
-    ::encode(num_blocks, bl);
+    ::encode(num_kb, bl);
     ::encode(num_objects, bl);
   }
   void decode(bufferlist::iterator &bl) {
@@ -332,10 +332,10 @@ struct pg_stat_t {
     ::decode(parent_split_bits, bl);
     ::decode(state, bl);
     ::decode(num_bytes, bl);
-    ::decode(num_blocks, bl);
+    ::decode(num_kb, bl);
     ::decode(num_objects, bl);
   }
-  pg_stat_t() : created(0), parent_split_bits(0), state(0), num_bytes(0), num_blocks(0), num_objects(0) {}
+  pg_stat_t() : created(0), parent_split_bits(0), state(0), num_bytes(0), num_kb(0), num_objects(0) {}
 };
 WRITE_CLASS_ENCODER(pg_stat_t)