mon_client.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef _FS_CEPH_MON_CLIENT_H
  2. #define _FS_CEPH_MON_CLIENT_H
  3. #include <linux/completion.h>
  4. #include <linux/rbtree.h>
  5. #include "messenger.h"
  6. #include "msgpool.h"
  7. struct ceph_client;
  8. struct ceph_mount_args;
  9. struct ceph_auth_client;
  10. /*
  11. * The monitor map enumerates the set of all monitors.
  12. */
  13. struct ceph_monmap {
  14. struct ceph_fsid fsid;
  15. u32 epoch;
  16. u32 num_mon;
  17. struct ceph_entity_inst mon_inst[0];
  18. };
  19. struct ceph_mon_client;
  20. struct ceph_mon_statfs_request;
  21. /*
  22. * Generic mechanism for resending monitor requests.
  23. */
  24. typedef void (*ceph_monc_request_func_t)(struct ceph_mon_client *monc,
  25. int newmon);
  26. /* a pending monitor request */
  27. struct ceph_mon_request {
  28. struct ceph_mon_client *monc;
  29. struct delayed_work delayed_work;
  30. unsigned long delay;
  31. ceph_monc_request_func_t do_request;
  32. };
  33. /*
  34. * statfs() is done a bit differently because we need to get data back
  35. * to the caller
  36. */
  37. struct ceph_mon_statfs_request {
  38. u64 tid;
  39. struct rb_node node;
  40. int result;
  41. struct ceph_statfs *buf;
  42. struct completion completion;
  43. unsigned long last_attempt, delay; /* jiffies */
  44. struct ceph_msg *request; /* original request */
  45. };
  46. struct ceph_mon_client {
  47. struct ceph_client *client;
  48. struct ceph_monmap *monmap;
  49. struct mutex mutex;
  50. struct delayed_work delayed_work;
  51. struct ceph_auth_client *auth;
  52. struct ceph_msg *m_auth;
  53. int pending_auth;
  54. bool hunting;
  55. int cur_mon; /* last monitor i contacted */
  56. unsigned long sub_sent, sub_renew_after;
  57. struct ceph_connection *con;
  58. bool have_fsid;
  59. /* msg pools */
  60. struct ceph_msgpool msgpool_subscribe_ack;
  61. struct ceph_msgpool msgpool_statfs_reply;
  62. struct ceph_msgpool msgpool_auth_reply;
  63. /* pending statfs requests */
  64. struct rb_root statfs_request_tree;
  65. int num_statfs_requests;
  66. u64 last_tid;
  67. /* mds/osd map */
  68. int want_next_osdmap; /* 1 = want, 2 = want+asked */
  69. u32 have_osdmap, have_mdsmap;
  70. #ifdef CONFIG_DEBUG_FS
  71. struct dentry *debugfs_file;
  72. #endif
  73. };
  74. extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end);
  75. extern int ceph_monmap_contains(struct ceph_monmap *m,
  76. struct ceph_entity_addr *addr);
  77. extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
  78. extern void ceph_monc_stop(struct ceph_mon_client *monc);
  79. /*
  80. * The model here is to indicate that we need a new map of at least
  81. * epoch @want, and also call in when we receive a map. We will
  82. * periodically rerequest the map from the monitor cluster until we
  83. * get what we want.
  84. */
  85. extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have);
  86. extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have);
  87. extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc);
  88. extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
  89. struct ceph_statfs *buf);
  90. extern int ceph_monc_open_session(struct ceph_mon_client *monc);
  91. extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);
  92. #endif