]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGNotify.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
15 #ifndef CEPH_MOSDPGPEERNOTIFY_H
16 #define CEPH_MOSDPGPEERNOTIFY_H
18 #include "msg/Message.h"
20 #include "osd/osd_types.h"
23 * PGNotify - notify primary of my PGs and versions.
26 class MOSDPGNotify
: public Message
{
28 static const int HEAD_VERSION
= 6;
29 static const int COMPAT_VERSION
= 2;
32 /// query_epoch is the epoch of the query being responded to, or
33 /// the current epoch if this is not being sent in response to a
34 /// query. This allows the recipient to disregard responses to old
36 vector
<pair
<pg_notify_t
,PastIntervals
> > pg_list
; // pgid -> version
39 version_t
get_epoch() const { return epoch
; }
40 const vector
<pair
<pg_notify_t
,PastIntervals
> >& get_pg_list() const {
45 : Message(MSG_OSD_PG_NOTIFY
, HEAD_VERSION
, COMPAT_VERSION
) {
46 set_priority(CEPH_MSG_PRIO_HIGH
);
48 MOSDPGNotify(epoch_t e
, vector
<pair
<pg_notify_t
,PastIntervals
> >& l
)
49 : Message(MSG_OSD_PG_NOTIFY
, HEAD_VERSION
, COMPAT_VERSION
),
52 set_priority(CEPH_MSG_PRIO_HIGH
);
55 ~MOSDPGNotify() override
{}
58 const char *get_type_name() const override
{ return "PGnot"; }
60 void encode_payload(uint64_t features
) override
{
61 if (!HAVE_FEATURE(features
, SERVER_LUMINOUS
)) {
62 // for jewel+kraken compat only
65 // Use query_epoch for first entry for backwards compatibility
66 epoch_t query_epoch
= epoch
;
68 query_epoch
= pg_list
.begin()->first
.query_epoch
;
70 ::encode(epoch
, payload
);
72 // v2 was vector<pg_info_t>
73 __u32 n
= pg_list
.size();
75 for (auto p
= pg_list
.begin();
78 ::encode(p
->first
.info
, payload
);
80 ::encode(query_epoch
, payload
);
82 // v3 needs the PastIntervals for each record
83 for (auto p
= pg_list
.begin();
86 p
->second
.encode_classic(payload
);
89 // v4 needs epoch_sent, query_epoch
90 for (vector
<pair
<pg_notify_t
,PastIntervals
> >::iterator p
= pg_list
.begin();
93 ::encode(pair
<epoch_t
, epoch_t
>(
94 p
->first
.epoch_sent
, p
->first
.query_epoch
),
98 for (vector
<pair
<pg_notify_t
, PastIntervals
> >::iterator p
= pg_list
.begin();
101 ::encode(p
->first
.from
, payload
);
102 ::encode(p
->first
.to
, payload
);
107 ::encode(epoch
, payload
);
108 ::encode(pg_list
, payload
);
111 void decode_payload() override
{
112 bufferlist::iterator p
= payload
.begin();
113 if (header
.version
< 6) {
114 // for kraken+jewel compat only
118 // decode pg_info_t portion of the vector
122 for (unsigned i
=0; i
<n
; i
++) {
123 ::decode(pg_list
[i
].first
.info
, p
);
126 ::decode(query_epoch
, p
);
128 if (header
.version
>= 3) {
129 // get the PastIntervals portion
130 for (unsigned i
=0; i
<n
; i
++) {
131 pg_list
[i
].second
.decode_classic(p
);
135 // v3 needs epoch_sent, query_epoch
136 for (auto i
= pg_list
.begin();
139 if (header
.version
>= 4) {
140 pair
<epoch_t
, epoch_t
> dec
;
142 i
->first
.epoch_sent
= dec
.first
;
143 i
->first
.query_epoch
= dec
.second
;
145 i
->first
.epoch_sent
= epoch
;
146 i
->first
.query_epoch
= query_epoch
;
150 // v5 needs from and to
151 if (header
.version
>= 5) {
152 for (auto i
= pg_list
.begin();
155 ::decode(i
->first
.from
, p
);
156 ::decode(i
->first
.to
, p
);
163 ::decode(pg_list
, p
);
165 void print(ostream
& out
) const override
{
167 for (auto i
= pg_list
.begin();
170 if (i
!= pg_list
.begin())
172 out
<< i
->first
<< "=" << i
->second
;
174 out
<< " epoch " << epoch