}
osd_stat_t OSDService::set_osd_stat(const struct store_statfs_t &stbuf,
- vector<int>& hb_peers)
+ vector<int>& hb_peers,
+ int num_pgs)
{
uint64_t bytes = stbuf.total;
uint64_t used = bytes - stbuf.available;
osd_stat.kb = bytes >> 10;
osd_stat.kb_used = used >> 10;
osd_stat.kb_avail = avail >> 10;
+ osd_stat.num_pgs = num_pgs;
return osd_stat;
}
}
return;
}
- auto new_stat = set_osd_stat(stbuf, hb_peers);
+ auto new_stat = set_osd_stat(stbuf, hb_peers, osd->get_num_pgs());
dout(20) << "update_osd_stat " << new_stat << dendl;
assert(new_stat.kb);
float ratio = ((float)new_stat.kb_used) / ((float)new_stat.kb);
void update_osd_stat(vector<int>& hb_peers);
osd_stat_t set_osd_stat(const struct store_statfs_t &stbuf,
- vector<int>& hb_peers);
+ vector<int>& hb_peers,
+ int num_pgs);
osd_stat_t get_osd_stat() {
Mutex::Locker l(stat_lock);
++seq;
public:
PG *lookup_lock_pg(spg_t pgid);
+ int get_num_pgs() {
+ RWLock::RLocker l(pg_map_lock);
+ return pg_map.size();
+ }
+
protected:
PG *_open_lock_pg(OSDMapRef createmap,
spg_t pg, bool no_lockdep_check=false);
{
f->dump_unsigned("up_from", up_from);
f->dump_unsigned("seq", seq);
+ f->dump_unsigned("num_pgs", num_pgs);
f->dump_unsigned("kb", kb);
f->dump_unsigned("kb_used", kb_used);
f->dump_unsigned("kb_avail", kb_avail);
void osd_stat_t::encode(bufferlist &bl) const
{
- ENCODE_START(6, 2, bl);
+ ENCODE_START(7, 2, bl);
::encode(kb, bl);
::encode(kb_used, bl);
::encode(kb_avail, bl);
::encode(os_perf_stat, bl);
::encode(up_from, bl);
::encode(seq, bl);
+ ::encode(num_pgs, bl);
ENCODE_FINISH(bl);
}
::decode(up_from, bl);
::decode(seq, bl);
}
+ if (struct_v >= 7) {
+ ::decode(num_pgs, bl);
+ }
DECODE_FINISH(bl);
}
epoch_t up_from = 0;
uint64_t seq = 0;
+ uint32_t num_pgs = 0;
+
osd_stat_t() : kb(0), kb_used(0), kb_avail(0),
snap_trim_queue_len(0), num_snap_trimming(0) {}
num_snap_trimming += o.num_snap_trimming;
op_queue_age_hist.add(o.op_queue_age_hist);
os_perf_stat.add(o.os_perf_stat);
+ num_pgs += o.num_pgs;
}
void sub(const osd_stat_t& o) {
kb -= o.kb;
num_snap_trimming -= o.num_snap_trimming;
op_queue_age_hist.sub(o.op_queue_age_hist);
os_perf_stat.sub(o.os_perf_stat);
+ num_pgs -= o.num_pgs;
}
void dump(Formatter *f) const;
l.num_snap_trimming == r.num_snap_trimming &&
l.hb_peers == r.hb_peers &&
l.op_queue_age_hist == r.op_queue_age_hist &&
- l.os_perf_stat == r.os_perf_stat;
+ l.os_perf_stat == r.os_perf_stat &&
+ l.num_pgs == r.num_pgs;
}
inline bool operator!=(const osd_stat_t& l, const osd_stat_t& r) {
return !(l == r);