forked from liewegas/ceph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMOSDPGInfo.h
141 lines (120 loc) · 3.58 KB
/
MOSDPGInfo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MOSDPGINFO_H
#define CEPH_MOSDPGINFO_H
#include "msg/Message.h"
#include "osd/osd_types.h"
class MOSDPGInfo : public Message {
static const int HEAD_VERSION = 4;
static const int COMPAT_VERSION = 1;
epoch_t epoch;
public:
vector<pair<pg_notify_t,pg_interval_map_t> > pg_list;
epoch_t get_epoch() { return epoch; }
MOSDPGInfo()
: Message(MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION) {
set_priority(CEPH_MSG_PRIO_HIGH);
}
MOSDPGInfo(version_t mv)
: Message(MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION),
epoch(mv) {
set_priority(CEPH_MSG_PRIO_HIGH);
}
private:
~MOSDPGInfo() {}
public:
const char *get_type_name() const { return "pg_info"; }
void print(ostream& out) const {
out << "pg_info(" << pg_list.size() << " pgs e" << epoch << ":";
for (vector<pair<pg_notify_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.info.pgid;
if (i->second.size())
out << "(" << i->second.size() << ")";
}
out << ")";
}
void encode_payload(uint64_t features) {
::encode(epoch, payload);
// v1 was vector<pg_info_t>
__u32 n = pg_list.size();
::encode(n, payload);
for (vector<pair<pg_notify_t,pg_interval_map_t> >::iterator p = pg_list.begin();
p != pg_list.end();
p++)
::encode(p->first.info, payload);
// v2 needs the pg_interval_map_t for each record
for (vector<pair<pg_notify_t,pg_interval_map_t> >::iterator p = pg_list.begin();
p != pg_list.end();
p++)
::encode(p->second, payload);
// v3 needs epoch_sent, query_epoch
for (vector<pair<pg_notify_t,pg_interval_map_t> >::iterator p = pg_list.begin();
p != pg_list.end();
p++)
::encode(pair<epoch_t, epoch_t>(
p->first.epoch_sent, p->first.query_epoch), payload);
// v4 needs from, to
for (vector<pair<pg_notify_t, pg_interval_map_t> >::iterator p = pg_list.begin();
p != pg_list.end();
++p) {
::encode(p->first.from, payload);
::encode(p->first.to, payload);
}
}
void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(epoch, 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.info, 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);
}
}
// v3 needs epoch_sent, query_epoch
for (vector<pair<pg_notify_t,pg_interval_map_t> >::iterator i = pg_list.begin();
i != pg_list.end();
i++) {
if (header.version >= 3) {
pair<epoch_t, epoch_t> dec;
::decode(dec, p);
i->first.epoch_sent = dec.first;
i->first.query_epoch = dec.second;
} else {
i->first.epoch_sent = epoch;
i->first.query_epoch = epoch;
}
}
// v4 needs from and to
if (header.version >= 4) {
for (vector<pair<pg_notify_t, pg_interval_map_t> >::iterator i = pg_list.begin();
i != pg_list.end();
i++) {
::decode(i->first.from, p);
::decode(i->first.to, p);
}
}
}
};
#endif