]>
Commit | Line | Data |
---|---|---|
7c673cae 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) 2004-2006 Sage Weil <sage@newdream.net> | |
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 | ||
3efd9988 FG |
15 | #include "common/debug.h" |
16 | #include "mon/health_check.h" | |
7c673cae FG |
17 | |
18 | #include "MDSMap.h" | |
19 | ||
20 | #include <sstream> | |
21 | using std::stringstream; | |
22 | ||
3efd9988 FG |
23 | #define dout_context g_ceph_context |
24 | #define dout_subsys ceph_subsys_ | |
7c673cae FG |
25 | |
26 | // features | |
1adf2230 | 27 | CompatSet MDSMap::get_compat_set_all() { |
7c673cae FG |
28 | CompatSet::FeatureSet feature_compat; |
29 | CompatSet::FeatureSet feature_ro_compat; | |
30 | CompatSet::FeatureSet feature_incompat; | |
31 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_BASE); | |
32 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_CLIENTRANGES); | |
33 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_FILELAYOUT); | |
34 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_DIRINODE); | |
35 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_ENCODING); | |
36 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_OMAPDIRFRAG); | |
37 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_INLINE); | |
38 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_NOANCHOR); | |
39 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_FILE_LAYOUT_V2); | |
11fdf7f2 | 40 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_SNAPREALM_V2); |
7c673cae FG |
41 | |
42 | return CompatSet(feature_compat, feature_ro_compat, feature_incompat); | |
43 | } | |
44 | ||
1adf2230 | 45 | CompatSet MDSMap::get_compat_set_default() { |
7c673cae FG |
46 | CompatSet::FeatureSet feature_compat; |
47 | CompatSet::FeatureSet feature_ro_compat; | |
48 | CompatSet::FeatureSet feature_incompat; | |
49 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_BASE); | |
50 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_CLIENTRANGES); | |
51 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_FILELAYOUT); | |
52 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_DIRINODE); | |
53 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_ENCODING); | |
54 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_OMAPDIRFRAG); | |
55 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_NOANCHOR); | |
56 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_FILE_LAYOUT_V2); | |
11fdf7f2 | 57 | feature_incompat.insert(MDS_FEATURE_INCOMPAT_SNAPREALM_V2); |
7c673cae FG |
58 | |
59 | return CompatSet(feature_compat, feature_ro_compat, feature_incompat); | |
60 | } | |
61 | ||
62 | // base (pre v0.20) | |
1adf2230 | 63 | CompatSet MDSMap::get_compat_set_base() { |
7c673cae FG |
64 | CompatSet::FeatureSet feature_compat_base; |
65 | CompatSet::FeatureSet feature_incompat_base; | |
66 | feature_incompat_base.insert(MDS_FEATURE_INCOMPAT_BASE); | |
67 | CompatSet::FeatureSet feature_ro_compat_base; | |
68 | ||
69 | return CompatSet(feature_compat_base, feature_ro_compat_base, feature_incompat_base); | |
70 | } | |
71 | ||
72 | void MDSMap::mds_info_t::dump(Formatter *f) const | |
73 | { | |
74 | f->dump_unsigned("gid", global_id); | |
75 | f->dump_string("name", name); | |
76 | f->dump_int("rank", rank); | |
77 | f->dump_int("incarnation", inc); | |
78 | f->dump_stream("state") << ceph_mds_state_name(state); | |
79 | f->dump_int("state_seq", state_seq); | |
11fdf7f2 TL |
80 | f->dump_stream("addr") << addrs.get_legacy_str(); |
81 | f->dump_object("addrs", addrs); | |
9f95a23c | 82 | f->dump_int("join_fscid", join_fscid); |
7c673cae FG |
83 | if (laggy_since != utime_t()) |
84 | f->dump_stream("laggy_since") << laggy_since; | |
85 | ||
7c673cae FG |
86 | f->open_array_section("export_targets"); |
87 | for (set<mds_rank_t>::iterator p = export_targets.begin(); | |
88 | p != export_targets.end(); ++p) { | |
89 | f->dump_int("mds", *p); | |
90 | } | |
91 | f->close_section(); | |
92 | f->dump_unsigned("features", mds_features); | |
11fdf7f2 | 93 | f->dump_unsigned("flags", flags); |
7c673cae FG |
94 | } |
95 | ||
9f95a23c | 96 | void MDSMap::mds_info_t::dump(std::ostream& o) const |
7c673cae | 97 | { |
9f95a23c TL |
98 | o << "[mds." << name << "{" << rank << ":" << global_id << "}" |
99 | << " state " << ceph_mds_state_name(state) | |
100 | << " seq " << state_seq; | |
7c673cae | 101 | if (laggy()) { |
9f95a23c | 102 | o << " laggy since " << laggy_since; |
7c673cae | 103 | } |
7c673cae | 104 | if (!export_targets.empty()) { |
9f95a23c | 105 | o << " export targets " << export_targets; |
7c673cae | 106 | } |
11fdf7f2 | 107 | if (is_frozen()) { |
9f95a23c | 108 | o << " frozen"; |
11fdf7f2 | 109 | } |
9f95a23c TL |
110 | if (join_fscid != FS_CLUSTER_ID_NONE) { |
111 | o << " join_fscid=" << join_fscid; | |
112 | } | |
113 | o << " addr " << addrs << "]"; | |
7c673cae FG |
114 | } |
115 | ||
9f95a23c | 116 | void MDSMap::mds_info_t::generate_test_instances(std::list<mds_info_t*>& ls) |
7c673cae FG |
117 | { |
118 | mds_info_t *sample = new mds_info_t(); | |
119 | ls.push_back(sample); | |
120 | sample = new mds_info_t(); | |
121 | sample->global_id = 1; | |
122 | sample->name = "test_instance"; | |
123 | sample->rank = 0; | |
124 | ls.push_back(sample); | |
125 | } | |
126 | ||
127 | void MDSMap::dump(Formatter *f) const | |
128 | { | |
129 | f->dump_int("epoch", epoch); | |
130 | f->dump_unsigned("flags", flags); | |
131 | f->dump_unsigned("ever_allowed_features", ever_allowed_features); | |
132 | f->dump_unsigned("explicitly_allowed_features", explicitly_allowed_features); | |
133 | f->dump_stream("created") << created; | |
134 | f->dump_stream("modified") << modified; | |
135 | f->dump_int("tableserver", tableserver); | |
136 | f->dump_int("root", root); | |
137 | f->dump_int("session_timeout", session_timeout); | |
138 | f->dump_int("session_autoclose", session_autoclose); | |
9f95a23c TL |
139 | f->dump_stream("min_compat_client") << ceph::to_integer<int>(min_compat_client) << " (" |
140 | << min_compat_client << ")"; | |
7c673cae FG |
141 | f->dump_int("max_file_size", max_file_size); |
142 | f->dump_int("last_failure", last_failure); | |
143 | f->dump_int("last_failure_osd_epoch", last_failure_osd_epoch); | |
144 | f->open_object_section("compat"); | |
145 | compat.dump(f); | |
146 | f->close_section(); | |
147 | f->dump_int("max_mds", max_mds); | |
148 | f->open_array_section("in"); | |
149 | for (set<mds_rank_t>::const_iterator p = in.begin(); p != in.end(); ++p) | |
150 | f->dump_int("mds", *p); | |
151 | f->close_section(); | |
152 | f->open_object_section("up"); | |
153 | for (map<mds_rank_t,mds_gid_t>::const_iterator p = up.begin(); p != up.end(); ++p) { | |
154 | char s[14]; | |
155 | sprintf(s, "mds_%d", int(p->first)); | |
156 | f->dump_int(s, p->second); | |
157 | } | |
158 | f->close_section(); | |
159 | f->open_array_section("failed"); | |
160 | for (set<mds_rank_t>::const_iterator p = failed.begin(); p != failed.end(); ++p) | |
161 | f->dump_int("mds", *p); | |
162 | f->close_section(); | |
163 | f->open_array_section("damaged"); | |
164 | for (set<mds_rank_t>::const_iterator p = damaged.begin(); p != damaged.end(); ++p) | |
165 | f->dump_int("mds", *p); | |
166 | f->close_section(); | |
167 | f->open_array_section("stopped"); | |
168 | for (set<mds_rank_t>::const_iterator p = stopped.begin(); p != stopped.end(); ++p) | |
169 | f->dump_int("mds", *p); | |
170 | f->close_section(); | |
171 | f->open_object_section("info"); | |
9f95a23c | 172 | for (const auto& [gid, info] : mds_info) { |
7c673cae | 173 | char s[25]; // 'gid_' + len(str(ULLONG_MAX)) + '\0' |
9f95a23c | 174 | sprintf(s, "gid_%llu", (long long unsigned)gid); |
7c673cae | 175 | f->open_object_section(s); |
9f95a23c | 176 | info.dump(f); |
7c673cae FG |
177 | f->close_section(); |
178 | } | |
179 | f->close_section(); | |
180 | f->open_array_section("data_pools"); | |
9f95a23c | 181 | for (const auto& p: data_pools) |
31f18b77 | 182 | f->dump_int("pool", p); |
7c673cae FG |
183 | f->close_section(); |
184 | f->dump_int("metadata_pool", metadata_pool); | |
185 | f->dump_bool("enabled", enabled); | |
186 | f->dump_string("fs_name", fs_name); | |
187 | f->dump_string("balancer", balancer); | |
188 | f->dump_int("standby_count_wanted", std::max(0, standby_count_wanted)); | |
189 | } | |
190 | ||
9f95a23c | 191 | void MDSMap::generate_test_instances(std::list<MDSMap*>& ls) |
7c673cae FG |
192 | { |
193 | MDSMap *m = new MDSMap(); | |
194 | m->max_mds = 1; | |
31f18b77 | 195 | m->data_pools.push_back(0); |
7c673cae FG |
196 | m->metadata_pool = 1; |
197 | m->cas_pool = 2; | |
1adf2230 | 198 | m->compat = get_compat_set_all(); |
7c673cae FG |
199 | |
200 | // these aren't the defaults, just in case anybody gets confused | |
201 | m->session_timeout = 61; | |
202 | m->session_autoclose = 301; | |
203 | m->max_file_size = 1<<24; | |
204 | ls.push_back(m); | |
205 | } | |
206 | ||
207 | void MDSMap::print(ostream& out) const | |
208 | { | |
209 | out << "fs_name\t" << fs_name << "\n"; | |
210 | out << "epoch\t" << epoch << "\n"; | |
211 | out << "flags\t" << hex << flags << dec << "\n"; | |
212 | out << "created\t" << created << "\n"; | |
213 | out << "modified\t" << modified << "\n"; | |
214 | out << "tableserver\t" << tableserver << "\n"; | |
215 | out << "root\t" << root << "\n"; | |
216 | out << "session_timeout\t" << session_timeout << "\n" | |
217 | << "session_autoclose\t" << session_autoclose << "\n"; | |
218 | out << "max_file_size\t" << max_file_size << "\n"; | |
9f95a23c TL |
219 | out << "min_compat_client\t" << ceph::to_integer<int>(min_compat_client) << " (" |
220 | << min_compat_client << ")\n"; | |
7c673cae FG |
221 | out << "last_failure\t" << last_failure << "\n" |
222 | << "last_failure_osd_epoch\t" << last_failure_osd_epoch << "\n"; | |
223 | out << "compat\t" << compat << "\n"; | |
224 | out << "max_mds\t" << max_mds << "\n"; | |
225 | out << "in\t" << in << "\n" | |
226 | << "up\t" << up << "\n" | |
227 | << "failed\t" << failed << "\n" | |
228 | << "damaged\t" << damaged << "\n" | |
229 | << "stopped\t" << stopped << "\n"; | |
230 | out << "data_pools\t" << data_pools << "\n"; | |
231 | out << "metadata_pool\t" << metadata_pool << "\n"; | |
232 | out << "inline_data\t" << (inline_data_enabled ? "enabled" : "disabled") << "\n"; | |
233 | out << "balancer\t" << balancer << "\n"; | |
234 | out << "standby_count_wanted\t" << std::max(0, standby_count_wanted) << "\n"; | |
235 | ||
236 | multimap< pair<mds_rank_t, unsigned>, mds_gid_t > foo; | |
237 | for (const auto &p : mds_info) { | |
238 | foo.insert(std::make_pair( | |
239 | std::make_pair(p.second.rank, p.second.inc-1), p.first)); | |
240 | } | |
241 | ||
242 | for (const auto &p : foo) { | |
9f95a23c | 243 | out << mds_info.at(p.second) << "\n"; |
7c673cae FG |
244 | } |
245 | } | |
246 | ||
7c673cae FG |
247 | void MDSMap::print_summary(Formatter *f, ostream *out) const |
248 | { | |
249 | map<mds_rank_t,string> by_rank; | |
250 | map<string,int> by_state; | |
251 | ||
252 | if (f) { | |
253 | f->dump_unsigned("epoch", get_epoch()); | |
254 | f->dump_unsigned("up", up.size()); | |
255 | f->dump_unsigned("in", in.size()); | |
256 | f->dump_unsigned("max", max_mds); | |
257 | } else { | |
258 | *out << "e" << get_epoch() << ": " << up.size() << "/" << in.size() << "/" << max_mds << " up"; | |
259 | } | |
260 | ||
261 | if (f) | |
262 | f->open_array_section("by_rank"); | |
263 | for (const auto &p : mds_info) { | |
264 | string s = ceph_mds_state_name(p.second.state); | |
265 | if (p.second.laggy()) | |
266 | s += "(laggy or crashed)"; | |
267 | ||
268 | if (p.second.rank >= 0 && p.second.state != MDSMap::STATE_STANDBY_REPLAY) { | |
269 | if (f) { | |
270 | f->open_object_section("mds"); | |
271 | f->dump_unsigned("rank", p.second.rank); | |
272 | f->dump_string("name", p.second.name); | |
273 | f->dump_string("status", s); | |
274 | f->close_section(); | |
275 | } else { | |
276 | by_rank[p.second.rank] = p.second.name + "=" + s; | |
277 | } | |
278 | } else { | |
279 | by_state[s]++; | |
280 | } | |
281 | } | |
282 | if (f) { | |
283 | f->close_section(); | |
284 | } else { | |
285 | if (!by_rank.empty()) | |
286 | *out << " " << by_rank; | |
287 | } | |
288 | ||
289 | for (map<string,int>::reverse_iterator p = by_state.rbegin(); p != by_state.rend(); ++p) { | |
290 | if (f) { | |
291 | f->dump_unsigned(p->first.c_str(), p->second); | |
292 | } else { | |
293 | *out << ", " << p->second << " " << p->first; | |
294 | } | |
295 | } | |
296 | ||
297 | if (!failed.empty()) { | |
298 | if (f) { | |
299 | f->dump_unsigned("failed", failed.size()); | |
300 | } else { | |
301 | *out << ", " << failed.size() << " failed"; | |
302 | } | |
303 | } | |
304 | ||
305 | if (!damaged.empty()) { | |
306 | if (f) { | |
307 | f->dump_unsigned("damaged", damaged.size()); | |
308 | } else { | |
309 | *out << ", " << damaged.size() << " damaged"; | |
310 | } | |
311 | } | |
312 | //if (stopped.size()) | |
313 | //out << ", " << stopped.size() << " stopped"; | |
314 | } | |
315 | ||
316 | void MDSMap::get_health(list<pair<health_status_t,string> >& summary, | |
317 | list<pair<health_status_t,string> > *detail) const | |
318 | { | |
319 | if (!failed.empty()) { | |
320 | std::ostringstream oss; | |
321 | oss << "mds rank" | |
322 | << ((failed.size() > 1) ? "s ":" ") | |
323 | << failed | |
324 | << ((failed.size() > 1) ? " have":" has") | |
325 | << " failed"; | |
326 | summary.push_back(make_pair(HEALTH_ERR, oss.str())); | |
327 | if (detail) { | |
328 | for (set<mds_rank_t>::const_iterator p = failed.begin(); p != failed.end(); ++p) { | |
329 | std::ostringstream oss; | |
330 | oss << "mds." << *p << " has failed"; | |
331 | detail->push_back(make_pair(HEALTH_ERR, oss.str())); | |
332 | } | |
333 | } | |
334 | } | |
335 | ||
336 | if (!damaged.empty()) { | |
337 | std::ostringstream oss; | |
338 | oss << "mds rank" | |
339 | << ((damaged.size() > 1) ? "s ":" ") | |
340 | << damaged | |
341 | << ((damaged.size() > 1) ? " are":" is") | |
342 | << " damaged"; | |
343 | summary.push_back(make_pair(HEALTH_ERR, oss.str())); | |
344 | if (detail) { | |
345 | for (set<mds_rank_t>::const_iterator p = damaged.begin(); p != damaged.end(); ++p) { | |
346 | std::ostringstream oss; | |
347 | oss << "mds." << *p << " is damaged"; | |
348 | detail->push_back(make_pair(HEALTH_ERR, oss.str())); | |
349 | } | |
350 | } | |
351 | } | |
352 | ||
353 | if (is_degraded()) { | |
354 | summary.push_back(make_pair(HEALTH_WARN, "mds cluster is degraded")); | |
355 | if (detail) { | |
356 | detail->push_back(make_pair(HEALTH_WARN, "mds cluster is degraded")); | |
357 | for (mds_rank_t i = mds_rank_t(0); i< get_max_mds(); i++) { | |
358 | if (!is_up(i)) | |
359 | continue; | |
360 | mds_gid_t gid = up.find(i)->second; | |
9f95a23c | 361 | const auto& info = mds_info.at(gid); |
7c673cae FG |
362 | stringstream ss; |
363 | if (is_resolve(i)) | |
9f95a23c | 364 | ss << "mds." << info.name << " at " << info.addrs |
11fdf7f2 | 365 | << " rank " << i << " is resolving"; |
7c673cae | 366 | if (is_replay(i)) |
9f95a23c | 367 | ss << "mds." << info.name << " at " << info.addrs |
11fdf7f2 | 368 | << " rank " << i << " is replaying journal"; |
7c673cae | 369 | if (is_rejoin(i)) |
9f95a23c | 370 | ss << "mds." << info.name << " at " << info.addrs |
11fdf7f2 | 371 | << " rank " << i << " is rejoining"; |
7c673cae | 372 | if (is_reconnect(i)) |
9f95a23c | 373 | ss << "mds." << info.name << " at " << info.addrs |
11fdf7f2 | 374 | << " rank " << i << " is reconnecting to clients"; |
7c673cae FG |
375 | if (ss.str().length()) |
376 | detail->push_back(make_pair(HEALTH_WARN, ss.str())); | |
377 | } | |
378 | } | |
379 | } | |
380 | ||
11fdf7f2 TL |
381 | { |
382 | stringstream ss; | |
383 | ss << fs_name << " max_mds " << max_mds; | |
384 | summary.push_back(make_pair(HEALTH_WARN, ss.str())); | |
385 | } | |
386 | ||
387 | if ((mds_rank_t)up.size() < max_mds) { | |
388 | stringstream ss; | |
389 | ss << fs_name << " has " << up.size() | |
390 | << " active MDS(s), but has max_mds of " << max_mds; | |
391 | summary.push_back(make_pair(HEALTH_WARN, ss.str())); | |
392 | } | |
393 | ||
7c673cae FG |
394 | set<string> laggy; |
395 | for (const auto &u : up) { | |
9f95a23c TL |
396 | const auto& info = mds_info.at(u.second); |
397 | if (info.laggy()) { | |
398 | laggy.insert(info.name); | |
7c673cae FG |
399 | if (detail) { |
400 | std::ostringstream oss; | |
9f95a23c | 401 | oss << "mds." << info.name << " at " << info.addrs |
11fdf7f2 | 402 | << " is laggy/unresponsive"; |
7c673cae FG |
403 | detail->push_back(make_pair(HEALTH_WARN, oss.str())); |
404 | } | |
405 | } | |
406 | } | |
407 | ||
408 | if (!laggy.empty()) { | |
409 | std::ostringstream oss; | |
410 | oss << "mds " << laggy | |
411 | << ((laggy.size() > 1) ? " are":" is") | |
412 | << " laggy"; | |
413 | summary.push_back(make_pair(HEALTH_WARN, oss.str())); | |
414 | } | |
11fdf7f2 TL |
415 | |
416 | if (get_max_mds() > 1 && | |
417 | was_snaps_ever_allowed() && !allows_multimds_snaps()) { | |
418 | std::ostringstream oss; | |
419 | oss << "multi-active mds while there are snapshots possibly created by pre-mimic MDS"; | |
420 | summary.push_back(make_pair(HEALTH_WARN, oss.str())); | |
421 | } | |
7c673cae FG |
422 | } |
423 | ||
224ce89b WB |
424 | void MDSMap::get_health_checks(health_check_map_t *checks) const |
425 | { | |
d2e6a577 | 426 | // MDS_DAMAGE |
224ce89b | 427 | if (!damaged.empty()) { |
d2e6a577 | 428 | health_check_t& check = checks->get_or_add("MDS_DAMAGE", HEALTH_ERR, |
9f95a23c TL |
429 | "%num% mds daemon%plurals% damaged", |
430 | damaged.size()); | |
224ce89b WB |
431 | for (auto p : damaged) { |
432 | std::ostringstream oss; | |
433 | oss << "fs " << fs_name << " mds." << p << " is damaged"; | |
434 | check.detail.push_back(oss.str()); | |
435 | } | |
436 | } | |
437 | ||
438 | // FS_DEGRADED | |
224ce89b | 439 | if (is_degraded()) { |
d2e6a577 | 440 | health_check_t& fscheck = checks->get_or_add( |
224ce89b | 441 | "FS_DEGRADED", HEALTH_WARN, |
9f95a23c | 442 | "%num% filesystem%plurals% %isorare% degraded", 1); |
224ce89b WB |
443 | ostringstream ss; |
444 | ss << "fs " << fs_name << " is degraded"; | |
445 | fscheck.detail.push_back(ss.str()); | |
446 | ||
447 | list<string> detail; | |
448 | for (mds_rank_t i = mds_rank_t(0); i< get_max_mds(); i++) { | |
449 | if (!is_up(i)) | |
450 | continue; | |
451 | mds_gid_t gid = up.find(i)->second; | |
9f95a23c | 452 | const auto& info = mds_info.at(gid); |
224ce89b | 453 | stringstream ss; |
9f95a23c TL |
454 | ss << "fs " << fs_name << " mds." << info.name << " at " |
455 | << info.addrs << " rank " << i; | |
224ce89b WB |
456 | if (is_resolve(i)) |
457 | ss << " is resolving"; | |
458 | if (is_replay(i)) | |
459 | ss << " is replaying journal"; | |
460 | if (is_rejoin(i)) | |
461 | ss << " is rejoining"; | |
462 | if (is_reconnect(i)) | |
463 | ss << " is reconnecting to clients"; | |
464 | if (ss.str().length()) | |
465 | detail.push_back(ss.str()); | |
466 | } | |
224ce89b | 467 | } |
11fdf7f2 TL |
468 | |
469 | // MDS_UP_LESS_THAN_MAX | |
470 | if ((mds_rank_t)get_num_in_mds() < get_max_mds()) { | |
471 | health_check_t& check = checks->add( | |
472 | "MDS_UP_LESS_THAN_MAX", HEALTH_WARN, | |
9f95a23c | 473 | "%num% filesystem%plurals% %isorare% online with fewer MDS than max_mds", 1); |
11fdf7f2 TL |
474 | stringstream ss; |
475 | ss << "fs " << fs_name << " has " << get_num_in_mds() | |
476 | << " MDS online, but wants " << get_max_mds(); | |
477 | check.detail.push_back(ss.str()); | |
478 | } | |
479 | ||
480 | // MDS_ALL_DOWN | |
481 | if ((mds_rank_t)get_num_up_mds() == 0 && get_max_mds() > 0) { | |
482 | health_check_t &check = checks->add( | |
483 | "MDS_ALL_DOWN", HEALTH_ERR, | |
9f95a23c | 484 | "%num% filesystem%plurals% %isorare% offline", 1); |
11fdf7f2 TL |
485 | stringstream ss; |
486 | ss << "fs " << fs_name << " is offline because no MDS is active for it."; | |
487 | check.detail.push_back(ss.str()); | |
488 | } | |
489 | ||
490 | if (get_max_mds() > 1 && | |
491 | was_snaps_ever_allowed() && !allows_multimds_snaps()) { | |
492 | health_check_t &check = checks->add( | |
493 | "MULTIMDS_WITH_OLDSNAPS", HEALTH_ERR, | |
9f95a23c | 494 | "%num% filesystem%plurals% %isorare% multi-active mds with old snapshots", 1); |
11fdf7f2 TL |
495 | stringstream ss; |
496 | ss << "multi-active mds while there are snapshots possibly created by pre-mimic MDS"; | |
497 | check.detail.push_back(ss.str()); | |
498 | } | |
9f95a23c TL |
499 | |
500 | if (get_inline_data_enabled()) { | |
501 | health_check_t &check = checks->add( | |
502 | "FS_INLINE_DATA_DEPRECATED", HEALTH_WARN, | |
503 | "%num% filesystem%plurals% with deprecated feature inline_data", 1); | |
504 | stringstream ss; | |
505 | ss << "fs " << fs_name << " has deprecated feature inline_data enabled."; | |
506 | check.detail.push_back(ss.str()); | |
507 | } | |
224ce89b WB |
508 | } |
509 | ||
7c673cae FG |
510 | void MDSMap::mds_info_t::encode_versioned(bufferlist& bl, uint64_t features) const |
511 | { | |
11fdf7f2 TL |
512 | __u8 v = 9; |
513 | if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) { | |
514 | v = 7; | |
515 | } | |
516 | ENCODE_START(v, 4, bl); | |
517 | encode(global_id, bl); | |
518 | encode(name, bl); | |
519 | encode(rank, bl); | |
520 | encode(inc, bl); | |
521 | encode((int32_t)state, bl); | |
522 | encode(state_seq, bl); | |
523 | if (v < 8) { | |
524 | encode(addrs.legacy_addr(), bl, features); | |
525 | } else { | |
526 | encode(addrs, bl, features); | |
527 | } | |
528 | encode(laggy_since, bl); | |
529 | encode(MDS_RANK_NONE, bl); /* standby_for_rank */ | |
530 | encode(std::string(), bl); /* standby_for_name */ | |
531 | encode(export_targets, bl); | |
532 | encode(mds_features, bl); | |
9f95a23c | 533 | encode(join_fscid, bl); /* formerly: standby_for_fscid */ |
11fdf7f2 TL |
534 | encode(false, bl); |
535 | if (v >= 9) { | |
536 | encode(flags, bl); | |
537 | } | |
7c673cae FG |
538 | ENCODE_FINISH(bl); |
539 | } | |
540 | ||
541 | void MDSMap::mds_info_t::encode_unversioned(bufferlist& bl) const | |
542 | { | |
543 | __u8 struct_v = 3; | |
11fdf7f2 TL |
544 | using ceph::encode; |
545 | encode(struct_v, bl); | |
546 | encode(global_id, bl); | |
547 | encode(name, bl); | |
548 | encode(rank, bl); | |
549 | encode(inc, bl); | |
550 | encode((int32_t)state, bl); | |
551 | encode(state_seq, bl); | |
552 | encode(addrs.legacy_addr(), bl, 0); | |
553 | encode(laggy_since, bl); | |
554 | encode(MDS_RANK_NONE, bl); | |
555 | encode(std::string(), bl); | |
556 | encode(export_targets, bl); | |
7c673cae FG |
557 | } |
558 | ||
11fdf7f2 | 559 | void MDSMap::mds_info_t::decode(bufferlist::const_iterator& bl) |
7c673cae | 560 | { |
11fdf7f2 TL |
561 | DECODE_START_LEGACY_COMPAT_LEN(9, 4, 4, bl); |
562 | decode(global_id, bl); | |
563 | decode(name, bl); | |
564 | decode(rank, bl); | |
565 | decode(inc, bl); | |
566 | decode((int32_t&)(state), bl); | |
567 | decode(state_seq, bl); | |
568 | decode(addrs, bl); | |
569 | decode(laggy_since, bl); | |
570 | { | |
571 | mds_rank_t standby_for_rank; | |
572 | decode(standby_for_rank, bl); | |
573 | } | |
574 | { | |
575 | std::string standby_for_name; | |
576 | decode(standby_for_name, bl); | |
577 | } | |
7c673cae | 578 | if (struct_v >= 2) |
11fdf7f2 | 579 | decode(export_targets, bl); |
7c673cae | 580 | if (struct_v >= 5) |
11fdf7f2 | 581 | decode(mds_features, bl); |
7c673cae | 582 | if (struct_v >= 6) { |
9f95a23c | 583 | decode(join_fscid, bl); |
7c673cae FG |
584 | } |
585 | if (struct_v >= 7) { | |
11fdf7f2 TL |
586 | bool standby_replay; |
587 | decode(standby_replay, bl); | |
588 | } | |
589 | if (struct_v >= 9) { | |
590 | decode(flags, bl); | |
7c673cae FG |
591 | } |
592 | DECODE_FINISH(bl); | |
593 | } | |
594 | ||
d2e6a577 FG |
595 | std::string MDSMap::mds_info_t::human_name() const |
596 | { | |
597 | // Like "daemon mds.myhost restarted", "Activating daemon mds.myhost" | |
598 | std::ostringstream out; | |
599 | out << "daemon mds." << name; | |
600 | return out.str(); | |
601 | } | |
7c673cae FG |
602 | |
603 | void MDSMap::encode(bufferlist& bl, uint64_t features) const | |
604 | { | |
605 | std::map<mds_rank_t,int32_t> inc; // Legacy field, fake it so that | |
606 | // old-mon peers have something sane | |
607 | // during upgrade | |
608 | for (const auto rank : in) { | |
609 | inc.insert(std::make_pair(rank, epoch)); | |
610 | } | |
611 | ||
11fdf7f2 | 612 | using ceph::encode; |
7c673cae FG |
613 | if ((features & CEPH_FEATURE_PGID64) == 0) { |
614 | __u16 v = 2; | |
11fdf7f2 TL |
615 | encode(v, bl); |
616 | encode(epoch, bl); | |
617 | encode(flags, bl); | |
618 | encode(last_failure, bl); | |
619 | encode(root, bl); | |
620 | encode(session_timeout, bl); | |
621 | encode(session_autoclose, bl); | |
622 | encode(max_file_size, bl); | |
623 | encode(max_mds, bl); | |
7c673cae | 624 | __u32 n = mds_info.size(); |
11fdf7f2 | 625 | encode(n, bl); |
7c673cae FG |
626 | for (map<mds_gid_t, mds_info_t>::const_iterator i = mds_info.begin(); |
627 | i != mds_info.end(); ++i) { | |
11fdf7f2 TL |
628 | encode(i->first, bl); |
629 | encode(i->second, bl, features); | |
7c673cae FG |
630 | } |
631 | n = data_pools.size(); | |
11fdf7f2 | 632 | encode(n, bl); |
31f18b77 FG |
633 | for (const auto p: data_pools) { |
634 | n = p; | |
11fdf7f2 | 635 | encode(n, bl); |
7c673cae FG |
636 | } |
637 | ||
638 | int32_t m = cas_pool; | |
11fdf7f2 | 639 | encode(m, bl); |
7c673cae FG |
640 | return; |
641 | } else if ((features & CEPH_FEATURE_MDSENC) == 0) { | |
642 | __u16 v = 3; | |
11fdf7f2 TL |
643 | encode(v, bl); |
644 | encode(epoch, bl); | |
645 | encode(flags, bl); | |
646 | encode(last_failure, bl); | |
647 | encode(root, bl); | |
648 | encode(session_timeout, bl); | |
649 | encode(session_autoclose, bl); | |
650 | encode(max_file_size, bl); | |
651 | encode(max_mds, bl); | |
7c673cae | 652 | __u32 n = mds_info.size(); |
11fdf7f2 | 653 | encode(n, bl); |
7c673cae FG |
654 | for (map<mds_gid_t, mds_info_t>::const_iterator i = mds_info.begin(); |
655 | i != mds_info.end(); ++i) { | |
11fdf7f2 TL |
656 | encode(i->first, bl); |
657 | encode(i->second, bl, features); | |
7c673cae | 658 | } |
11fdf7f2 TL |
659 | encode(data_pools, bl); |
660 | encode(cas_pool, bl); | |
7c673cae | 661 | |
7c673cae | 662 | __u16 ev = 5; |
11fdf7f2 TL |
663 | encode(ev, bl); |
664 | encode(compat, bl); | |
665 | encode(metadata_pool, bl); | |
666 | encode(created, bl); | |
667 | encode(modified, bl); | |
668 | encode(tableserver, bl); | |
669 | encode(in, bl); | |
670 | encode(inc, bl); | |
671 | encode(up, bl); | |
672 | encode(failed, bl); | |
673 | encode(stopped, bl); | |
674 | encode(last_failure_osd_epoch, bl); | |
7c673cae FG |
675 | return; |
676 | } | |
677 | ||
678 | ENCODE_START(5, 4, bl); | |
11fdf7f2 TL |
679 | encode(epoch, bl); |
680 | encode(flags, bl); | |
681 | encode(last_failure, bl); | |
682 | encode(root, bl); | |
683 | encode(session_timeout, bl); | |
684 | encode(session_autoclose, bl); | |
685 | encode(max_file_size, bl); | |
686 | encode(max_mds, bl); | |
687 | encode(mds_info, bl, features); | |
688 | encode(data_pools, bl); | |
689 | encode(cas_pool, bl); | |
7c673cae | 690 | |
9f95a23c | 691 | __u16 ev = 15; |
11fdf7f2 TL |
692 | encode(ev, bl); |
693 | encode(compat, bl); | |
694 | encode(metadata_pool, bl); | |
695 | encode(created, bl); | |
696 | encode(modified, bl); | |
697 | encode(tableserver, bl); | |
698 | encode(in, bl); | |
699 | encode(inc, bl); | |
700 | encode(up, bl); | |
701 | encode(failed, bl); | |
702 | encode(stopped, bl); | |
703 | encode(last_failure_osd_epoch, bl); | |
704 | encode(ever_allowed_features, bl); | |
705 | encode(explicitly_allowed_features, bl); | |
706 | encode(inline_data_enabled, bl); | |
707 | encode(enabled, bl); | |
708 | encode(fs_name, bl); | |
709 | encode(damaged, bl); | |
710 | encode(balancer, bl); | |
711 | encode(standby_count_wanted, bl); | |
712 | encode(old_max_mds, bl); | |
713 | encode(min_compat_client, bl); | |
7c673cae FG |
714 | ENCODE_FINISH(bl); |
715 | } | |
716 | ||
11fdf7f2 | 717 | void MDSMap::sanitize(const std::function<bool(int64_t pool)>& pool_exists) |
3efd9988 FG |
718 | { |
719 | /* Before we did stricter checking, it was possible to remove a data pool | |
720 | * without also deleting it from the MDSMap. Check for that here after | |
721 | * decoding the data pools. | |
722 | */ | |
723 | ||
724 | for (auto it = data_pools.begin(); it != data_pools.end();) { | |
725 | if (!pool_exists(*it)) { | |
726 | dout(0) << "removed non-existant data pool " << *it << " from MDSMap" << dendl; | |
727 | it = data_pools.erase(it); | |
728 | } else { | |
729 | it++; | |
730 | } | |
731 | } | |
732 | } | |
733 | ||
11fdf7f2 | 734 | void MDSMap::decode(bufferlist::const_iterator& p) |
7c673cae FG |
735 | { |
736 | std::map<mds_rank_t,int32_t> inc; // Legacy field, parse and drop | |
737 | ||
738 | cached_up_features = 0; | |
739 | DECODE_START_LEGACY_COMPAT_LEN_16(5, 4, 4, p); | |
11fdf7f2 TL |
740 | decode(epoch, p); |
741 | decode(flags, p); | |
742 | decode(last_failure, p); | |
743 | decode(root, p); | |
744 | decode(session_timeout, p); | |
745 | decode(session_autoclose, p); | |
746 | decode(max_file_size, p); | |
747 | decode(max_mds, p); | |
748 | decode(mds_info, p); | |
7c673cae FG |
749 | if (struct_v < 3) { |
750 | __u32 n; | |
11fdf7f2 | 751 | decode(n, p); |
7c673cae FG |
752 | while (n--) { |
753 | __u32 m; | |
11fdf7f2 | 754 | decode(m, p); |
31f18b77 | 755 | data_pools.push_back(m); |
7c673cae FG |
756 | } |
757 | __s32 s; | |
11fdf7f2 | 758 | decode(s, p); |
7c673cae FG |
759 | cas_pool = s; |
760 | } else { | |
11fdf7f2 TL |
761 | decode(data_pools, p); |
762 | decode(cas_pool, p); | |
7c673cae FG |
763 | } |
764 | ||
765 | // kclient ignores everything from here | |
766 | __u16 ev = 1; | |
767 | if (struct_v >= 2) | |
11fdf7f2 | 768 | decode(ev, p); |
7c673cae | 769 | if (ev >= 3) |
11fdf7f2 | 770 | decode(compat, p); |
7c673cae | 771 | else |
1adf2230 | 772 | compat = get_compat_set_base(); |
7c673cae FG |
773 | if (ev < 5) { |
774 | __u32 n; | |
11fdf7f2 | 775 | decode(n, p); |
7c673cae FG |
776 | metadata_pool = n; |
777 | } else { | |
11fdf7f2 TL |
778 | decode(metadata_pool, p); |
779 | } | |
780 | decode(created, p); | |
781 | decode(modified, p); | |
782 | decode(tableserver, p); | |
783 | decode(in, p); | |
784 | decode(inc, p); | |
785 | decode(up, p); | |
786 | decode(failed, p); | |
787 | decode(stopped, p); | |
7c673cae | 788 | if (ev >= 4) |
11fdf7f2 | 789 | decode(last_failure_osd_epoch, p); |
7c673cae FG |
790 | if (ev >= 6) { |
791 | if (ev < 10) { | |
792 | // previously this was a bool about snaps, not a flag map | |
793 | bool flag; | |
11fdf7f2 | 794 | decode(flag, p); |
7c673cae | 795 | ever_allowed_features = flag ? CEPH_MDSMAP_ALLOW_SNAPS : 0; |
11fdf7f2 | 796 | decode(flag, p); |
7c673cae | 797 | explicitly_allowed_features = flag ? CEPH_MDSMAP_ALLOW_SNAPS : 0; |
7c673cae | 798 | } else { |
11fdf7f2 TL |
799 | decode(ever_allowed_features, p); |
800 | decode(explicitly_allowed_features, p); | |
7c673cae FG |
801 | } |
802 | } else { | |
11fdf7f2 | 803 | ever_allowed_features = 0; |
7c673cae | 804 | explicitly_allowed_features = 0; |
7c673cae FG |
805 | } |
806 | if (ev >= 7) | |
11fdf7f2 | 807 | decode(inline_data_enabled, p); |
7c673cae FG |
808 | |
809 | if (ev >= 8) { | |
11fdf7f2 TL |
810 | ceph_assert(struct_v >= 5); |
811 | decode(enabled, p); | |
812 | decode(fs_name, p); | |
7c673cae FG |
813 | } else { |
814 | if (epoch > 1) { | |
815 | // If an MDS has ever been started, epoch will be greater than 1, | |
816 | // assume filesystem is enabled. | |
817 | enabled = true; | |
818 | } else { | |
819 | // Upgrading from a cluster that never used an MDS, switch off | |
820 | // filesystem until it's explicitly enabled. | |
821 | enabled = false; | |
822 | } | |
823 | } | |
824 | ||
825 | if (ev >= 9) { | |
11fdf7f2 | 826 | decode(damaged, p); |
7c673cae FG |
827 | } |
828 | ||
829 | if (ev >= 11) { | |
11fdf7f2 | 830 | decode(balancer, p); |
7c673cae FG |
831 | } |
832 | ||
833 | if (ev >= 12) { | |
11fdf7f2 TL |
834 | decode(standby_count_wanted, p); |
835 | } | |
836 | ||
837 | if (ev >= 13) { | |
838 | decode(old_max_mds, p); | |
839 | } | |
840 | ||
9f95a23c TL |
841 | if (ev == 14) { |
842 | int8_t r; | |
843 | decode(r, p); | |
844 | if (r < 0) { | |
845 | min_compat_client = ceph_release_t::unknown; | |
846 | } else { | |
847 | min_compat_client = ceph_release_t{static_cast<uint8_t>(r)}; | |
848 | } | |
849 | } else if (ev > 14) { | |
11fdf7f2 | 850 | decode(min_compat_client, p); |
7c673cae FG |
851 | } |
852 | ||
853 | DECODE_FINISH(p); | |
854 | } | |
855 | ||
856 | MDSMap::availability_t MDSMap::is_cluster_available() const | |
857 | { | |
858 | if (epoch == 0) { | |
859 | // If I'm a client, this means I'm looking at an MDSMap instance | |
860 | // that was never actually initialized from the mons. Client should | |
861 | // wait. | |
862 | return TRANSIENT_UNAVAILABLE; | |
863 | } | |
864 | ||
865 | // If a rank is marked damage (unavailable until operator intervenes) | |
866 | if (damaged.size()) { | |
867 | return STUCK_UNAVAILABLE; | |
868 | } | |
869 | ||
870 | // If no ranks are created (filesystem not initialized) | |
871 | if (in.empty()) { | |
872 | return STUCK_UNAVAILABLE; | |
873 | } | |
874 | ||
875 | for (const auto rank : in) { | |
876 | if (up.count(rank) && mds_info.at(up.at(rank)).laggy()) { | |
877 | // This might only be transient, but because we can't see | |
878 | // standbys, we have no way of knowing whether there is a | |
879 | // standby available to replace the laggy guy. | |
880 | return STUCK_UNAVAILABLE; | |
881 | } | |
882 | } | |
883 | ||
884 | if (get_num_mds(CEPH_MDS_STATE_ACTIVE) > 0) { | |
885 | // Nobody looks stuck, so indicate to client they should go ahead | |
886 | // and try mounting if anybody is active. This may include e.g. | |
887 | // one MDS failing over and another active: the client should | |
888 | // proceed to start talking to the active one and let the | |
889 | // transiently-unavailable guy catch up later. | |
890 | return AVAILABLE; | |
891 | } else { | |
892 | // Nothing indicating we were stuck, but nobody active (yet) | |
893 | //return TRANSIENT_UNAVAILABLE; | |
894 | ||
895 | // Because we don't have standbys in the MDSMap any more, we can't | |
896 | // reliably indicate transient vs. stuck, so always say stuck so | |
897 | // that the client doesn't block. | |
898 | return STUCK_UNAVAILABLE; | |
899 | } | |
900 | } | |
901 | ||
902 | bool MDSMap::state_transition_valid(DaemonState prev, DaemonState next) | |
903 | { | |
904 | bool state_valid = true; | |
905 | if (next != prev) { | |
906 | if (prev == MDSMap::STATE_REPLAY) { | |
907 | if (next != MDSMap::STATE_RESOLVE && next != MDSMap::STATE_RECONNECT) { | |
908 | state_valid = false; | |
909 | } | |
910 | } else if (prev == MDSMap::STATE_REJOIN) { | |
1adf2230 AA |
911 | if (next != MDSMap::STATE_ACTIVE && |
912 | next != MDSMap::STATE_CLIENTREPLAY && | |
913 | next != MDSMap::STATE_STOPPED) { | |
7c673cae FG |
914 | state_valid = false; |
915 | } | |
1adf2230 | 916 | } else if (prev >= MDSMap::STATE_RESOLVE && prev < MDSMap::STATE_ACTIVE) { |
7c673cae FG |
917 | // Once I have entered replay, the only allowable transitions are to |
918 | // the next next along in the sequence. | |
919 | if (next != prev + 1) { | |
920 | state_valid = false; | |
921 | } | |
922 | } | |
923 | } | |
924 | ||
925 | return state_valid; | |
926 | } | |
927 | ||
928 | bool MDSMap::check_health(mds_rank_t standby_daemon_count) | |
929 | { | |
930 | std::set<mds_rank_t> standbys; | |
931 | get_standby_replay_mds_set(standbys); | |
932 | std::set<mds_rank_t> actives; | |
933 | get_active_mds_set(actives); | |
934 | mds_rank_t standbys_avail = (mds_rank_t)standbys.size()+standby_daemon_count; | |
935 | ||
936 | /* If there are standby daemons available/replaying and | |
937 | * standby_count_wanted is unset (default), then we set it to 1. This will | |
938 | * happen during health checks by the mons. Also, during initial creation | |
939 | * of the FS we will have no actives so we don't want to change the default | |
940 | * yet. | |
941 | */ | |
942 | if (standby_count_wanted == -1 && actives.size() > 0 && standbys_avail > 0) { | |
943 | set_standby_count_wanted(1); | |
944 | return true; | |
945 | } | |
946 | return false; | |
947 | } | |
9f95a23c TL |
948 | |
949 | mds_gid_t MDSMap::find_mds_gid_by_name(std::string_view s) const { | |
950 | for (const auto& [gid, info] : mds_info) { | |
951 | if (info.name == s) { | |
952 | return gid; | |
953 | } | |
954 | } | |
955 | return MDS_GID_NONE; | |
956 | } | |
957 | ||
958 | unsigned MDSMap::get_num_mds(int state) const { | |
959 | unsigned n = 0; | |
960 | for (std::map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin(); | |
961 | p != mds_info.end(); | |
962 | ++p) | |
963 | if (p->second.state == state) ++n; | |
964 | return n; | |
965 | } | |
966 | ||
967 | void MDSMap::get_up_mds_set(std::set<mds_rank_t>& s) const { | |
968 | for (std::map<mds_rank_t, mds_gid_t>::const_iterator p = up.begin(); | |
969 | p != up.end(); | |
970 | ++p) | |
971 | s.insert(p->first); | |
972 | } | |
973 | ||
974 | uint64_t MDSMap::get_up_features() { | |
975 | if (!cached_up_features) { | |
976 | bool first = true; | |
977 | for (std::map<mds_rank_t, mds_gid_t>::const_iterator p = up.begin(); | |
978 | p != up.end(); | |
979 | ++p) { | |
980 | std::map<mds_gid_t, mds_info_t>::const_iterator q = | |
981 | mds_info.find(p->second); | |
982 | ceph_assert(q != mds_info.end()); | |
983 | if (first) { | |
984 | cached_up_features = q->second.mds_features; | |
985 | first = false; | |
986 | } else { | |
987 | cached_up_features &= q->second.mds_features; | |
988 | } | |
989 | } | |
990 | } | |
991 | return cached_up_features; | |
992 | } | |
993 | ||
994 | void MDSMap::get_recovery_mds_set(std::set<mds_rank_t>& s) const { | |
995 | s = failed; | |
996 | for (const auto& p : damaged) | |
997 | s.insert(p); | |
998 | for (const auto& p : mds_info) | |
999 | if (p.second.state >= STATE_REPLAY && p.second.state <= STATE_STOPPING) | |
1000 | s.insert(p.second.rank); | |
1001 | } | |
1002 | ||
1003 | void MDSMap::get_mds_set_lower_bound(std::set<mds_rank_t>& s, DaemonState first) const { | |
1004 | for (std::map<mds_gid_t, mds_info_t>::const_iterator p = mds_info.begin(); | |
1005 | p != mds_info.end(); | |
1006 | ++p) | |
1007 | if (p->second.state >= first && p->second.state <= STATE_STOPPING) | |
1008 | s.insert(p->second.rank); | |
1009 | } | |
1010 | ||
1011 | void MDSMap::get_mds_set(std::set<mds_rank_t>& s, DaemonState state) const { | |
1012 | for (std::map<mds_gid_t, mds_info_t>::const_iterator p = mds_info.begin(); | |
1013 | p != mds_info.end(); | |
1014 | ++p) | |
1015 | if (p->second.state == state) | |
1016 | s.insert(p->second.rank); | |
1017 | } | |
1018 | ||
1019 | mds_gid_t MDSMap::get_standby_replay(mds_rank_t r) const { | |
1020 | for (auto& [gid,info] : mds_info) { | |
1021 | if (info.rank == r && info.state == STATE_STANDBY_REPLAY) { | |
1022 | return gid; | |
1023 | } | |
1024 | } | |
1025 | return MDS_GID_NONE; | |
1026 | } | |
1027 | ||
1028 | bool MDSMap::is_degraded() const { | |
1029 | if (!failed.empty() || !damaged.empty()) | |
1030 | return true; | |
1031 | for (const auto& p : mds_info) { | |
1032 | if (p.second.is_degraded()) | |
1033 | return true; | |
1034 | } | |
1035 | return false; | |
1036 | } |