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