Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osd: check feature bits when encoding objectstore_perf_stat_t #20378

Merged
merged 1 commit into from Feb 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/include/ceph_features.h
Expand Up @@ -92,6 +92,7 @@ DEFINE_CEPH_FEATURE_RETIRED(16, 1, QUERY_T, JEWEL, LUMINOUS)
DEFINE_CEPH_FEATURE(16, 3, SERVER_O)
DEFINE_CEPH_FEATURE_RETIRED(17, 1, INDEP_PG_MAP, JEWEL, LUMINOUS)
DEFINE_CEPH_FEATURE(17, 2, QOS_DMC)
DEFINE_CEPH_FEATURE(17, 2, OS_PERF_STAT_NS)

DEFINE_CEPH_FEATURE(18, 1, CRUSH_TUNABLES)
DEFINE_CEPH_FEATURE_RETIRED(19, 1, CHUNKY_SCRUB, JEWEL, LUMINOUS)
Expand Down
2 changes: 1 addition & 1 deletion src/messages/MPGStats.h
Expand Up @@ -47,7 +47,7 @@ class MPGStats : public PaxosServiceMessage {
using ceph::encode;
paxos_encode();
encode(fsid, payload);
encode(osd_stat, payload);
encode(osd_stat, payload, features);
encode(pg_stat, payload);
encode(epoch, payload);
encode(had_map_for, payload);
Expand Down
4 changes: 2 additions & 2 deletions src/mon/PGMap.cc
Expand Up @@ -38,7 +38,7 @@ void PGMapDigest::encode(bufferlist& bl, uint64_t features) const
encode(num_osd, bl);
encode(pg_pool_sum, bl, features);
encode(pg_sum, bl, features);
encode(osd_sum, bl);
encode(osd_sum, bl, features);
if (v >= 2) {
encode(num_pg_by_state, bl);
} else {
Expand Down Expand Up @@ -1340,7 +1340,7 @@ void PGMap::encode(bufferlist &bl, uint64_t features) const
ENCODE_START(7, 7, bl);
encode(version, bl);
encode(pg_stat, bl);
encode(osd_stat, bl);
encode(osd_stat, bl, features);
encode(last_osdmap_epoch, bl);
encode(last_pg_scan, bl);
encode(stamp, bl);
Expand Down
41 changes: 25 additions & 16 deletions src/osd/osd_types.cc
Expand Up @@ -283,31 +283,40 @@ void objectstore_perf_stat_t::dump(Formatter *f) const
f->dump_unsigned("apply_latency_ns", os_apply_latency_ns);
}

void objectstore_perf_stat_t::encode(bufferlist &bl) const
void objectstore_perf_stat_t::encode(bufferlist &bl, uint64_t features) const
{
uint32_t commit_latency_ms = os_commit_latency_ns / 1000000;
uint32_t apply_latency_ms = os_apply_latency_ns / 1000000;
ENCODE_START(2, 1, bl);
encode(commit_latency_ms, bl); // for compatibility with older monitor.
encode(apply_latency_ms, bl); // for compatibility with older monitor.
encode(os_commit_latency_ns, bl);
encode(os_apply_latency_ns, bl);
uint8_t target_v = 2;
if (!HAVE_FEATURE(features, OS_PERF_STAT_NS)) {
target_v = 1;
}
ENCODE_START(target_v, target_v, bl);
if (target_v >= 2) {
encode(os_commit_latency_ns, bl);
encode(os_apply_latency_ns, bl);
} else {
constexpr auto NS_PER_MS = std::chrono::nanoseconds(1ms).count();
uint32_t commit_latency_ms = os_commit_latency_ns / NS_PER_MS;
uint32_t apply_latency_ms = os_apply_latency_ns / NS_PER_MS;
encode(commit_latency_ms, bl); // for compatibility with older monitor.
encode(apply_latency_ms, bl); // for compatibility with older monitor.
}
ENCODE_FINISH(bl);
}

void objectstore_perf_stat_t::decode(bufferlist::iterator &bl)
{
DECODE_START(2, bl);
uint32_t commit_latency_ms;
uint32_t apply_latency_ms;
decode(commit_latency_ms, bl);
decode(apply_latency_ms, bl);
if (struct_v >= 2) {
decode(os_commit_latency_ns, bl);
decode(os_apply_latency_ns, bl);
} else {
os_commit_latency_ns = commit_latency_ms * (uint64_t) 1000000;
os_apply_latency_ns = apply_latency_ms * (uint64_t) 1000000;
uint32_t commit_latency_ms;
uint32_t apply_latency_ms;
decode(commit_latency_ms, bl);
decode(apply_latency_ms, bl);
constexpr auto NS_PER_MS = std::chrono::nanoseconds(1ms).count();
os_commit_latency_ns = commit_latency_ms * NS_PER_MS;
os_apply_latency_ns = apply_latency_ms * NS_PER_MS;
}
DECODE_FINISH(bl);
}
Expand Down Expand Up @@ -343,7 +352,7 @@ void osd_stat_t::dump(Formatter *f) const
f->close_section();
}

void osd_stat_t::encode(bufferlist &bl) const
void osd_stat_t::encode(bufferlist &bl, uint64_t features) const
{
ENCODE_START(7, 2, bl);
encode(kb, bl);
Expand All @@ -354,7 +363,7 @@ void osd_stat_t::encode(bufferlist &bl) const
encode(hb_peers, bl);
encode((uint32_t)0, bl);
encode(op_queue_age_hist, bl);
encode(os_perf_stat, bl);
encode(os_perf_stat, bl, features);
encode(up_from, bl);
encode(seq, bl);
encode(num_pgs, bl);
Expand Down
8 changes: 4 additions & 4 deletions src/osd/osd_types.h
Expand Up @@ -904,11 +904,11 @@ struct objectstore_perf_stat_t {
os_apply_latency_ns -= o.os_apply_latency_ns;
}
void dump(Formatter *f) const;
void encode(bufferlist &bl) const;
void encode(bufferlist &bl, uint64_t features) const;
void decode(bufferlist::iterator &bl);
static void generate_test_instances(std::list<objectstore_perf_stat_t*>& o);
};
WRITE_CLASS_ENCODER(objectstore_perf_stat_t)
WRITE_CLASS_ENCODER_FEATURES(objectstore_perf_stat_t)

/** osd_stat
* aggregate stats for an osd
Expand Down Expand Up @@ -952,11 +952,11 @@ struct osd_stat_t {
}

void dump(Formatter *f) const;
void encode(bufferlist &bl) const;
void encode(bufferlist &bl, uint64_t features) const;
void decode(bufferlist::iterator &bl);
static void generate_test_instances(std::list<osd_stat_t*>& o);
};
WRITE_CLASS_ENCODER(osd_stat_t)
WRITE_CLASS_ENCODER_FEATURES(osd_stat_t)

inline bool operator==(const osd_stat_t& l, const osd_stat_t& r) {
return l.kb == r.kb &&
Expand Down
4 changes: 2 additions & 2 deletions src/test/encoding/types.h
Expand Up @@ -59,8 +59,8 @@ TYPE(object_locator_t)
TYPE(request_redirect_t)
TYPE(pg_t)
TYPE(coll_t)
TYPE(objectstore_perf_stat_t)
TYPE(osd_stat_t)
TYPE_FEATUREFUL(objectstore_perf_stat_t)
TYPE_FEATUREFUL(osd_stat_t)
TYPE(OSDSuperblock)
TYPE_FEATUREFUL(pool_snap_info_t)
TYPE_FEATUREFUL(pg_pool_t)
Expand Down