mdsmap.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _FS_CEPH_MDSMAP_H
  2. #define _FS_CEPH_MDSMAP_H
  3. #include "types.h"
  4. /*
  5. * mds map - describe servers in the mds cluster.
  6. *
  7. * we limit fields to those the client actually xcares about
  8. */
  9. struct ceph_mds_info {
  10. u64 global_id;
  11. struct ceph_entity_addr addr;
  12. s32 state;
  13. int num_export_targets;
  14. bool laggy;
  15. u32 *export_targets;
  16. };
  17. struct ceph_mdsmap {
  18. u32 m_epoch, m_client_epoch, m_last_failure;
  19. u32 m_root;
  20. u32 m_session_timeout; /* seconds */
  21. u32 m_session_autoclose; /* seconds */
  22. u64 m_max_file_size;
  23. u32 m_max_mds; /* size of m_addr, m_state arrays */
  24. struct ceph_mds_info *m_info;
  25. /* which object pools file data can be stored in */
  26. int m_num_data_pg_pools;
  27. u32 *m_data_pg_pools;
  28. u32 m_cas_pg_pool;
  29. };
  30. static inline struct ceph_entity_addr *
  31. ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w)
  32. {
  33. if (w >= m->m_max_mds)
  34. return NULL;
  35. return &m->m_info[w].addr;
  36. }
  37. static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w)
  38. {
  39. BUG_ON(w < 0);
  40. if (w >= m->m_max_mds)
  41. return CEPH_MDS_STATE_DNE;
  42. return m->m_info[w].state;
  43. }
  44. static inline bool ceph_mdsmap_is_laggy(struct ceph_mdsmap *m, int w)
  45. {
  46. if (w >= 0 && w < m->m_max_mds)
  47. return m->m_info[w].laggy;
  48. return false;
  49. }
  50. extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m);
  51. extern struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end);
  52. extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m);
  53. #endif