Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 1 | #ifndef _FS_CEPH_MDSMAP_H |
| 2 | #define _FS_CEPH_MDSMAP_H |
| 3 | |
Paul Gortmaker | 187f188 | 2011-11-23 20:12:59 -0500 | [diff] [blame] | 4 | #include <linux/bug.h> |
David Howells | a1ce392 | 2012-10-02 18:01:25 +0100 | [diff] [blame] | 5 | #include <linux/ceph/types.h> |
Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 6 | |
| 7 | /* |
| 8 | * mds map - describe servers in the mds cluster. |
| 9 | * |
| 10 | * we limit fields to those the client actually xcares about |
| 11 | */ |
| 12 | struct ceph_mds_info { |
Sage Weil | 94045e1 | 2009-11-19 15:31:50 -0800 | [diff] [blame] | 13 | u64 global_id; |
Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 14 | struct ceph_entity_addr addr; |
| 15 | s32 state; |
| 16 | int num_export_targets; |
Sage Weil | 0deb01c | 2010-06-17 14:19:01 -0700 | [diff] [blame] | 17 | bool laggy; |
Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 18 | u32 *export_targets; |
| 19 | }; |
| 20 | |
| 21 | struct 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 */ |
Yan, Zheng | 76201b6 | 2017-03-28 17:04:13 +0800 | [diff] [blame] | 28 | int m_num_mds; |
Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 29 | struct ceph_mds_info *m_info; |
| 30 | |
| 31 | /* which object pools file data can be stored in */ |
| 32 | int m_num_data_pg_pools; |
Sage Weil | 4f6a7e5 | 2013-02-23 10:41:09 -0800 | [diff] [blame] | 33 | u64 *m_data_pg_pools; |
| 34 | u64 m_cas_pg_pool; |
Yan, Zheng | e9e427f | 2016-11-10 16:02:06 +0800 | [diff] [blame] | 35 | |
| 36 | bool m_enabled; |
| 37 | bool m_damaged; |
| 38 | int m_num_laggy; |
Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | static inline struct ceph_entity_addr * |
| 42 | ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w) |
| 43 | { |
Yan, Zheng | 76201b6 | 2017-03-28 17:04:13 +0800 | [diff] [blame] | 44 | if (w >= m->m_num_mds) |
Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 45 | return NULL; |
| 46 | return &m->m_info[w].addr; |
| 47 | } |
| 48 | |
| 49 | static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w) |
| 50 | { |
| 51 | BUG_ON(w < 0); |
Yan, Zheng | 76201b6 | 2017-03-28 17:04:13 +0800 | [diff] [blame] | 52 | if (w >= m->m_num_mds) |
Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 53 | return CEPH_MDS_STATE_DNE; |
| 54 | return m->m_info[w].state; |
| 55 | } |
| 56 | |
Sage Weil | 0deb01c | 2010-06-17 14:19:01 -0700 | [diff] [blame] | 57 | static inline bool ceph_mdsmap_is_laggy(struct ceph_mdsmap *m, int w) |
| 58 | { |
Yan, Zheng | 76201b6 | 2017-03-28 17:04:13 +0800 | [diff] [blame] | 59 | if (w >= 0 && w < m->m_num_mds) |
Sage Weil | 0deb01c | 2010-06-17 14:19:01 -0700 | [diff] [blame] | 60 | return m->m_info[w].laggy; |
| 61 | return false; |
| 62 | } |
| 63 | |
Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 64 | extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m); |
| 65 | extern struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end); |
| 66 | extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m); |
Yan, Zheng | e9e427f | 2016-11-10 16:02:06 +0800 | [diff] [blame] | 67 | extern bool ceph_mdsmap_is_cluster_available(struct ceph_mdsmap *m); |
Sage Weil | 2f2dc05 | 2009-10-06 11:31:09 -0700 | [diff] [blame] | 68 | |
| 69 | #endif |