mon_client.h 2.7 KB

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