1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _FS_CEPH_MDSMAP_H
3 #define _FS_CEPH_MDSMAP_H
4
5 #include <linux/bug.h>
6 #include <linux/ceph/types.h>
7
8 /*
9 * mds map - describe servers in the mds cluster.
10 *
11 * we limit fields to those the client actually xcares about
12 */
13 struct ceph_mds_info {
14 u64 global_id;
15 struct ceph_entity_addr addr;
16 s32 state;
17 int num_export_targets;
18 bool laggy;
19 u32 *export_targets;
20 };
21
22 struct ceph_mdsmap {
23 u32 m_epoch, m_client_epoch, m_last_failure;
24 u32 m_root;
25 u32 m_session_timeout; /* seconds */
26 u32 m_session_autoclose; /* seconds */
27 u64 m_max_file_size;
28 /*
29 * maximum size for xattrs blob.
30 * Zeroed by default to force the usage of the (sync) SETXATTR Op.
31 */
32 u64 m_max_xattr_size;
33 u32 m_max_mds; /* expected up:active mds number */
34 u32 m_num_active_mds; /* actual up:active mds number */
35 u32 possible_max_rank; /* possible max rank index */
36 struct ceph_mds_info *m_info;
37
38 /* which object pools file data can be stored in */
39 int m_num_data_pg_pools;
40 u64 *m_data_pg_pools;
41 u64 m_cas_pg_pool;
42
43 bool m_enabled;
44 bool m_damaged;
45 int m_num_laggy;
46 };
47
48 static inline struct ceph_entity_addr *
ceph_mdsmap_get_addr(struct ceph_mdsmap * m,int w)49 ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w)
50 {
51 if (w >= m->possible_max_rank)
52 return NULL;
53 return &m->m_info[w].addr;
54 }
55
ceph_mdsmap_get_state(struct ceph_mdsmap * m,int w)56 static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w)
57 {
58 BUG_ON(w < 0);
59 if (w >= m->possible_max_rank)
60 return CEPH_MDS_STATE_DNE;
61 return m->m_info[w].state;
62 }
63
ceph_mdsmap_is_laggy(struct ceph_mdsmap * m,int w)64 static inline bool ceph_mdsmap_is_laggy(struct ceph_mdsmap *m, int w)
65 {
66 if (w >= 0 && w < m->possible_max_rank)
67 return m->m_info[w].laggy;
68 return false;
69 }
70
71 extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m);
72 struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2);
73 extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m);
74 extern bool ceph_mdsmap_is_cluster_available(struct ceph_mdsmap *m);
75
76 #endif
77