mdsmap.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. struct ceph_mds_client;
  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 {
  13. u64 global_id;
  14. struct ceph_entity_addr addr;
  15. s32 state;
  16. int num_export_targets;
  17. bool laggy;
  18. u32 *export_targets;
  19. };
  20. struct ceph_mdsmap {
  21. u32 m_epoch, m_client_epoch, m_last_failure;
  22. u32 m_root;
  23. u32 m_session_timeout; /* seconds */
  24. u32 m_session_autoclose; /* seconds */
  25. u64 m_max_file_size;
  26. /*
  27. * maximum size for xattrs blob.
  28. * Zeroed by default to force the usage of the (sync) SETXATTR Op.
  29. */
  30. u64 m_max_xattr_size;
  31. u32 m_max_mds; /* expected up:active mds number */
  32. u32 m_num_active_mds; /* actual up:active mds number */
  33. u32 possible_max_rank; /* possible max rank index */
  34. struct ceph_mds_info *m_info;
  35. /* which object pools file data can be stored in */
  36. int m_num_data_pg_pools;
  37. u64 *m_data_pg_pools;
  38. u64 m_cas_pg_pool;
  39. bool m_enabled;
  40. bool m_damaged;
  41. int m_num_laggy;
  42. };
  43. static inline struct ceph_entity_addr *
  44. ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w)
  45. {
  46. if (w >= m->possible_max_rank)
  47. return NULL;
  48. return &m->m_info[w].addr;
  49. }
  50. static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w)
  51. {
  52. BUG_ON(w < 0);
  53. if (w >= m->possible_max_rank)
  54. return CEPH_MDS_STATE_DNE;
  55. return m->m_info[w].state;
  56. }
  57. static inline bool ceph_mdsmap_is_laggy(struct ceph_mdsmap *m, int w)
  58. {
  59. if (w >= 0 && w < m->possible_max_rank)
  60. return m->m_info[w].laggy;
  61. return false;
  62. }
  63. extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m);
  64. struct ceph_mdsmap *ceph_mdsmap_decode(struct ceph_mds_client *mdsc, void **p,
  65. void *end, bool msgr2);
  66. extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m);
  67. extern bool ceph_mdsmap_is_cluster_available(struct ceph_mdsmap *m);
  68. #endif