From 6c2dea970392d5192f98b6d8ac7a273a4dfce65b Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Wed, 21 Jan 2015 17:45:02 +0000 Subject: [PATCH 1/5] mon: mon_types.h: initialize LevelDBStoreStats and avoid craziness On a mixed-version cluster, say firefly and dumpling, the first round of data health checks could end up with crazy values being reported for data usage/availability for dumpling monitors. This would be caused by dumpling not supporting reporting of store stats, and by not assuming values as zero on decoding we would end up decoding trash. Signed-off-by: Joao Eduardo Luis --- src/mon/mon_types.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mon/mon_types.h b/src/mon/mon_types.h index c3a39979268..f28e5e60816 100644 --- a/src/mon/mon_types.h +++ b/src/mon/mon_types.h @@ -56,6 +56,13 @@ struct LevelDBStoreStats { uint64_t bytes_misc; utime_t last_update; + LevelDBStoreStats() : + bytes_total(0), + bytes_sst(0), + bytes_log(0), + bytes_misc(0) + {} + void dump(Formatter *f) const { assert(f != NULL); f->dump_int("bytes_total", bytes_total); From b8c7baec841e9fecc8abfb4e1578b0a5675f9cd7 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Wed, 21 Jan 2015 17:47:20 +0000 Subject: [PATCH 2/5] include/util.h: initialize ceph_data_stats to zero We decode this struct on the monitor. Although at the moment there's no reports of any weird behavior by not initializing it, let's avoid it completely by setting member values to zero -- just in case and because it's a good policy. Signed-off-by: Joao Eduardo Luis --- src/include/util.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/include/util.h b/src/include/util.h index 4e4476ad644..7801d0654c4 100644 --- a/src/include/util.h +++ b/src/include/util.h @@ -30,6 +30,13 @@ struct ceph_data_stats uint64_t byte_avail; int avail_percent; + ceph_data_stats() : + byte_total(0), + byte_used(0), + byte_avail(0), + avail_percent(0) + { } + void dump(Formatter *f) const { assert(f != NULL); f->dump_int("total", byte_total); From 6c7f3a7dbc467555379db4ff6bfffe04a1b0a049 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Mon, 26 Jan 2015 12:58:24 +0000 Subject: [PATCH 3/5] include/util.h: allow testing encoding/decoding of ceph_data_stats Signed-off-by: Joao Eduardo Luis --- src/include/util.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/include/util.h b/src/include/util.h index 7801d0654c4..87f64999c6d 100644 --- a/src/include/util.h +++ b/src/include/util.h @@ -44,6 +44,33 @@ struct ceph_data_stats f->dump_int("avail", byte_avail); f->dump_int("avail_percent", avail_percent); } + + void encode(bufferlist &bl) const { + ENCODE_START(1, 1, bl); + ::encode(byte_total, bl); + ::encode(byte_used, bl); + ::encode(byte_avail, bl); + ::encode(avail_percent, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::iterator &p) { + DECODE_START(1, p); + ::decode(byte_total, p); + ::decode(byte_used, p); + ::decode(byte_avail, p); + ::decode(avail_percent, p); + DECODE_FINISH(p); + } + + static void generate_test_instances(list& ls) { + ls.push_back(new ceph_data_stats); + ls.push_back(new ceph_data_stats); + ls.back()->byte_total = 1024*1024; + ls.back()->byte_used = 512*1024; + ls.back()->byte_avail = 512*1024; + ls.back()->avail_percent = 50; + } }; typedef struct ceph_data_stats ceph_data_stats_t; From 028806a56787320e4255fa70765d7dc74cb183b5 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Mon, 26 Jan 2015 12:59:21 +0000 Subject: [PATCH 4/5] mon/mon_types.h: allow testing encode/decode of LevelDBStoreStats Signed-off-by: Joao Eduardo Luis --- src/mon/mon_types.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mon/mon_types.h b/src/mon/mon_types.h index f28e5e60816..d7346cf2de4 100644 --- a/src/mon/mon_types.h +++ b/src/mon/mon_types.h @@ -91,6 +91,16 @@ struct LevelDBStoreStats { ::decode(last_update, p); DECODE_FINISH(p); } + + static void generate_test_instances(list& ls) { + ls.push_back(new LevelDBStoreStats); + ls.push_back(new LevelDBStoreStats); + ls.back()->bytes_total = 1024*1024; + ls.back()->bytes_sst = 512*1024; + ls.back()->bytes_log = 256*1024; + ls.back()->bytes_misc = 256*1024; + ls.back()->last_update = utime_t(); + } }; WRITE_CLASS_ENCODER(LevelDBStoreStats) From 3f73eb497530c5c59888ba565b2d69390b8d98fa Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Fri, 23 Jan 2015 11:30:02 +0000 Subject: [PATCH 5/5] test: encoding: add LevelDBStoreStats and ceph_data_stats to types.h Signed-off-by: Joao Eduardo Luis --- src/test/encoding/types.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index bcc03472c2d..21eefe7402b 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -4,6 +4,9 @@ TYPE(CompatSet) #include "include/filepath.h" TYPE(filepath) +#include "include/util.h" +TYPE(ceph_data_stats) + #include "common/bit_vector.hpp" TYPE(BitVector<2>) @@ -129,6 +132,9 @@ TYPE_FEATUREFUL(MonMap) #include "mon/MonCap.h" TYPE(MonCap) +#include "mon/mon_types.h" +TYPE(LevelDBStoreStats) + #include "os/DBObjectMap.h" TYPE(DBObjectMap::_Header) TYPE(DBObjectMap::State)