]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDForceRecovery.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) 2017 OVH
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_MOSDFORCERECOVERY_H
17 #define CEPH_MOSDFORCERECOVERY_H
19 #include "msg/Message.h"
22 * instruct an OSD to boost/unboost recovery/backfill priority of some or all pg(s)
25 // boost priority of recovery
26 static const int OFR_RECOVERY
= 1;
28 // boost priority of backfill
29 static const int OFR_BACKFILL
= 2;
31 // cancel priority boost, requeue if necessary
32 static const int OFR_CANCEL
= 4;
34 class MOSDForceRecovery final
: public Message
{
36 static constexpr int HEAD_VERSION
= 2;
37 static constexpr int COMPAT_VERSION
= 2;
40 std::vector
<spg_t
> forced_pgs
;
43 MOSDForceRecovery() : Message
{MSG_OSD_FORCE_RECOVERY
, HEAD_VERSION
, COMPAT_VERSION
} {}
44 MOSDForceRecovery(const uuid_d
& f
, char opts
) :
45 Message
{MSG_OSD_FORCE_RECOVERY
, HEAD_VERSION
, COMPAT_VERSION
},
46 fsid(f
), options(opts
) {}
47 MOSDForceRecovery(const uuid_d
& f
, std::vector
<spg_t
>& pgs
, char opts
) :
48 Message
{MSG_OSD_FORCE_RECOVERY
, HEAD_VERSION
, COMPAT_VERSION
},
49 fsid(f
), forced_pgs(pgs
), options(opts
) {}
51 ~MOSDForceRecovery() final
{}
54 std::string_view
get_type_name() const { return "force_recovery"; }
55 void print(std::ostream
& out
) const {
56 out
<< "force_recovery(";
57 if (forced_pgs
.empty())
61 if (options
& OFR_RECOVERY
)
63 if (options
& OFR_BACKFILL
)
65 if (options
& OFR_CANCEL
)
70 void encode_payload(uint64_t features
) {
72 if (!HAVE_FEATURE(features
, SERVER_MIMIC
)) {
74 header
.compat_version
= 1;
75 std::vector
<pg_t
> pgs
;
76 for (auto pgid
: forced_pgs
) {
77 pgs
.push_back(pgid
.pgid
);
79 encode(fsid
, payload
);
81 encode(options
, payload
);
84 header
.version
= HEAD_VERSION
;
85 header
.compat_version
= COMPAT_VERSION
;
86 encode(fsid
, payload
);
87 encode(forced_pgs
, payload
);
88 encode(options
, payload
);
90 void decode_payload() {
92 auto p
= payload
.cbegin();
93 if (header
.version
== 1) {
94 std::vector
<pg_t
> pgs
;
99 // note: this only works with replicated pools. if a pre-mimic mon
100 // tries to force a mimic+ osd on an ec pool it will not work.
101 forced_pgs
.push_back(spg_t(pg
));
106 decode(forced_pgs
, p
);
110 template<class T
, typename
... Args
>
111 friend boost::intrusive_ptr
<T
> ceph::make_message(Args
&&... args
);
114 #endif /* CEPH_MOSDFORCERECOVERY_H_ */