mdsmap.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _FS_CEPH_MDSMAP_H
  3. #define _FS_CEPH_MDSMAP_H
  4. #include <linux/bug.h>
  5. #include <linux/ceph/types.h>
  6. /*
  7. * mds map - describe servers in the mds cluster.
  8. *
  9. * we limit fields to those the client actually xcares about
  10. */
  11. struct ceph_mds_info {
  12. u64 global_id;
  13. struct ceph_entity_addr addr;
  14. s32 state;
  15. int num_export_targets;
  16. bool laggy;
  17. u32 *export_targets;
  18. };
  19. struct ceph_mdsmap {
  20. u32 m_epoch, m_client_epoch, m_last_failure;
  21. u32 m_root;
  22. u32 m_session_timeout; /* seconds */
  23. u32 m_session_autoclose; /* seconds */
  24. u64 m_max_file_size;
  25. u64 m_max_xattr_size; /* maximum size for xattrs blob */
  26. u32 m_max_mds; /* expected up:active mds number */
  27. u32 m_num_active_mds; /* actual up:active mds number */
  28. u32 possible_max_rank; /* possible max rank index */
  29. struct ceph_mds_info *m_info;
  30. /* which object pools file data can be stored in */
  31. int m_num_data_pg_pools;
  32. u64 *m_data_pg_pools;
  33. u64 m_cas_pg_pool;
  34. bool m_enabled;
  35. bool m_damaged;
  36. int m_num_laggy;
  37. };
  38. static inline struct ceph_entity_addr *
  39. ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w)
  40. {
  41. if (w >= m->possible_max_rank)
  42. return NULL;
  43. return &m->m_info[w].addr;
  44. }
  45. static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w)
  46. {
  47. BUG_ON(w < 0);
  48. if (w >= m->possible_max_rank)
  49. return CEPH_MDS_STATE_DNE;
  50. return m->m_info[w].state;
  51. }
  52. static inline bool ceph_mdsmap_is_laggy(struct ceph_mdsmap *m, int w)
  53. {
  54. if (w >= 0 && w < m->possible_max_rank)
  55. return m->m_info[w].laggy;
  56. return false;
  57. }
  58. extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m);
  59. struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2);
  60. extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m);
  61. extern bool ceph_mdsmap_is_cluster_available(struct ceph_mdsmap *m);
  62. #endif