blob: 30387733765d51f0aa02fd0f61a06b347c52a019 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -07002#include <linux/ceph/ceph_debug.h>
Sage Weil2f2dc052009-10-06 11:31:09 -07003
4#include <linux/bug.h>
5#include <linux/err.h>
6#include <linux/random.h>
7#include <linux/slab.h>
8#include <linux/types.h>
9
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -070010#include <linux/ceph/mdsmap.h>
11#include <linux/ceph/messenger.h>
12#include <linux/ceph/decode.h>
Sage Weil2f2dc052009-10-06 11:31:09 -070013
14#include "super.h"
15
Xiubo Li5d476482019-11-26 07:24:22 -050016#define CEPH_MDS_IS_READY(i, ignore_laggy) \
Xiubo Lib38c9eb2019-12-04 06:57:39 -050017 (m->m_info[i].state > 0 && ignore_laggy ? true : !m->m_info[i].laggy)
Sage Weil2f2dc052009-10-06 11:31:09 -070018
Xiubo Li5d476482019-11-26 07:24:22 -050019static int __mdsmap_get_random_mds(struct ceph_mdsmap *m, bool ignore_laggy)
Sage Weil2f2dc052009-10-06 11:31:09 -070020{
21 int n = 0;
Xiubo Li74d6f032019-11-11 06:51:05 -050022 int i, j;
Sam Langa84cd292013-04-09 16:49:11 -050023
Sage Weil2f2dc052009-10-06 11:31:09 -070024 /* count */
Xiubo Lib38c9eb2019-12-04 06:57:39 -050025 for (i = 0; i < m->possible_max_rank; i++)
Xiubo Li5d476482019-11-26 07:24:22 -050026 if (CEPH_MDS_IS_READY(i, ignore_laggy))
Sage Weil2f2dc052009-10-06 11:31:09 -070027 n++;
28 if (n == 0)
29 return -1;
30
31 /* pick */
Sam Langa84cd292013-04-09 16:49:11 -050032 n = prandom_u32() % n;
Xiubo Lib38c9eb2019-12-04 06:57:39 -050033 for (j = 0, i = 0; i < m->possible_max_rank; i++) {
Xiubo Li5d476482019-11-26 07:24:22 -050034 if (CEPH_MDS_IS_READY(i, ignore_laggy))
Xiubo Li74d6f032019-11-11 06:51:05 -050035 j++;
36 if (j > n)
37 break;
38 }
Sage Weil2f2dc052009-10-06 11:31:09 -070039
40 return i;
41}
42
Xiubo Li5d476482019-11-26 07:24:22 -050043/*
44 * choose a random mds that is "up" (i.e. has a state > 0), or -1.
45 */
46int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
47{
48 int mds;
49
50 mds = __mdsmap_get_random_mds(m, false);
Xiubo Lib38c9eb2019-12-04 06:57:39 -050051 if (mds == m->possible_max_rank || mds == -1)
Xiubo Li5d476482019-11-26 07:24:22 -050052 mds = __mdsmap_get_random_mds(m, true);
53
Xiubo Lib38c9eb2019-12-04 06:57:39 -050054 return mds == m->possible_max_rank ? -1 : mds;
Xiubo Li5d476482019-11-26 07:24:22 -050055}
56
Yan, Zhenge9e427f2016-11-10 16:02:06 +080057#define __decode_and_drop_type(p, end, type, bad) \
58 do { \
59 if (*p + sizeof(type) > end) \
60 goto bad; \
61 *p += sizeof(type); \
62 } while (0)
63
64#define __decode_and_drop_set(p, end, type, bad) \
65 do { \
66 u32 n; \
67 size_t need; \
68 ceph_decode_32_safe(p, end, n, bad); \
69 need = sizeof(type) * n; \
70 ceph_decode_need(p, end, need, bad); \
71 *p += need; \
72 } while (0)
73
74#define __decode_and_drop_map(p, end, ktype, vtype, bad) \
75 do { \
76 u32 n; \
77 size_t need; \
78 ceph_decode_32_safe(p, end, n, bad); \
79 need = (sizeof(ktype) + sizeof(vtype)) * n; \
80 ceph_decode_need(p, end, need, bad); \
81 *p += need; \
82 } while (0)
83
84
85static int __decode_and_drop_compat_set(void **p, void* end)
86{
87 int i;
88 /* compat, ro_compat, incompat*/
89 for (i = 0; i < 3; i++) {
90 u32 n;
91 ceph_decode_need(p, end, sizeof(u64) + sizeof(u32), bad);
92 /* mask */
93 *p += sizeof(u64);
94 /* names (map<u64, string>) */
95 n = ceph_decode_32(p);
96 while (n-- > 0) {
97 u32 len;
98 ceph_decode_need(p, end, sizeof(u64) + sizeof(u32),
99 bad);
100 *p += sizeof(u64);
101 len = ceph_decode_32(p);
102 ceph_decode_need(p, end, len, bad);
103 *p += len;
104 }
105 }
106 return 0;
107bad:
108 return -1;
109}
110
Sage Weil2f2dc052009-10-06 11:31:09 -0700111/*
112 * Decode an MDS map
113 *
114 * Ignore any fields we don't care about (there are quite a few of
115 * them).
116 */
Ilya Dryomova5cbd5f2020-10-30 13:30:51 +0100117struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2)
Sage Weil2f2dc052009-10-06 11:31:09 -0700118{
119 struct ceph_mdsmap *m;
Sage Weil9ec7cab2009-12-14 15:13:47 -0800120 const void *start = *p;
Sage Weil2f2dc052009-10-06 11:31:09 -0700121 int i, j, n;
Jeff Laytonf3848af2019-06-04 11:26:36 -0400122 int err;
Jia Yang8e298de2020-07-23 10:25:52 +0800123 u8 mdsmap_v;
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800124 u16 mdsmap_ev;
Xiubo Lid517b392021-08-18 09:31:19 +0800125 u32 target;
Sage Weil2f2dc052009-10-06 11:31:09 -0700126
127 m = kzalloc(sizeof(*m), GFP_NOFS);
Markus Elfringd37b1d92017-08-20 20:22:02 +0200128 if (!m)
Sage Weil2f2dc052009-10-06 11:31:09 -0700129 return ERR_PTR(-ENOMEM);
130
Yan, Zhengd463a432016-03-31 15:53:01 +0800131 ceph_decode_need(p, end, 1 + 1, bad);
132 mdsmap_v = ceph_decode_8(p);
Jia Yang8e298de2020-07-23 10:25:52 +0800133 *p += sizeof(u8); /* mdsmap_cv */
Yan, Zhengd463a432016-03-31 15:53:01 +0800134 if (mdsmap_v >= 4) {
135 u32 mdsmap_len;
136 ceph_decode_32_safe(p, end, mdsmap_len, bad);
137 if (end < *p + mdsmap_len)
138 goto bad;
139 end = *p + mdsmap_len;
Sage Weil4f6a7e52013-02-23 10:41:09 -0800140 }
Sage Weil2f2dc052009-10-06 11:31:09 -0700141
142 ceph_decode_need(p, end, 8*sizeof(u32) + sizeof(u64), bad);
Sage Weilc89136e2009-10-14 09:59:09 -0700143 m->m_epoch = ceph_decode_32(p);
144 m->m_client_epoch = ceph_decode_32(p);
145 m->m_last_failure = ceph_decode_32(p);
146 m->m_root = ceph_decode_32(p);
147 m->m_session_timeout = ceph_decode_32(p);
148 m->m_session_autoclose = ceph_decode_32(p);
149 m->m_max_file_size = ceph_decode_64(p);
150 m->m_max_mds = ceph_decode_32(p);
Xiubo Li4d7ace02019-11-26 07:24:21 -0500151
152 /*
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500153 * pick out the active nodes as the m_num_active_mds, the
154 * m_num_active_mds maybe larger than m_max_mds when decreasing
155 * the max_mds in cluster side, in other case it should less
156 * than or equal to m_max_mds.
Xiubo Li4d7ace02019-11-26 07:24:21 -0500157 */
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500158 m->m_num_active_mds = n = ceph_decode_32(p);
Xiubo Li4d7ace02019-11-26 07:24:21 -0500159
160 /*
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500161 * the possible max rank, it maybe larger than the m_num_active_mds,
Xiubo Li4d7ace02019-11-26 07:24:21 -0500162 * for example if the mds_max == 2 in the cluster, when the MDS(0)
163 * was laggy and being replaced by a new MDS, we will temporarily
164 * receive a new mds map with n_num_mds == 1 and the active MDS(1),
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500165 * and the mds rank >= m_num_active_mds.
Xiubo Li4d7ace02019-11-26 07:24:21 -0500166 */
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500167 m->possible_max_rank = max(m->m_num_active_mds, m->m_max_mds);
Sage Weil2f2dc052009-10-06 11:31:09 -0700168
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500169 m->m_info = kcalloc(m->possible_max_rank, sizeof(*m->m_info), GFP_NOFS);
Markus Elfringd37b1d92017-08-20 20:22:02 +0200170 if (!m->m_info)
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800171 goto nomem;
Sage Weil2f2dc052009-10-06 11:31:09 -0700172
173 /* pick out active nodes from mds_info (state > 0) */
Sage Weil2f2dc052009-10-06 11:31:09 -0700174 for (i = 0; i < n; i++) {
Sage Weil94045e12009-11-19 15:31:50 -0800175 u64 global_id;
Sage Weil2f2dc052009-10-06 11:31:09 -0700176 u32 namelen;
177 s32 mds, inc, state;
Yan, Zhengd463a432016-03-31 15:53:01 +0800178 u8 info_v;
179 void *info_end = NULL;
Sage Weil2f2dc052009-10-06 11:31:09 -0700180 struct ceph_entity_addr addr;
181 u32 num_export_targets;
182 void *pexport_targets = NULL;
Sage Weil0deb01c2010-06-17 14:19:01 -0700183 struct ceph_timespec laggy_since;
Dan Carpenter6af86522013-05-29 06:46:56 -0500184 struct ceph_mds_info *info;
Xiubo Lida08e1e2019-11-26 07:24:20 -0500185 bool laggy;
Sage Weil2f2dc052009-10-06 11:31:09 -0700186
Yan, Zhengd463a432016-03-31 15:53:01 +0800187 ceph_decode_need(p, end, sizeof(u64) + 1, bad);
Sage Weil94045e12009-11-19 15:31:50 -0800188 global_id = ceph_decode_64(p);
Yan, Zhengd463a432016-03-31 15:53:01 +0800189 info_v= ceph_decode_8(p);
190 if (info_v >= 4) {
191 u32 info_len;
Yan, Zhengd463a432016-03-31 15:53:01 +0800192 ceph_decode_need(p, end, 1 + sizeof(u32), bad);
Jia Yang8e298de2020-07-23 10:25:52 +0800193 *p += sizeof(u8); /* info_cv */
Yan, Zhengd463a432016-03-31 15:53:01 +0800194 info_len = ceph_decode_32(p);
195 info_end = *p + info_len;
196 if (info_end > end)
197 goto bad;
198 }
199
200 ceph_decode_need(p, end, sizeof(u64) + sizeof(u32), bad);
Sage Weil94045e12009-11-19 15:31:50 -0800201 *p += sizeof(u64);
Sage Weilc89136e2009-10-14 09:59:09 -0700202 namelen = ceph_decode_32(p); /* skip mds name */
Sage Weil2f2dc052009-10-06 11:31:09 -0700203 *p += namelen;
204
Ilya Dryomova5cbd5f2020-10-30 13:30:51 +0100205 ceph_decode_32_safe(p, end, mds, bad);
206 ceph_decode_32_safe(p, end, inc, bad);
207 ceph_decode_32_safe(p, end, state, bad);
Jia Yang8e298de2020-07-23 10:25:52 +0800208 *p += sizeof(u64); /* state_seq */
Ilya Dryomova5cbd5f2020-10-30 13:30:51 +0100209 if (info_v >= 8)
210 err = ceph_decode_entity_addrvec(p, end, msgr2, &addr);
211 else
212 err = ceph_decode_entity_addr(p, end, &addr);
Jeff Laytonf3848af2019-06-04 11:26:36 -0400213 if (err)
214 goto corrupt;
Ilya Dryomova5cbd5f2020-10-30 13:30:51 +0100215
216 ceph_decode_copy_safe(p, end, &laggy_since, sizeof(laggy_since),
217 bad);
Xiubo Lida08e1e2019-11-26 07:24:20 -0500218 laggy = laggy_since.tv_sec != 0 || laggy_since.tv_nsec != 0;
Sage Weil2f2dc052009-10-06 11:31:09 -0700219 *p += sizeof(u32);
220 ceph_decode_32_safe(p, end, namelen, bad);
Sage Weile251e282009-10-07 16:38:19 -0700221 *p += namelen;
Yan, Zhengd463a432016-03-31 15:53:01 +0800222 if (info_v >= 2) {
Sage Weil2f2dc052009-10-06 11:31:09 -0700223 ceph_decode_32_safe(p, end, num_export_targets, bad);
224 pexport_targets = *p;
Sage Weile251e282009-10-07 16:38:19 -0700225 *p += num_export_targets * sizeof(u32);
Sage Weil2f2dc052009-10-06 11:31:09 -0700226 } else {
227 num_export_targets = 0;
228 }
229
Yan, Zhengd463a432016-03-31 15:53:01 +0800230 if (info_end && *p != info_end) {
231 if (*p > info_end)
232 goto bad;
233 *p = info_end;
234 }
235
Xiubo Lida08e1e2019-11-26 07:24:20 -0500236 dout("mdsmap_decode %d/%d %lld mds%d.%d %s %s%s\n",
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700237 i+1, n, global_id, mds, inc,
Jeff Laytonb726ec92019-05-06 09:38:47 -0400238 ceph_pr_addr(&addr),
Xiubo Lida08e1e2019-11-26 07:24:20 -0500239 ceph_mds_state_name(state),
240 laggy ? "(laggy)" : "");
Dan Carpenter6af86522013-05-29 06:46:56 -0500241
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500242 if (mds < 0 || mds >= m->possible_max_rank) {
Xiubo Li4d7ace02019-11-26 07:24:21 -0500243 pr_warn("mdsmap_decode got incorrect mds(%d)\n", mds);
Dan Carpenter6af86522013-05-29 06:46:56 -0500244 continue;
Xiubo Li4d7ace02019-11-26 07:24:21 -0500245 }
Dan Carpenter6af86522013-05-29 06:46:56 -0500246
Xiubo Li4d7ace02019-11-26 07:24:21 -0500247 if (state <= 0) {
Luis Henriquesccd1acd2020-11-12 11:25:32 +0000248 dout("mdsmap_decode got incorrect state(%s)\n",
249 ceph_mds_state_name(state));
Xiubo Li4d7ace02019-11-26 07:24:21 -0500250 continue;
Yan, Zheng76201b62017-03-28 17:04:13 +0800251 }
252
Dan Carpenter6af86522013-05-29 06:46:56 -0500253 info = &m->m_info[mds];
254 info->global_id = global_id;
255 info->state = state;
256 info->addr = addr;
Xiubo Lida08e1e2019-11-26 07:24:20 -0500257 info->laggy = laggy;
Dan Carpenter6af86522013-05-29 06:46:56 -0500258 info->num_export_targets = num_export_targets;
259 if (num_export_targets) {
260 info->export_targets = kcalloc(num_export_targets,
261 sizeof(u32), GFP_NOFS);
Markus Elfringd37b1d92017-08-20 20:22:02 +0200262 if (!info->export_targets)
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800263 goto nomem;
Xiubo Lid517b392021-08-18 09:31:19 +0800264 for (j = 0; j < num_export_targets; j++) {
265 target = ceph_decode_32(&pexport_targets);
Xiubo Lid517b392021-08-18 09:31:19 +0800266 info->export_targets[j] = target;
267 }
Dan Carpenter6af86522013-05-29 06:46:56 -0500268 } else {
269 info->export_targets = NULL;
Sage Weil2f2dc052009-10-06 11:31:09 -0700270 }
271 }
272
273 /* pg_pools */
274 ceph_decode_32_safe(p, end, n, bad);
275 m->m_num_data_pg_pools = n;
Sage Weil4f6a7e52013-02-23 10:41:09 -0800276 m->m_data_pg_pools = kcalloc(n, sizeof(u64), GFP_NOFS);
Sage Weil2f2dc052009-10-06 11:31:09 -0700277 if (!m->m_data_pg_pools)
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800278 goto nomem;
Sage Weil4f6a7e52013-02-23 10:41:09 -0800279 ceph_decode_need(p, end, sizeof(u64)*(n+1), bad);
Sage Weil2f2dc052009-10-06 11:31:09 -0700280 for (i = 0; i < n; i++)
Sage Weil4f6a7e52013-02-23 10:41:09 -0800281 m->m_data_pg_pools[i] = ceph_decode_64(p);
282 m->m_cas_pg_pool = ceph_decode_64(p);
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800283 m->m_enabled = m->m_epoch > 1;
Sage Weil2f2dc052009-10-06 11:31:09 -0700284
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800285 mdsmap_ev = 1;
286 if (mdsmap_v >= 2) {
287 ceph_decode_16_safe(p, end, mdsmap_ev, bad_ext);
288 }
289 if (mdsmap_ev >= 3) {
290 if (__decode_and_drop_compat_set(p, end) < 0)
291 goto bad_ext;
292 }
293 /* metadata_pool */
294 if (mdsmap_ev < 5) {
295 __decode_and_drop_type(p, end, u32, bad_ext);
296 } else {
297 __decode_and_drop_type(p, end, u64, bad_ext);
298 }
299
300 /* created + modified + tableserver */
301 __decode_and_drop_type(p, end, struct ceph_timespec, bad_ext);
302 __decode_and_drop_type(p, end, struct ceph_timespec, bad_ext);
303 __decode_and_drop_type(p, end, u32, bad_ext);
304
305 /* in */
306 {
307 int num_laggy = 0;
308 ceph_decode_32_safe(p, end, n, bad_ext);
309 ceph_decode_need(p, end, sizeof(u32) * n, bad_ext);
310
311 for (i = 0; i < n; i++) {
312 s32 mds = ceph_decode_32(p);
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500313 if (mds >= 0 && mds < m->possible_max_rank) {
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800314 if (m->m_info[mds].laggy)
315 num_laggy++;
316 }
317 }
318 m->m_num_laggy = num_laggy;
Yan, Zheng76201b62017-03-28 17:04:13 +0800319
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500320 if (n > m->possible_max_rank) {
Yan, Zheng76201b62017-03-28 17:04:13 +0800321 void *new_m_info = krealloc(m->m_info,
322 n * sizeof(*m->m_info),
323 GFP_NOFS | __GFP_ZERO);
324 if (!new_m_info)
325 goto nomem;
326 m->m_info = new_m_info;
327 }
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500328 m->possible_max_rank = n;
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800329 }
330
331 /* inc */
332 __decode_and_drop_map(p, end, u32, u32, bad_ext);
333 /* up */
334 __decode_and_drop_map(p, end, u32, u64, bad_ext);
335 /* failed */
336 __decode_and_drop_set(p, end, u32, bad_ext);
337 /* stopped */
338 __decode_and_drop_set(p, end, u32, bad_ext);
339
340 if (mdsmap_ev >= 4) {
341 /* last_failure_osd_epoch */
342 __decode_and_drop_type(p, end, u32, bad_ext);
343 }
344 if (mdsmap_ev >= 6) {
345 /* ever_allowed_snaps */
346 __decode_and_drop_type(p, end, u8, bad_ext);
347 /* explicitly_allowed_snaps */
348 __decode_and_drop_type(p, end, u8, bad_ext);
349 }
350 if (mdsmap_ev >= 7) {
351 /* inline_data_enabled */
352 __decode_and_drop_type(p, end, u8, bad_ext);
353 }
354 if (mdsmap_ev >= 8) {
355 u32 name_len;
356 /* enabled */
357 ceph_decode_8_safe(p, end, m->m_enabled, bad_ext);
358 ceph_decode_32_safe(p, end, name_len, bad_ext);
359 ceph_decode_need(p, end, name_len, bad_ext);
360 *p += name_len;
361 }
362 /* damaged */
363 if (mdsmap_ev >= 9) {
364 size_t need;
365 ceph_decode_32_safe(p, end, n, bad_ext);
366 need = sizeof(u32) * n;
367 ceph_decode_need(p, end, need, bad_ext);
368 *p += need;
369 m->m_damaged = n > 0;
370 } else {
371 m->m_damaged = false;
372 }
373bad_ext:
Xiubo Lida08e1e2019-11-26 07:24:20 -0500374 dout("mdsmap_decode m_enabled: %d, m_damaged: %d, m_num_laggy: %d\n",
375 !!m->m_enabled, !!m->m_damaged, m->m_num_laggy);
Yan, Zhengd463a432016-03-31 15:53:01 +0800376 *p = end;
Sage Weil2f2dc052009-10-06 11:31:09 -0700377 dout("mdsmap_decode success epoch %u\n", m->m_epoch);
378 return m;
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800379nomem:
Sage Weil2f2dc052009-10-06 11:31:09 -0700380 err = -ENOMEM;
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800381 goto out_err;
Jeff Laytonf3848af2019-06-04 11:26:36 -0400382corrupt:
Sage Weil2f2dc052009-10-06 11:31:09 -0700383 pr_err("corrupt mdsmap\n");
Sage Weil9ec7cab2009-12-14 15:13:47 -0800384 print_hex_dump(KERN_DEBUG, "mdsmap: ",
385 DUMP_PREFIX_OFFSET, 16, 1,
386 start, end - start, true);
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800387out_err:
Sage Weil2f2dc052009-10-06 11:31:09 -0700388 ceph_mdsmap_destroy(m);
Emil Goodec213b502013-05-28 16:59:00 +0200389 return ERR_PTR(err);
Jeff Laytonf3848af2019-06-04 11:26:36 -0400390bad:
391 err = -EINVAL;
392 goto corrupt;
Sage Weil2f2dc052009-10-06 11:31:09 -0700393}
394
395void ceph_mdsmap_destroy(struct ceph_mdsmap *m)
396{
397 int i;
398
Tuo Lia9e6ffb2021-08-05 08:14:34 -0700399 if (m->m_info) {
400 for (i = 0; i < m->possible_max_rank; i++)
401 kfree(m->m_info[i].export_targets);
402 kfree(m->m_info);
403 }
Sage Weil2f2dc052009-10-06 11:31:09 -0700404 kfree(m->m_data_pg_pools);
405 kfree(m);
406}
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800407
408bool ceph_mdsmap_is_cluster_available(struct ceph_mdsmap *m)
409{
410 int i, nr_active = 0;
411 if (!m->m_enabled)
412 return false;
413 if (m->m_damaged)
414 return false;
Xiubo Li4d7ace02019-11-26 07:24:21 -0500415 if (m->m_num_laggy == m->m_num_active_mds)
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800416 return false;
Xiubo Lib38c9eb2019-12-04 06:57:39 -0500417 for (i = 0; i < m->possible_max_rank; i++) {
Yan, Zhenge9e427f2016-11-10 16:02:06 +0800418 if (m->m_info[i].state == CEPH_MDS_STATE_ACTIVE)
419 nr_active++;
420 }
421 return nr_active > 0;
422}