blob: 8ed5dc505fbb2e0672efd81089d1e35caf8e062c [file] [log] [blame]
Sage Weil2f2dc052009-10-06 11:31:09 -07001#ifndef _FS_CEPH_MDSMAP_H
2#define _FS_CEPH_MDSMAP_H
3
Paul Gortmaker187f1882011-11-23 20:12:59 -05004#include <linux/bug.h>
David Howellsa1ce3922012-10-02 18:01:25 +01005#include <linux/ceph/types.h>
Sage Weil2f2dc052009-10-06 11:31:09 -07006
7/*
8 * mds map - describe servers in the mds cluster.
9 *
10 * we limit fields to those the client actually xcares about
11 */
12struct ceph_mds_info {
Sage Weil94045e12009-11-19 15:31:50 -080013 u64 global_id;
Sage Weil2f2dc052009-10-06 11:31:09 -070014 struct ceph_entity_addr addr;
15 s32 state;
16 int num_export_targets;
Sage Weil0deb01c2010-06-17 14:19:01 -070017 bool laggy;
Sage Weil2f2dc052009-10-06 11:31:09 -070018 u32 *export_targets;
19};
20
21struct ceph_mdsmap {
22 u32 m_epoch, m_client_epoch, m_last_failure;
23 u32 m_root;
24 u32 m_session_timeout; /* seconds */
25 u32 m_session_autoclose; /* seconds */
26 u64 m_max_file_size;
27 u32 m_max_mds; /* size of m_addr, m_state arrays */
28 struct ceph_mds_info *m_info;
29
30 /* which object pools file data can be stored in */
31 int m_num_data_pg_pools;
Sage Weil4f6a7e52013-02-23 10:41:09 -080032 u64 *m_data_pg_pools;
33 u64 m_cas_pg_pool;
Yan, Zhenge9e427f2016-11-10 16:02:06 +080034
35 bool m_enabled;
36 bool m_damaged;
37 int m_num_laggy;
Sage Weil2f2dc052009-10-06 11:31:09 -070038};
39
40static inline struct ceph_entity_addr *
41ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w)
42{
43 if (w >= m->m_max_mds)
44 return NULL;
45 return &m->m_info[w].addr;
46}
47
48static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w)
49{
50 BUG_ON(w < 0);
51 if (w >= m->m_max_mds)
52 return CEPH_MDS_STATE_DNE;
53 return m->m_info[w].state;
54}
55
Sage Weil0deb01c2010-06-17 14:19:01 -070056static inline bool ceph_mdsmap_is_laggy(struct ceph_mdsmap *m, int w)
57{
58 if (w >= 0 && w < m->m_max_mds)
59 return m->m_info[w].laggy;
60 return false;
61}
62
Sage Weil2f2dc052009-10-06 11:31:09 -070063extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m);
64extern struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end);
65extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m);
Yan, Zhenge9e427f2016-11-10 16:02:06 +080066extern bool ceph_mdsmap_is_cluster_available(struct ceph_mdsmap *m);
Sage Weil2f2dc052009-10-06 11:31:09 -070067
68#endif