From 34158ed09e1f2ddf34ecac3c0e499b284b71e5d3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 9 Feb 2012 21:15:53 -0800 Subject: [PATCH] ceph-dencoder: add pg_create_t (formerly MOSDPGCreate::create_rec) Signed-off-by: Sage Weil --- src/messages/MOSDPGCreate.h | 25 +++---------------------- src/osd/OSD.cc | 2 +- src/osd/osd_types.cc | 30 ++++++++++++++++++++++++++++++ src/osd/osd_types.h | 17 +++++++++++++++++ src/test/encoding/types.h | 1 + 5 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/messages/MOSDPGCreate.h b/src/messages/MOSDPGCreate.h index d9537363df8c1..38410b99e1df8 100644 --- a/src/messages/MOSDPGCreate.h +++ b/src/messages/MOSDPGCreate.h @@ -17,6 +17,7 @@ #define CEPH_MOSDPGCREATE_H #include "msg/Message.h" +#include "osd/osd_types.h" /* * PGCreate - instruct an OSD to create a pg, if it doesn't already exist @@ -24,25 +25,7 @@ struct MOSDPGCreate : public Message { version_t epoch; - struct create_rec { - epoch_t created; // epoch pg created - pg_t parent; // split from parent (if != pg_t()) - __s32 split_bits; - - void encode(bufferlist &bl) const { - ::encode(created, bl); - ::encode(parent, bl); - ::encode(split_bits, bl); - } - void decode(bufferlist::iterator &bl) { - ::decode(created, bl); - ::decode(parent, bl); - ::decode(split_bits, bl); - } - }; - WRITE_CLASS_ENCODER(create_rec) - - map mkpg; + map mkpg; MOSDPGCreate() : Message(MSG_OSD_PG_CREATE) {} MOSDPGCreate(epoch_t e) : @@ -66,7 +49,7 @@ public: void print(ostream& out) const { out << "osd pg create("; - for (map::const_iterator i = mkpg.begin(); + for (map::const_iterator i = mkpg.begin(); i != mkpg.end(); ++i) { out << "pg" << i->first << "," << i->second.created << "; "; @@ -75,6 +58,4 @@ public: } }; -WRITE_CLASS_ENCODER(MOSDPGCreate::create_rec) - #endif diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 314645c18d128..5134566421446 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4230,7 +4230,7 @@ void OSD::handle_pg_create(OpRequest *op) int num_created = 0; - for (map::iterator p = m->mkpg.begin(); + for (map::iterator p = m->mkpg.begin(); p != m->mkpg.end(); p++) { pg_t pgid = p->first; diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 854b6c4bbc3b3..2ac4b83df610c 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -1531,6 +1531,36 @@ void pg_missing_t::got(const std::map::iterator & missing.erase(m); } +// -- pg_create_t -- + +void pg_create_t::encode(bufferlist &bl) const +{ + ::encode(created, bl); + ::encode(parent, bl); + ::encode(split_bits, bl); +} + +void pg_create_t::decode(bufferlist::iterator &bl) +{ + ::decode(created, bl); + ::decode(parent, bl); + ::decode(split_bits, bl); +} + +void pg_create_t::dump(Formatter *f) const +{ + f->dump_unsigned("created", created); + f->dump_stream("parent") << parent; + f->dump_int("split_bits", split_bits); +} + +void pg_create_t::generate_test_instances(list& o) +{ + o.push_back(new pg_create_t); + o.push_back(new pg_create_t(1, 2)); + o.back()->parent = pg_t(1, 2, 3); +} + // -- OSDSuperblock -- void OSDSuperblock::encode(bufferlist &bl) const diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 65bcb55c1563b..454b9f6ae23dd 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1309,6 +1309,23 @@ struct pg_ls_response_t { WRITE_CLASS_ENCODER(pg_ls_response_t) +/** + * pg creation info + */ +struct pg_create_t { + epoch_t created; // epoch pg created + pg_t parent; // split from parent (if != pg_t()) + __s32 split_bits; + + pg_create_t(unsigned c=0, int s=0) : created(c), split_bits(s) {} + + void encode(bufferlist &bl) const; + void decode(bufferlist::iterator &bl); + void dump(Formatter *f) const; + static void generate_test_instances(list& o); +}; +WRITE_CLASS_ENCODER(pg_create_t) + // ----------------------------------------- struct osd_peer_stat_t { diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 5f1163d6e33a0..f02afdd61cb7d 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -44,6 +44,7 @@ TYPE(pg_log_t) TYPE(pg_missing_t::item) TYPE(pg_missing_t) TYPE(pg_ls_response_t) +TYPE(pg_create_t) TYPE(watch_info_t) TYPE(object_info_t) TYPE(SnapSet) -- 2.39.5