mon_client.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef _FS_CEPH_MON_CLIENT_H
  2. #define _FS_CEPH_MON_CLIENT_H
  3. #include <linux/completion.h>
  4. #include <linux/kref.h>
  5. #include <linux/rbtree.h>
  6. #include <linux/ceph/messenger.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_generic_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. * ceph_mon_generic_request is being used for the statfs and
  35. * mon_get_version requests which are being done a bit differently
  36. * because we need to get data back to the caller
  37. */
  38. struct ceph_mon_generic_request {
  39. struct kref kref;
  40. u64 tid;
  41. struct rb_node node;
  42. int result;
  43. void *buf;
  44. struct completion completion;
  45. struct ceph_msg *request; /* original request */
  46. struct ceph_msg *reply; /* and reply */
  47. };
  48. struct ceph_mon_client {
  49. struct ceph_client *client;
  50. struct ceph_monmap *monmap;
  51. struct mutex mutex;
  52. struct delayed_work delayed_work;
  53. struct ceph_auth_client *auth;
  54. struct ceph_msg *m_auth, *m_auth_reply, *m_subscribe, *m_subscribe_ack;
  55. int pending_auth;
  56. bool hunting;
  57. int cur_mon; /* last monitor i contacted */
  58. unsigned long sub_sent, sub_renew_after;
  59. struct ceph_connection con;
  60. /* pending generic requests */
  61. struct rb_root generic_request_tree;
  62. int num_generic_requests;
  63. u64 last_tid;
  64. /* mds/osd map */
  65. int want_mdsmap;
  66. int want_next_osdmap; /* 1 = want, 2 = want+asked */
  67. u32 have_osdmap, have_mdsmap;
  68. #ifdef CONFIG_DEBUG_FS
  69. struct dentry *debugfs_file;
  70. #endif
  71. };
  72. extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end);
  73. extern int ceph_monmap_contains(struct ceph_monmap *m,
  74. struct ceph_entity_addr *addr);
  75. extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
  76. extern void ceph_monc_stop(struct ceph_mon_client *monc);
  77. /*
  78. * The model here is to indicate that we need a new map of at least
  79. * epoch @want, and also call in when we receive a map. We will
  80. * periodically rerequest the map from the monitor cluster until we
  81. * get what we want.
  82. */
  83. extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have);
  84. extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have);
  85. extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc);
  86. extern int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch,
  87. unsigned long timeout);
  88. extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
  89. struct ceph_statfs *buf);
  90. extern int ceph_monc_do_get_version(struct ceph_mon_client *monc,
  91. const char *what, u64 *newest);
  92. extern int ceph_monc_open_session(struct ceph_mon_client *monc);
  93. extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);
  94. #endif