]>
Commit | Line | Data |
---|---|---|
c07f9fc5 FG |
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 | ||
9f95a23c | 34 | class MOSDForceRecovery : public Message { |
11fdf7f2 | 35 | public: |
11fdf7f2 TL |
36 | static constexpr int HEAD_VERSION = 2; |
37 | static constexpr int COMPAT_VERSION = 2; | |
c07f9fc5 FG |
38 | |
39 | uuid_d fsid; | |
11fdf7f2 TL |
40 | vector<spg_t> forced_pgs; |
41 | uint8_t options = 0; | |
c07f9fc5 | 42 | |
9f95a23c | 43 | MOSDForceRecovery() : Message{MSG_OSD_FORCE_RECOVERY, HEAD_VERSION, COMPAT_VERSION} {} |
c07f9fc5 | 44 | MOSDForceRecovery(const uuid_d& f, char opts) : |
9f95a23c | 45 | Message{MSG_OSD_FORCE_RECOVERY, HEAD_VERSION, COMPAT_VERSION}, |
c07f9fc5 | 46 | fsid(f), options(opts) {} |
11fdf7f2 | 47 | MOSDForceRecovery(const uuid_d& f, vector<spg_t>& pgs, char opts) : |
9f95a23c | 48 | Message{MSG_OSD_FORCE_RECOVERY, HEAD_VERSION, COMPAT_VERSION}, |
c07f9fc5 FG |
49 | fsid(f), forced_pgs(pgs), options(opts) {} |
50 | private: | |
51 | ~MOSDForceRecovery() {} | |
52 | ||
53 | public: | |
11fdf7f2 | 54 | std::string_view get_type_name() const { return "force_recovery"; } |
c07f9fc5 FG |
55 | void print(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) { | |
11fdf7f2 TL |
71 | using ceph::encode; |
72 | if (!HAVE_FEATURE(features, SERVER_MIMIC)) { | |
73 | header.version = 1; | |
74 | header.compat_version = 1; | |
75 | 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); | |
c07f9fc5 FG |
89 | } |
90 | void decode_payload() { | |
11fdf7f2 TL |
91 | auto p = payload.cbegin(); |
92 | if (header.version == 1) { | |
93 | vector<pg_t> pgs; | |
94 | decode(fsid, p); | |
95 | decode(pgs, p); | |
96 | decode(options, p); | |
97 | for (auto pg : pgs) { | |
98 | // note: this only works with replicated pools. if a pre-mimic mon | |
99 | // tries to force a mimic+ osd on an ec pool it will not work. | |
100 | forced_pgs.push_back(spg_t(pg)); | |
101 | } | |
102 | return; | |
103 | } | |
104 | decode(fsid, p); | |
105 | decode(forced_pgs, p); | |
106 | decode(options, p); | |
c07f9fc5 | 107 | } |
9f95a23c TL |
108 | private: |
109 | template<class T, typename... Args> | |
110 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
c07f9fc5 FG |
111 | }; |
112 | ||
113 | #endif /* CEPH_MOSDFORCERECOVERY_H_ */ |