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
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);
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) {
}
// 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);
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()) {
// 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;
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;
}
// 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;
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)
{ }
* 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);
}
};
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)";
}
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 {
::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) {
::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)