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 "msg/Message.h"
21 class MOSDPGLog
: public Message
{
23 static const int HEAD_VERSION
= 5;
24 static const int COMPAT_VERSION
= 2;
27 /// query_epoch is the epoch of the query being responded to, or
28 /// the current epoch if this is not being sent in response to a
29 /// query. This allows the recipient to disregard responses to old
39 PastIntervals past_intervals
;
41 epoch_t
get_epoch() const { return epoch
; }
42 spg_t
get_pgid() const { return spg_t(info
.pgid
.pgid
, to
); }
43 epoch_t
get_query_epoch() const { return query_epoch
; }
45 MOSDPGLog() : Message(MSG_OSD_PG_LOG
, HEAD_VERSION
, COMPAT_VERSION
) {
46 set_priority(CEPH_MSG_PRIO_HIGH
);
48 MOSDPGLog(shard_id_t to
, shard_id_t from
, version_t mv
, pg_info_t
& i
)
49 : Message(MSG_OSD_PG_LOG
, HEAD_VERSION
, COMPAT_VERSION
),
50 epoch(mv
), query_epoch(mv
),
53 set_priority(CEPH_MSG_PRIO_HIGH
);
55 MOSDPGLog(shard_id_t to
, shard_id_t from
,
56 version_t mv
, pg_info_t
& i
, epoch_t query_epoch
)
57 : Message(MSG_OSD_PG_LOG
, HEAD_VERSION
, COMPAT_VERSION
),
58 epoch(mv
), query_epoch(query_epoch
),
61 set_priority(CEPH_MSG_PRIO_HIGH
);
65 ~MOSDPGLog() override
{}
68 const char *get_type_name() const override
{ return "PGlog"; }
69 void print(ostream
& out
) const override
{
70 // NOTE: log is not const, but operator<< doesn't touch fields
71 // swapped out by OSD code.
72 out
<< "pg_log(" << info
.pgid
<< " epoch " << epoch
74 << " pi " << past_intervals
75 << " query_epoch " << query_epoch
<< ")";
78 void encode_payload(uint64_t features
) override
{
79 ::encode(epoch
, payload
);
80 ::encode(info
, payload
);
81 ::encode(log
, payload
);
82 ::encode(missing
, payload
);
83 ::encode(query_epoch
, payload
);
84 if (HAVE_FEATURE(features
, SERVER_LUMINOUS
)) {
85 header
.version
= HEAD_VERSION
;
86 ::encode(past_intervals
, payload
);
89 past_intervals
.encode_classic(payload
);
91 ::encode(to
, payload
);
92 ::encode(from
, payload
);
94 void decode_payload() override
{
95 bufferlist::iterator p
= payload
.begin();
98 log
.decode(p
, info
.pgid
.pool());
99 missing
.decode(p
, info
.pgid
.pool());
100 if (header
.version
>= 2) {
101 ::decode(query_epoch
, p
);
103 if (header
.version
>= 3) {
104 if (header
.version
>= 5) {
105 ::decode(past_intervals
, p
);
107 past_intervals
.decode_classic(p
);
110 if (header
.version
>= 4) {
114 to
= shard_id_t::NO_SHARD
;
115 from
= shard_id_t::NO_SHARD
;