13d14c5d2SYehuda Sadeh #ifndef _FS_CEPH_MON_CLIENT_H 23d14c5d2SYehuda Sadeh #define _FS_CEPH_MON_CLIENT_H 33d14c5d2SYehuda Sadeh 43d14c5d2SYehuda Sadeh #include <linux/completion.h> 53d14c5d2SYehuda Sadeh #include <linux/kref.h> 63d14c5d2SYehuda Sadeh #include <linux/rbtree.h> 73d14c5d2SYehuda Sadeh 8a1ce3928SDavid Howells #include <linux/ceph/messenger.h> 93d14c5d2SYehuda Sadeh 103d14c5d2SYehuda Sadeh struct ceph_client; 113d14c5d2SYehuda Sadeh struct ceph_mount_args; 123d14c5d2SYehuda Sadeh struct ceph_auth_client; 133d14c5d2SYehuda Sadeh 143d14c5d2SYehuda Sadeh /* 153d14c5d2SYehuda Sadeh * The monitor map enumerates the set of all monitors. 163d14c5d2SYehuda Sadeh */ 173d14c5d2SYehuda Sadeh struct ceph_monmap { 183d14c5d2SYehuda Sadeh struct ceph_fsid fsid; 193d14c5d2SYehuda Sadeh u32 epoch; 203d14c5d2SYehuda Sadeh u32 num_mon; 213d14c5d2SYehuda Sadeh struct ceph_entity_inst mon_inst[0]; 223d14c5d2SYehuda Sadeh }; 233d14c5d2SYehuda Sadeh 243d14c5d2SYehuda Sadeh struct ceph_mon_client; 253d14c5d2SYehuda Sadeh struct ceph_mon_generic_request; 263d14c5d2SYehuda Sadeh 273d14c5d2SYehuda Sadeh 283d14c5d2SYehuda Sadeh /* 293d14c5d2SYehuda Sadeh * Generic mechanism for resending monitor requests. 303d14c5d2SYehuda Sadeh */ 313d14c5d2SYehuda Sadeh typedef void (*ceph_monc_request_func_t)(struct ceph_mon_client *monc, 323d14c5d2SYehuda Sadeh int newmon); 333d14c5d2SYehuda Sadeh 343d14c5d2SYehuda Sadeh /* a pending monitor request */ 353d14c5d2SYehuda Sadeh struct ceph_mon_request { 363d14c5d2SYehuda Sadeh struct ceph_mon_client *monc; 373d14c5d2SYehuda Sadeh struct delayed_work delayed_work; 383d14c5d2SYehuda Sadeh unsigned long delay; 393d14c5d2SYehuda Sadeh ceph_monc_request_func_t do_request; 403d14c5d2SYehuda Sadeh }; 413d14c5d2SYehuda Sadeh 423d14c5d2SYehuda Sadeh /* 43513a8243SIlya Dryomov * ceph_mon_generic_request is being used for the statfs, poolop and 44513a8243SIlya Dryomov * mon_get_version requests which are being done a bit differently 45513a8243SIlya Dryomov * because we need to get data back to the caller 463d14c5d2SYehuda Sadeh */ 473d14c5d2SYehuda Sadeh struct ceph_mon_generic_request { 483d14c5d2SYehuda Sadeh struct kref kref; 493d14c5d2SYehuda Sadeh u64 tid; 503d14c5d2SYehuda Sadeh struct rb_node node; 513d14c5d2SYehuda Sadeh int result; 523d14c5d2SYehuda Sadeh void *buf; 533d14c5d2SYehuda Sadeh int buf_len; 543d14c5d2SYehuda Sadeh struct completion completion; 553d14c5d2SYehuda Sadeh struct ceph_msg *request; /* original request */ 563d14c5d2SYehuda Sadeh struct ceph_msg *reply; /* and reply */ 573d14c5d2SYehuda Sadeh }; 583d14c5d2SYehuda Sadeh 593d14c5d2SYehuda Sadeh struct ceph_mon_client { 603d14c5d2SYehuda Sadeh struct ceph_client *client; 613d14c5d2SYehuda Sadeh struct ceph_monmap *monmap; 623d14c5d2SYehuda Sadeh 633d14c5d2SYehuda Sadeh struct mutex mutex; 643d14c5d2SYehuda Sadeh struct delayed_work delayed_work; 653d14c5d2SYehuda Sadeh 663d14c5d2SYehuda Sadeh struct ceph_auth_client *auth; 673d14c5d2SYehuda Sadeh struct ceph_msg *m_auth, *m_auth_reply, *m_subscribe, *m_subscribe_ack; 683d14c5d2SYehuda Sadeh int pending_auth; 693d14c5d2SYehuda Sadeh 703d14c5d2SYehuda Sadeh bool hunting; 713d14c5d2SYehuda Sadeh int cur_mon; /* last monitor i contacted */ 723d14c5d2SYehuda Sadeh unsigned long sub_sent, sub_renew_after; 7367130934SAlex Elder struct ceph_connection con; 743d14c5d2SYehuda Sadeh 753d14c5d2SYehuda Sadeh /* pending generic requests */ 763d14c5d2SYehuda Sadeh struct rb_root generic_request_tree; 773d14c5d2SYehuda Sadeh int num_generic_requests; 783d14c5d2SYehuda Sadeh u64 last_tid; 793d14c5d2SYehuda Sadeh 803d14c5d2SYehuda Sadeh /* mds/osd map */ 813d14c5d2SYehuda Sadeh int want_mdsmap; 823d14c5d2SYehuda Sadeh int want_next_osdmap; /* 1 = want, 2 = want+asked */ 833d14c5d2SYehuda Sadeh u32 have_osdmap, have_mdsmap; 843d14c5d2SYehuda Sadeh 853d14c5d2SYehuda Sadeh #ifdef CONFIG_DEBUG_FS 863d14c5d2SYehuda Sadeh struct dentry *debugfs_file; 873d14c5d2SYehuda Sadeh #endif 883d14c5d2SYehuda Sadeh }; 893d14c5d2SYehuda Sadeh 903d14c5d2SYehuda Sadeh extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end); 913d14c5d2SYehuda Sadeh extern int ceph_monmap_contains(struct ceph_monmap *m, 923d14c5d2SYehuda Sadeh struct ceph_entity_addr *addr); 933d14c5d2SYehuda Sadeh 943d14c5d2SYehuda Sadeh extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl); 953d14c5d2SYehuda Sadeh extern void ceph_monc_stop(struct ceph_mon_client *monc); 963d14c5d2SYehuda Sadeh 973d14c5d2SYehuda Sadeh /* 983d14c5d2SYehuda Sadeh * The model here is to indicate that we need a new map of at least 993d14c5d2SYehuda Sadeh * epoch @want, and also call in when we receive a map. We will 1003d14c5d2SYehuda Sadeh * periodically rerequest the map from the monitor cluster until we 1013d14c5d2SYehuda Sadeh * get what we want. 1023d14c5d2SYehuda Sadeh */ 1033d14c5d2SYehuda Sadeh extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have); 1043d14c5d2SYehuda Sadeh extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have); 1053d14c5d2SYehuda Sadeh 1063d14c5d2SYehuda Sadeh extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc); 1073d14c5d2SYehuda Sadeh 1083d14c5d2SYehuda Sadeh extern int ceph_monc_do_statfs(struct ceph_mon_client *monc, 1093d14c5d2SYehuda Sadeh struct ceph_statfs *buf); 1103d14c5d2SYehuda Sadeh 111513a8243SIlya Dryomov extern int ceph_monc_do_get_version(struct ceph_mon_client *monc, 112513a8243SIlya Dryomov const char *what, u64 *newest); 113513a8243SIlya Dryomov 1143d14c5d2SYehuda Sadeh extern int ceph_monc_open_session(struct ceph_mon_client *monc); 1153d14c5d2SYehuda Sadeh 1163d14c5d2SYehuda Sadeh extern int ceph_monc_validate_auth(struct ceph_mon_client *monc); 1173d14c5d2SYehuda Sadeh 1183d14c5d2SYehuda Sadeh extern int ceph_monc_create_snapid(struct ceph_mon_client *monc, 1193d14c5d2SYehuda Sadeh u32 pool, u64 *snapid); 1203d14c5d2SYehuda Sadeh 1213d14c5d2SYehuda Sadeh extern int ceph_monc_delete_snapid(struct ceph_mon_client *monc, 1223d14c5d2SYehuda Sadeh u32 pool, u64 snapid); 1233d14c5d2SYehuda Sadeh 1243d14c5d2SYehuda Sadeh #endif 125