]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MBackfillReserve.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_MBACKFILL_H
16 #define CEPH_MBACKFILL_H
18 #include "msg/Message.h"
19 #include "messages/MOSDPeeringOp.h"
20 #include "osd/PGPeeringEvent.h"
22 class MBackfillReserve
: public MOSDPeeringOp
{
24 static constexpr int HEAD_VERSION
= 5;
25 static constexpr int COMPAT_VERSION
= 4;
30 REQUEST
= 0, // primary->replica: please reserve a slot
31 GRANT
= 1, // replica->primary: ok, i reserved it
32 REJECT_TOOFULL
= 2, // replica->primary: too full, sorry, try again later (*)
33 RELEASE
= 3, // primary->replcia: release the slot i reserved before
34 REVOKE_TOOFULL
= 4, // replica->primary: too full, stop backfilling
35 REVOKE
= 5, // replica->primary: i'm taking back the slot i gave you
36 // (*) NOTE: prior to luminous, REJECT was overloaded to also mean release
40 int64_t primary_num_bytes
;
41 int64_t shard_num_bytes
;
43 spg_t
get_spg() const {
46 epoch_t
get_map_epoch() const {
49 epoch_t
get_min_epoch() const {
53 PGPeeringEvent
*get_event() override
{
56 return new PGPeeringEvent(
59 RequestBackfillPrio(priority
, primary_num_bytes
, shard_num_bytes
));
61 return new PGPeeringEvent(
64 RemoteBackfillReserved());
66 // NOTE: this is replica -> primary "i reject your request"
67 // and also primary -> replica "cancel my previously-granted request"
69 // and also replica -> primary "i revoke your reservation"
71 return new PGPeeringEvent(
74 RemoteReservationRejectedTooFull());
76 return new PGPeeringEvent(
79 RemoteReservationCanceled());
81 return new PGPeeringEvent(
84 RemoteReservationRevokedTooFull());
86 return new PGPeeringEvent(
89 RemoteReservationRevoked());
96 : MOSDPeeringOp
{MSG_OSD_BACKFILL_RESERVE
, HEAD_VERSION
, COMPAT_VERSION
},
97 query_epoch(0), type(-1), priority(-1), primary_num_bytes(0),
99 MBackfillReserve(int type
,
101 epoch_t query_epoch
, unsigned prio
= -1,
102 int64_t primary_num_bytes
= 0,
103 int64_t shard_num_bytes
= 0)
104 : MOSDPeeringOp
{MSG_OSD_BACKFILL_RESERVE
, HEAD_VERSION
, COMPAT_VERSION
},
105 pgid(pgid
), query_epoch(query_epoch
),
106 type(type
), priority(prio
), primary_num_bytes(primary_num_bytes
),
107 shard_num_bytes(shard_num_bytes
) {}
109 std::string_view
get_type_name() const override
{
110 return "MBackfillReserve";
113 void inner_print(ostream
& out
) const override
{
122 out
<< "REJECT_TOOFULL";
128 out
<< "REVOKE_TOOFULL";
134 if (type
== REQUEST
) out
<< " prio: " << priority
;
138 void decode_payload() override
{
139 auto p
= payload
.cbegin();
140 decode(pgid
.pgid
, p
);
141 decode(query_epoch
, p
);
144 decode(pgid
.shard
, p
);
145 if (header
.version
>= 5) {
146 decode(primary_num_bytes
, p
);
147 decode(shard_num_bytes
, p
);
149 primary_num_bytes
= 0;
154 void encode_payload(uint64_t features
) override
{
156 if (!HAVE_FEATURE(features
, RECOVERY_RESERVATION_2
)) {
158 header
.compat_version
= 3;
159 encode(pgid
.pgid
, payload
);
160 encode(query_epoch
, payload
);
161 encode((type
== RELEASE
|| type
== REVOKE_TOOFULL
|| type
== REVOKE
) ?
162 REJECT_TOOFULL
: type
, payload
);
163 encode(priority
, payload
);
164 encode(pgid
.shard
, payload
);
167 header
.version
= HEAD_VERSION
;
168 header
.compat_version
= COMPAT_VERSION
;
169 encode(pgid
.pgid
, payload
);
170 encode(query_epoch
, payload
);
171 encode(type
, payload
);
172 encode(priority
, payload
);
173 encode(pgid
.shard
, payload
);
174 encode(primary_num_bytes
, payload
);
175 encode(shard_num_bytes
, payload
);