]>
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"
21 class MBackfillReserve
: public MessageInstance
<MBackfillReserve
, MOSDPeeringOp
> {
25 static constexpr int HEAD_VERSION
= 5;
26 static constexpr int COMPAT_VERSION
= 4;
31 REQUEST
= 0, // primary->replica: please reserve a slot
32 GRANT
= 1, // replica->primary: ok, i reserved it
33 REJECT
= 2, // replica->primary: sorry, try again later (*)
34 RELEASE
= 3, // primary->replcia: release the slot i reserved before
35 TOOFULL
= 4, // replica->primary: too full, stop backfilling
36 REVOKE
= 5, // replica->primary: i'm taking back the slot i gave you
37 // (*) NOTE: prior to luminous, REJECT was overloaded to also mean release
41 int64_t primary_num_bytes
;
42 int64_t shard_num_bytes
;
44 spg_t
get_spg() const {
47 epoch_t
get_map_epoch() const {
50 epoch_t
get_min_epoch() const {
54 PGPeeringEvent
*get_event() override
{
57 return new PGPeeringEvent(
60 RequestBackfillPrio(priority
, primary_num_bytes
, shard_num_bytes
));
62 return new PGPeeringEvent(
65 RemoteBackfillReserved());
67 // NOTE: this is replica -> primary "i reject your request"
68 // and also primary -> replica "cancel my previously-granted request"
70 // and also replica -> primary "i revoke your reservation"
72 return new PGPeeringEvent(
75 RemoteReservationRejected());
77 return new PGPeeringEvent(
80 RemoteReservationCanceled());
82 return new PGPeeringEvent(
85 RemoteReservationRevokedTooFull());
87 return new PGPeeringEvent(
90 RemoteReservationRevoked());
97 : MessageInstance(MSG_OSD_BACKFILL_RESERVE
, HEAD_VERSION
, COMPAT_VERSION
),
98 query_epoch(0), type(-1), priority(-1), primary_num_bytes(0),
100 MBackfillReserve(int type
,
102 epoch_t query_epoch
, unsigned prio
= -1,
103 int64_t primary_num_bytes
= 0,
104 int64_t shard_num_bytes
= 0)
105 : MessageInstance(MSG_OSD_BACKFILL_RESERVE
, HEAD_VERSION
, COMPAT_VERSION
),
106 pgid(pgid
), query_epoch(query_epoch
),
107 type(type
), priority(prio
), primary_num_bytes(primary_num_bytes
),
108 shard_num_bytes(shard_num_bytes
) {}
110 std::string_view
get_type_name() const override
{
111 return "MBackfillReserve";
114 void inner_print(ostream
& out
) const override
{
135 if (type
== REQUEST
) out
<< " prio: " << priority
;
139 void decode_payload() override
{
140 auto p
= payload
.cbegin();
141 decode(pgid
.pgid
, p
);
142 decode(query_epoch
, p
);
145 decode(pgid
.shard
, p
);
146 if (header
.version
>= 5) {
147 decode(primary_num_bytes
, p
);
148 decode(shard_num_bytes
, p
);
150 primary_num_bytes
= 0;
155 void encode_payload(uint64_t features
) override
{
157 if (!HAVE_FEATURE(features
, RECOVERY_RESERVATION_2
)) {
159 header
.compat_version
= 3;
160 encode(pgid
.pgid
, payload
);
161 encode(query_epoch
, payload
);
162 encode((type
== RELEASE
|| type
== TOOFULL
|| type
== REVOKE
) ?
163 REJECT
: type
, payload
);
164 encode(priority
, payload
);
165 encode(pgid
.shard
, payload
);
168 header
.version
= HEAD_VERSION
;
169 header
.compat_version
= COMPAT_VERSION
;
170 encode(pgid
.pgid
, payload
);
171 encode(query_epoch
, payload
);
172 encode(type
, payload
);
173 encode(priority
, payload
);
174 encode(pgid
.shard
, payload
);
175 encode(primary_num_bytes
, payload
);
176 encode(shard_num_bytes
, payload
);