]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGInfo.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.
16 #ifndef CEPH_MOSDPGINFO_H
17 #define CEPH_MOSDPGINFO_H
19 #include "msg/Message.h"
20 #include "osd/osd_types.h"
22 class MOSDPGInfo
: public Message
{
23 static const int HEAD_VERSION
= 5;
24 static const int COMPAT_VERSION
= 1;
29 vector
<pair
<pg_notify_t
,PastIntervals
> > pg_list
;
31 epoch_t
get_epoch() const { return epoch
; }
34 : Message(MSG_OSD_PG_INFO
, HEAD_VERSION
, COMPAT_VERSION
) {
35 set_priority(CEPH_MSG_PRIO_HIGH
);
37 MOSDPGInfo(version_t mv
)
38 : Message(MSG_OSD_PG_INFO
, HEAD_VERSION
, COMPAT_VERSION
),
40 set_priority(CEPH_MSG_PRIO_HIGH
);
43 ~MOSDPGInfo() override
{}
46 const char *get_type_name() const override
{ return "pg_info"; }
47 void print(ostream
& out
) const override
{
49 for (auto i
= pg_list
.begin();
52 if (i
!= pg_list
.begin())
54 out
<< i
->first
<< "=" << i
->second
;
56 out
<< " epoch " << epoch
60 void encode_payload(uint64_t features
) override
{
61 if (!HAVE_FEATURE(features
, SERVER_LUMINOUS
)) {
64 // for kraken+jewel only
65 ::encode(epoch
, payload
);
67 // v1 was vector<pg_info_t>
68 __u32 n
= pg_list
.size();
70 for (auto p
= pg_list
.begin();
73 ::encode(p
->first
.info
, payload
);
75 // v2 needs the PastIntervals for each record
76 for (auto p
= pg_list
.begin();
79 p
->second
.encode_classic(payload
);
82 // v3 needs epoch_sent, query_epoch
83 for (auto p
= pg_list
.begin();
86 ::encode(pair
<epoch_t
, epoch_t
>(
87 p
->first
.epoch_sent
, p
->first
.query_epoch
), payload
);
90 for (auto p
= pg_list
.begin();
93 ::encode(p
->first
.from
, payload
);
94 ::encode(p
->first
.to
, payload
);
98 ::encode(epoch
, payload
);
99 ::encode(pg_list
, payload
);
101 void decode_payload() override
{
102 bufferlist::iterator p
= payload
.begin();
103 if (header
.version
< 5) {
106 // decode pg_info_t portion of the vector
110 for (unsigned i
=0; i
<n
; i
++) {
111 ::decode(pg_list
[i
].first
.info
, p
);
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
);
120 pg_list
[i
].second
.decode_classic(p
);
125 // v3 needs epoch_sent, query_epoch
126 for (auto i
= pg_list
.begin();
129 if (header
.version
>= 3) {
130 pair
<epoch_t
, epoch_t
> dec
;
132 i
->first
.epoch_sent
= dec
.first
;
133 i
->first
.query_epoch
= dec
.second
;
135 i
->first
.epoch_sent
= epoch
;
136 i
->first
.query_epoch
= epoch
;
140 // v4 needs from and to
141 if (header
.version
>= 4) {
142 for (auto i
= pg_list
.begin();
145 ::decode(i
->first
.from
, p
);
146 ::decode(i
->first
.to
, p
);
152 ::decode(pg_list
, p
);