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_MOSDPGLOG_H
17 #define CEPH_MOSDPGLOG_H
19 #include "messages/MOSDPeeringOp.h"
20 #include "osd/PGPeeringEvent.h"
22 class MOSDPGLog
: public MOSDPeeringOp
{
24 static constexpr int HEAD_VERSION
= 6;
25 static constexpr int COMPAT_VERSION
= 5;
28 /// query_epoch is the epoch of the query being responded to, or
29 /// the current epoch if this is not being sent in response to a
30 /// query. This allows the recipient to disregard responses to old
32 epoch_t query_epoch
= 0;
40 PastIntervals past_intervals
;
41 std::optional
<pg_lease_t
> lease
;
43 epoch_t
get_epoch() const { return epoch
; }
44 spg_t
get_pgid() const { return spg_t(info
.pgid
.pgid
, to
); }
45 epoch_t
get_query_epoch() const { return query_epoch
; }
47 spg_t
get_spg() const override
{
48 return spg_t(info
.pgid
.pgid
, to
);
50 epoch_t
get_map_epoch() const override
{
53 epoch_t
get_min_epoch() const override
{
57 PGPeeringEvent
*get_event() override
{
58 return new PGPeeringEvent(
60 MLogRec(pg_shard_t(get_source().num(), from
),
71 MOSDPGLog() : MOSDPeeringOp
{MSG_OSD_PG_LOG
, HEAD_VERSION
, COMPAT_VERSION
} {
72 set_priority(CEPH_MSG_PRIO_HIGH
);
74 MOSDPGLog(shard_id_t to
, shard_id_t from
,
75 version_t mv
, const pg_info_t
& i
, epoch_t query_epoch
)
76 : MOSDPeeringOp
{MSG_OSD_PG_LOG
, HEAD_VERSION
, COMPAT_VERSION
},
77 epoch(mv
), query_epoch(query_epoch
),
80 set_priority(CEPH_MSG_PRIO_HIGH
);
84 ~MOSDPGLog() override
{}
87 std::string_view
get_type_name() const override
{ return "PGlog"; }
88 void inner_print(std::ostream
& out
) const override
{
89 // NOTE: log is not const, but operator<< doesn't touch fields
90 // swapped out by OSD code.
92 << " pi " << past_intervals
;
98 void encode_payload(uint64_t features
) override
{
100 encode(epoch
, payload
);
101 encode(info
, payload
);
102 encode(log
, payload
);
103 encode(missing
, payload
, features
);
104 if (!HAVE_FEATURE(features
, SERVER_NAUTILUS
)) {
105 // pre-nautilus OSDs do not set last_peering_reset properly
106 encode(epoch
, payload
);
108 encode(query_epoch
, payload
);
110 encode(past_intervals
, payload
);
112 encode(from
, payload
);
113 encode(lease
, payload
);
115 void decode_payload() override
{
117 auto p
= payload
.cbegin();
120 log
.decode(p
, info
.pgid
.pool());
121 missing
.decode(p
, info
.pgid
.pool());
122 decode(query_epoch
, p
);
123 decode(past_intervals
, p
);
126 if (header
.version
>= 6) {
131 template<class T
, typename
... Args
>
132 friend boost::intrusive_ptr
<T
> ceph::make_message(Args
&&... args
);