]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MOSDPGInfo.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / messages / MOSDPGInfo.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15
16#ifndef CEPH_MOSDPGINFO_H
17#define CEPH_MOSDPGINFO_H
18
19#include "msg/Message.h"
20#include "osd/osd_types.h"
21
22class MOSDPGInfo : public Message {
23 static const int HEAD_VERSION = 5;
24 static const int COMPAT_VERSION = 1;
25
26 epoch_t epoch;
27
28public:
29 vector<pair<pg_notify_t,PastIntervals> > pg_list;
30
31 epoch_t get_epoch() const { return epoch; }
32
33 MOSDPGInfo()
34 : Message(MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION) {
35 set_priority(CEPH_MSG_PRIO_HIGH);
36 }
37 MOSDPGInfo(version_t mv)
38 : Message(MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION),
39 epoch(mv) {
40 set_priority(CEPH_MSG_PRIO_HIGH);
41 }
42private:
43 ~MOSDPGInfo() override {}
44
45public:
46 const char *get_type_name() const override { return "pg_info"; }
47 void print(ostream& out) const override {
48 out << "pg_info(";
49 for (auto i = pg_list.begin();
50 i != pg_list.end();
51 ++i) {
52 if (i != pg_list.begin())
53 out << " ";
54 out << i->first << "=" << i->second;
55 }
56 out << " epoch " << epoch
57 << ")";
58 }
59
60 void encode_payload(uint64_t features) override {
61 if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
62 header.version = 4;
63
64 // for kraken+jewel only
65 ::encode(epoch, payload);
66
67 // v1 was vector<pg_info_t>
68 __u32 n = pg_list.size();
69 ::encode(n, payload);
70 for (auto p = pg_list.begin();
71 p != pg_list.end();
72 p++)
73 ::encode(p->first.info, payload);
74
75 // v2 needs the PastIntervals for each record
76 for (auto p = pg_list.begin();
77 p != pg_list.end();
78 p++) {
79 p->second.encode_classic(payload);
80 }
81
82 // v3 needs epoch_sent, query_epoch
83 for (auto p = pg_list.begin();
84 p != pg_list.end();
85 p++)
86 ::encode(pair<epoch_t, epoch_t>(
87 p->first.epoch_sent, p->first.query_epoch), payload);
88
89 // v4 needs from, to
90 for (auto p = pg_list.begin();
91 p != pg_list.end();
92 ++p) {
93 ::encode(p->first.from, payload);
94 ::encode(p->first.to, payload);
95 }
96 return;
97 }
98 ::encode(epoch, payload);
99 ::encode(pg_list, payload);
100 }
101 void decode_payload() override {
102 bufferlist::iterator p = payload.begin();
103 if (header.version < 5) {
104 ::decode(epoch, p);
105
106 // decode pg_info_t portion of the vector
107 __u32 n;
108 ::decode(n, p);
109 pg_list.resize(n);
110 for (unsigned i=0; i<n; i++) {
111 ::decode(pg_list[i].first.info, p);
112 }
113
114 if (header.version >= 2) {
115 // get the PastIntervals portion
116 for (unsigned i=0; i<n; i++) {
117 if (header.version >= 5) {
118 ::decode(pg_list[i].second, p);
119 } else {
120 pg_list[i].second.decode_classic(p);
121 }
122 }
123 }
124
125 // v3 needs epoch_sent, query_epoch
126 for (auto i = pg_list.begin();
127 i != pg_list.end();
128 i++) {
129 if (header.version >= 3) {
130 pair<epoch_t, epoch_t> dec;
131 ::decode(dec, p);
132 i->first.epoch_sent = dec.first;
133 i->first.query_epoch = dec.second;
134 } else {
135 i->first.epoch_sent = epoch;
136 i->first.query_epoch = epoch;
137 }
138 }
139
140 // v4 needs from and to
141 if (header.version >= 4) {
142 for (auto i = pg_list.begin();
143 i != pg_list.end();
144 i++) {
145 ::decode(i->first.from, p);
146 ::decode(i->first.to, p);
147 }
148 }
149 return;
150 }
151 ::decode(epoch, p);
152 ::decode(pg_list, p);
153 }
154};
155
156#endif