]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDForceRecovery.h
bump version to 18.2.2-pve1
[ceph.git] / 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
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2017 OVH
7 *
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.
12 *
13 */
14
15
16 #ifndef CEPH_MOSDFORCERECOVERY_H
17 #define CEPH_MOSDFORCERECOVERY_H
18
19 #include "msg/Message.h"
20
21 /*
22 * instruct an OSD to boost/unboost recovery/backfill priority of some or all pg(s)
23 */
24
25 // boost priority of recovery
26 static const int OFR_RECOVERY = 1;
27
28 // boost priority of backfill
29 static const int OFR_BACKFILL = 2;
30
31 // cancel priority boost, requeue if necessary
32 static const int OFR_CANCEL = 4;
33
34 class MOSDForceRecovery final : public Message {
35 public:
36 static constexpr int HEAD_VERSION = 2;
37 static constexpr int COMPAT_VERSION = 2;
38
39 uuid_d fsid;
40 std::vector<spg_t> forced_pgs;
41 uint8_t options = 0;
42
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) {}
50 private:
51 ~MOSDForceRecovery() final {}
52
53 public:
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())
58 out << "osd";
59 else
60 out << forced_pgs;
61 if (options & OFR_RECOVERY)
62 out << " recovery";
63 if (options & OFR_BACKFILL)
64 out << " backfill";
65 if (options & OFR_CANCEL)
66 out << " cancel";
67 out << ")";
68 }
69
70 void encode_payload(uint64_t features) {
71 using ceph::encode;
72 if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
73 header.version = 1;
74 header.compat_version = 1;
75 std::vector<pg_t> pgs;
76 for (auto pgid : forced_pgs) {
77 pgs.push_back(pgid.pgid);
78 }
79 encode(fsid, payload);
80 encode(pgs, payload);
81 encode(options, payload);
82 return;
83 }
84 header.version = HEAD_VERSION;
85 header.compat_version = COMPAT_VERSION;
86 encode(fsid, payload);
87 encode(forced_pgs, payload);
88 encode(options, payload);
89 }
90 void decode_payload() {
91 using ceph::decode;
92 auto p = payload.cbegin();
93 if (header.version == 1) {
94 std::vector<pg_t> pgs;
95 decode(fsid, p);
96 decode(pgs, p);
97 decode(options, p);
98 for (auto pg : 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));
102 }
103 return;
104 }
105 decode(fsid, p);
106 decode(forced_pgs, p);
107 decode(options, p);
108 }
109 private:
110 template<class T, typename... Args>
111 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
112 };
113
114 #endif /* CEPH_MOSDFORCERECOVERY_H_ */