mdsmap.h 1.4 KB

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