Skip to content

Commit

Permalink
Merge branch 'wip-pi'
Browse files Browse the repository at this point in the history
Reviewed-by: Samuel Just <[email protected]>
  • Loading branch information
liewegas committed Apr 30, 2012
2 parents 580b520 + d64e1b9 commit 05bbe14
Show file tree
Hide file tree
Showing 14 changed files with 413 additions and 213 deletions.
57 changes: 49 additions & 8 deletions src/messages/MOSDPGInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,75 @@
#include "osd/osd_types.h"

class MOSDPGInfo : public Message {
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;

epoch_t epoch;

public:
vector<pg_info_t> pg_info;
vector<pair<pg_info_t,pg_interval_map_t> > pg_list;

epoch_t get_epoch() { return epoch; }

MOSDPGInfo() : Message(MSG_OSD_PG_INFO) {}
MOSDPGInfo(version_t mv) :
Message(MSG_OSD_PG_INFO),
epoch(mv) { }
MOSDPGInfo()
: Message(MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION) {}
MOSDPGInfo(version_t mv)
: Message(MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION),
epoch(mv) { }
private:
~MOSDPGInfo() {}

public:
const char *get_type_name() const { return "pg_info"; }
void print(ostream& out) const {
out << "pg_info(" << pg_info.size() << " pgs e" << epoch << ")";
out << "pg_info(" << pg_list.size() << " pgs e" << epoch << ":";

for (vector<pair<pg_info_t,pg_interval_map_t> >::const_iterator i = pg_list.begin();
i != pg_list.end();
++i) {
if (i != pg_list.begin())
out << ",";
out << i->first.pgid;
if (i->second.size())
out << "(" << i->second.size() << ")";
}

out << ")";
}

void encode_payload(uint64_t features) {
::encode(epoch, payload);
::encode(pg_info, payload);

// v1 was vector<pg_info_t>
__u32 n = pg_list.size();
::encode(n, payload);
for (vector<pair<pg_info_t,pg_interval_map_t> >::iterator p = pg_list.begin();
p != pg_list.end();
p++)
::encode(p->first, payload);

// v2 needs the pg_interval_map_t for each record
for (vector<pair<pg_info_t,pg_interval_map_t> >::iterator p = pg_list.begin();
p != pg_list.end();
p++)
::encode(p->second, payload);
}
void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(epoch, p);
::decode(pg_info, p);

// decode pg_info_t portion of the vector
__u32 n;
::decode(n, p);
pg_list.resize(n);
for (unsigned i=0; i<n; i++)
::decode(pg_list[i].first, p);

if (header.version >= 2) {
// get the pg_interval_map_t portion
for (unsigned i=0; i<n; i++)
::decode(pg_list[i].second, p);
}
}
};

Expand Down
14 changes: 10 additions & 4 deletions src/messages/MOSDPGLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

