]>
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
{
24 static constexpr int HEAD_VERSION
= 6;
25 static constexpr int COMPAT_VERSION
= 5;
30 using pg_list_t
= std::vector
<pg_notify_t
>;
33 epoch_t
get_epoch() const { return epoch
; }
38 MOSDPGInfo(epoch_t mv
)
41 MOSDPGInfo(epoch_t mv
, pg_list_t
&& l
)
42 : Message
{MSG_OSD_PG_INFO
, HEAD_VERSION
, COMPAT_VERSION
},
46 set_priority(CEPH_MSG_PRIO_HIGH
);
49 ~MOSDPGInfo() override
{}
52 std::string_view
get_type_name() const override
{ return "pg_info"; }
53 void print(ostream
& out
) const override
{
55 for (auto i
= pg_list
.begin();
58 if (i
!= pg_list
.begin())
62 out
<< " epoch " << epoch
66 void encode_payload(uint64_t features
) override
{
68 header
.version
= HEAD_VERSION
;
69 encode(epoch
, payload
);
70 if (!HAVE_FEATURE(features
, SERVER_OCTOPUS
)) {
71 // pretend to be vector<pair<pg_notify_t,PastIntervals>>
73 encode((uint32_t)pg_list
.size(), payload
);
74 for (auto& i
: pg_list
) {
75 encode(i
, payload
); // this embeds a dup (ignored) PastIntervals
76 encode(i
.past_intervals
, payload
);
80 encode(pg_list
, payload
);
82 void decode_payload() override
{
83 auto p
= payload
.cbegin();
85 if (header
.version
== 5) {
86 // decode legacy vector<pair<pg_notify_t,PastIntervals>>
90 for (unsigned i
= 0; i
< num
; ++i
) {
91 decode(pg_list
[i
], p
);
92 decode(pg_list
[i
].past_intervals
, p
);
99 template<class T
, typename
... Args
>
100 friend boost::intrusive_ptr
<T
> ceph::make_message(Args
&&... args
);