mon_client.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 "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 poolop requests
  35. * which are bening done a bit differently because we need to get data back
  36. * 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. int buf_len;
  45. struct completion completion;
  46. struct ceph_msg *request; /* original request */
  47. struct ceph_msg *reply; /* and reply */
  48. };
  49. struct ceph_mon_client {
  50. struct ceph_client *client;
  51. struct ceph_monmap *monmap;
  52. struct mutex mutex;
  53. struct delayed_work delayed_work;
  54. struct ceph_auth_client *auth;
  55. struct ceph_msg *m_auth, *m_auth_reply, *m_subscribe, *m_subscribe_ack;
  56. int pending_auth;
  57. bool hunting;
  58. int cur_mon; /* last monitor i contacted */
  59. unsigned long sub_sent, sub_renew_after;
  60. struct ceph_connection *con;
  61. bool have_fsid;
  62. /* pending generic requests */
  63. struct rb_root generic_request_tree;
  64. int num_generic_requests;
  65. u64 last_tid;
  66. /* mds/osd map */
  67. int want_next_osdmap; /* 1 = want, 2 = want+asked */
  68. u32 have_osdmap, have_mdsmap;
  69. #ifdef CONFIG_DEBUG_FS
  70. struct dentry *debugfs_file;
  71. #endif
  72. };
  73. extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end);
  74. extern int ceph_monmap_contains(struct ceph_monmap *m,
  75. struct ceph_entity_addr *addr);
  76. extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
  77. extern void ceph_monc_stop(struct ceph_mon_client *monc);
  78. /*
  79. * The model here is to indicate that we need a new map of at least
  80. * epoch @want, and also call in when we receive a map. We will
  81. * periodically rerequest the map from the monitor cluster until we
  82. * get what we want.
  83. */
  84. extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have);
  85. extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have);
  86. extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc);
  87. extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
  88. struct ceph_statfs *buf);
  89. extern int ceph_monc_open_session(struct ceph_mon_client *monc);
  90. extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);
  91. extern int ceph_monc_create_snapid(struct ceph_mon_client *monc,
  92. u32 pool, u64 *snapid);
  93. extern int ceph_monc_delete_snapid(struct ceph_mon_client *monc,
  94. u32 pool, u64 snapid);
  95. #endif