class MOSDPGLog : public Message {

static const int HEAD_VERSION = 2;
static const int HEAD_VERSION = 3;
static const int COMPAT_VERSION = 2;

epoch_t epoch;
/// query_epoch is the epoch of the query being responded to, or
Expand All @@ -33,17 +34,18 @@ class MOSDPGLog : public Message {
pg_info_t info;
pg_log_t log;
pg_missing_t missing;
pg_interval_map_t past_intervals;

epoch_t get_epoch() { return epoch; }
pg_t get_pgid() { return info.pgid; }
epoch_t get_query_epoch() { return query_epoch; }

MOSDPGLog() : Message(MSG_OSD_PG_LOG, HEAD_VERSION) { }
MOSDPGLog() : Message(MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION) { }
MOSDPGLog(version_t mv, pg_info_t& i)
: Message(MSG_OSD_PG_LOG, HEAD_VERSION),
: Message(MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION),
epoch(mv), query_epoch(mv), info(i) { }
MOSDPGLog(version_t mv, pg_info_t& i, epoch_t query_epoch)
: Message(MSG_OSD_PG_LOG, HEAD_VERSION),
: Message(MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION),
epoch(mv), query_epoch(query_epoch), info(i) { }

private:
Expand All @@ -62,6 +64,7 @@ class MOSDPGLog : public Message {
::encode(log, payload);
::encode(missing, payload);
::encode(query_epoch, payload);
::encode(past_intervals, payload);
}
void decode_payload() {
bufferlist::iterator p = payload.begin();
Expand All @@ -72,6 +75,9 @@ class MOSDPGLog : public Message {
if (header.version >= 2) {
::decode(query_epoch, p);
}
if (header.version >= 3) {
::decode(past_intervals, p);
}
}
};

Expand Down
44 changes: 36 additions & 8 deletions src/messages/MOSDPGNotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

class MOSDPGNotify : public Message {

static const int HEAD_VERSION = 2;
static const int HEAD_VERSION = 3;
static const int COMPAT_VERSION = 1;

epoch_t epoch;
Expand All @@ -34,16 +34,16 @@ class MOSDPGNotify : public Message {
/// query. This allows the recipient to disregard responses to old
/// queries.
epoch_t query_epoch;
vector<pg_info_t> pg_list; // pgid -> version
vector<pair<pg_info_t,pg_interval_map_t> > pg_list; // pgid -> version

public:
version_t get_epoch() { return epoch; }
vector<pg_info_t>& get_pg_list() { return pg_list; }
vector<pair<pg_info_t,pg_interval_map_t> >& get_pg_list() { return pg_list; }
epoch_t get_query_epoch() { return query_epoch; }

MOSDPGNotify()
: Message(MSG_OSD_PG_NOTIFY, HEAD_VERSION, COMPAT_VERSION) { }
MOSDPGNotify(epoch_t e, vector<pg_info_t>& l, epoch_t query_epoch)
MOSDPGNotify(epoch_t e, vector<pair<pg_info_t,pg_interval_map_t> >& l, epoch_t query_epoch)
: Message(MSG_OSD_PG_NOTIFY, HEAD_VERSION, COMPAT_VERSION),
epoch(e), query_epoch(query_epoch) {
pg_list.swap(l);
Expand All @@ -56,25 +56,53 @@ class MOSDPGNotify : public Message {

void encode_payload(uint64_t features) {
::encode(epoch, payload);
::encode(pg_list, payload);

// v2 was vector<pg_info_t>
__u32 n = pg_list.size();
::encode(n, payload);
for (vector<pair<pg_info_t,pg_interval_map_t> >::iterator p = pg_list.begin();
p != pg_list.end();
p++)
::encode(p->first, payload);

::encode(query_epoch, payload);

// v3 needs the pg_interval_map_t for each record
for (vector<pair<pg_info_t,pg_interval_map_t> >::iterator p = pg_list.begin();
p != pg_list.end();
p++)
::encode(p->second, payload);
}
void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(epoch, p);
::decode(pg_list, p);

// decode pg_info_t portion of the vector
__u32 n;
::decode(n, p);
pg_list.resize(n);
for (unsigned i=0; i<n; i++)
::decode(pg_list[i].first, p);

if (header.version >= 2) {
::decode(query_epoch, p);
}
if (header.version >= 3) {
// get the pg_interval_map_t portion
for (unsigned i=0; i<n; i++)
::decode(pg_list[i].second, p);
}
}
void print(ostream& out) const {
out << "pg_notify(";
for (vector<pg_info_t>::const_iterator i = pg_list.begin();
for (vector<pair<pg_info_t,pg_interval_map_t> >::const_iterator i = pg_list.begin();
i != pg_list.end();
++i) {
if (i != pg_list.begin())
out << ",";
out << i->pgid;
out << i->first.pgid;
if (i->second.size())
out << "(" << i->second.size() << ")";
}
out << " epoch " << epoch
<< " query_epoch " << query_epoch
Expand Down
1 change: 0 additions & 1 deletion src/mon/AuthMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "auth/KeyRing.h"

#include "osd/osd_types.h"
#include "osd/PG.h" // yuck

#include "common/config.h"
#include <sstream>
Expand Down
1 change: 0 additions & 1 deletion src/mon/LogMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "common/Timer.h"

#include "osd/osd_types.h"
#include "osd/PG.h" // yuck

#include "common/config.h"
#include <sstream>
Expand Down
1 change: 0 additions & 1 deletion src/mon/PGMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "common/perf_counters.h"

#include "osd/osd_types.h"
#include "osd/PG.h" // yuck

#include "common/config.h"
#include "common/errno.h"
Expand Down
Loading

0 comments on commit 05bbe14

Please sign in to comment.