injectfull = count;
}
-void OSDService::set_statfs(const struct store_statfs_t &stbuf)
+void OSDService::set_statfs(const struct store_statfs_t &stbuf,
+ osd_alert_list_t& alerts)
{
uint64_t bytes = stbuf.total;
uint64_t avail = stbuf.available;
std::lock_guard l(stat_lock);
osd_stat.statfs = stbuf;
+ osd_stat.os_alerts.clear();
+ osd_stat.os_alerts[whoami].swap(alerts);
if (cct->_conf->fake_statfs_for_testing) {
osd_stat.statfs.total = bytes;
osd_stat.statfs.available = avail;
osd_alert_list_t alerts;
int r = store->statfs(&stbuf, &alerts);
ceph_assert(r == 0);
- service.set_statfs(stbuf);
+ service.set_statfs(stbuf, alerts);
}
// i'm ready!
osd_alert_list_t alerts;
int r = store->statfs(&stbuf, &alerts);
ceph_assert(r == 0);
- service.set_statfs(stbuf);
+ service.set_statfs(stbuf, alerts);
// osd_lock is not being held, which means the OSD state
// might change when doing the monitor report
osd_stat_t osd_stat;
uint32_t seq = 0;
- void set_statfs(const struct store_statfs_t &stbuf);
+ void set_statfs(const struct store_statfs_t &stbuf,
+ osd_alert_list_t& alerts);
osd_stat_t set_osd_stat(vector<int>& hb_peers, int num_pgs);
float compute_adjusted_ratio(osd_stat_t new_stat, float *pratio, uint64_t adjust_used = 0);
osd_stat_t get_osd_stat() {
#include "osd_types.h"
#include "include/ceph_features.h"
+#include "include/stringify.h"
extern "C" {
#include "crush/hash.h"
}
return lhs << rhs.get_osd() << '(' << (unsigned)(rhs.shard) << ')';
}
+void dump(Formatter* f, const osd_alerts_t& alerts)
+{
+ for (auto& a : alerts) {
+ string s0 = " osd: ";
+ s0 += stringify(a.first);
+ string s;
+ for (auto& aa : a.second) {
+ s = s0;
+ s += " ";
+ s += aa.first;
+ s += ":";
+ s += aa.second;
+ f->dump_string("alert", s);
+ }
+ }
+}
+
// -- osd_reqid_t --
void osd_reqid_t::dump(Formatter *f) const
{
f->open_object_section("perf_stat");
os_perf_stat.dump(f);
f->close_section();
+ f->open_array_section("alerts");
+ ::dump(f, os_alerts);
+ f->close_section();
}
void osd_stat_t::encode(bufferlist &bl, uint64_t features) const
{
- ENCODE_START(9, 2, bl);
+ ENCODE_START(10, 2, bl);
//////// for compatibility ////////
int64_t kb = statfs.kb();
encode(kb_used_meta, bl);
encode(statfs, bl);
///////////////////////////////////
-
+ encode(os_alerts, bl);
ENCODE_FINISH(bl);
}
{
int64_t kb, kb_used,kb_avail;
int64_t kb_used_data, kb_used_omap, kb_used_meta;
- DECODE_START_LEGACY_COMPAT_LEN(9, 2, 2, bl);
+ DECODE_START_LEGACY_COMPAT_LEN(10, 2, 2, bl);
decode(kb, bl);
decode(kb_used, bl);
decode(kb_avail, bl);
statfs.omap_allocated = kb_used_omap << 10;
statfs.internal_metadata = kb_used_meta << 10;
}
+ if (struct_v >= 10) {
+ decode(os_alerts, bl);
+ } else {
+ os_alerts.clear();
+ }
DECODE_FINISH(bl);
}
o.back()->hb_peers.push_back(7);
o.back()->snap_trim_queue_len = 8;
o.back()->num_snap_trimming = 99;
+ o.back()->os_alerts[0].emplace(
+ "some alert", "some alert details");
+ o.back()->os_alerts[1].emplace(
+ "some alert2", "some alert2 details");
}
// -- pg_t --
string ceph_osd_alloc_hint_flag_string(unsigned flags);
typedef map<string,string> osd_alert_list_t;
+/// map osd id -> alert_list_t
+typedef map<int, osd_alert_list_t> osd_alerts_t;
+void dump(Formatter* f, const osd_alerts_t& alerts);
/**
* osd request identifier
pow2_hist_t op_queue_age_hist;
objectstore_perf_stat_t os_perf_stat;
+ osd_alerts_t os_alerts;
epoch_t up_from = 0;
uint64_t seq = 0;
osd_stat_t() : snap_trim_queue_len(0), num_snap_trimming(0) {}
- void add(const osd_stat_t& o) {
+ void add(const osd_stat_t& o) {
statfs.add(o.statfs);
snap_trim_queue_len += o.snap_trim_queue_len;
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;
+ for (const auto& a : o.os_alerts) {
+ auto& target = os_alerts[a.first];
+ for (auto& i : a.second) {
+ target.emplace(i.first, i.second);
+ }
+ }
}
void sub(const osd_stat_t& o) {
statfs.sub(o.statfs);
op_queue_age_hist.sub(o.op_queue_age_hist);
os_perf_stat.sub(o.os_perf_stat);
num_pgs -= o.num_pgs;
+ for (const auto& a : o.os_alerts) {
+ auto& target = os_alerts[a.first];
+ for (auto& i : a.second) {
+ target.erase(i.first);
+ }
+ if (target.empty()) {
+ os_alerts.erase(a.first);
+ }
+ }
}
-
void dump(Formatter *f) const;
void encode(bufferlist &bl, uint64_t features) const;
void decode(bufferlist::const_iterator &bl);