2009-10-07 02:31:11 +08:00
|
|
|
#ifndef _FS_CEPH_MON_CLIENT_H
|
|
|
|
#define _FS_CEPH_MON_CLIENT_H
|
|
|
|
|
|
|
|
#include <linux/completion.h>
|
2010-03-25 12:43:33 +08:00
|
|
|
#include <linux/kref.h>
|
2010-02-16 06:47:28 +08:00
|
|
|
#include <linux/rbtree.h>
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2012-10-03 01:01:25 +08:00
|
|
|
#include <linux/ceph/messenger.h>
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
struct ceph_client;
|
|
|
|
struct ceph_mount_args;
|
2009-11-19 08:19:57 +08:00
|
|
|
struct ceph_auth_client;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The monitor map enumerates the set of all monitors.
|
|
|
|
*/
|
|
|
|
struct ceph_monmap {
|
|
|
|
struct ceph_fsid fsid;
|
|
|
|
u32 epoch;
|
|
|
|
u32 num_mon;
|
|
|
|
struct ceph_entity_inst mon_inst[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ceph_mon_client;
|
2010-04-23 06:40:37 +08:00
|
|
|
struct ceph_mon_generic_request;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic mechanism for resending monitor requests.
|
|
|
|
*/
|
|
|
|
typedef void (*ceph_monc_request_func_t)(struct ceph_mon_client *monc,
|
|
|
|
int newmon);
|
|
|
|
|
|
|
|
/* a pending monitor request */
|
|
|
|
struct ceph_mon_request {
|
|
|
|
struct ceph_mon_client *monc;
|
|
|
|
struct delayed_work delayed_work;
|
|
|
|
unsigned long delay;
|
|
|
|
ceph_monc_request_func_t do_request;
|
|
|
|
};
|
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
typedef void (*ceph_monc_callback_t)(struct ceph_mon_generic_request *);
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
/*
|
2014-12-23 00:14:26 +08:00
|
|
|
* ceph_mon_generic_request is being used for the statfs and
|
2014-05-13 15:19:26 +08:00
|
|
|
* mon_get_version requests which are being done a bit differently
|
|
|
|
* because we need to get data back to the caller
|
2009-10-07 02:31:11 +08:00
|
|
|
*/
|
2010-04-23 06:40:37 +08:00
|
|
|
struct ceph_mon_generic_request {
|
2016-04-28 22:07:27 +08:00
|
|
|
struct ceph_mon_client *monc;
|
2010-03-25 12:43:33 +08:00
|
|
|
struct kref kref;
|
2009-10-07 02:31:11 +08:00
|
|
|
u64 tid;
|
2010-02-16 06:47:28 +08:00
|
|
|
struct rb_node node;
|
2009-10-07 02:31:11 +08:00
|
|
|
int result;
|
2016-04-28 22:07:27 +08:00
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
struct completion completion;
|
2016-04-28 22:07:27 +08:00
|
|
|
ceph_monc_callback_t complete_cb;
|
|
|
|
u64 private_data; /* r_tid/linger_id */
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
struct ceph_msg *request; /* original request */
|
2010-03-25 12:43:33 +08:00
|
|
|
struct ceph_msg *reply; /* and reply */
|
2016-04-28 22:07:27 +08:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct ceph_statfs *st;
|
|
|
|
u64 newest;
|
|
|
|
} u;
|
2009-10-07 02:31:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ceph_mon_client {
|
|
|
|
struct ceph_client *client;
|
|
|
|
struct ceph_monmap *monmap;
|
|
|
|
|
|
|
|
struct mutex mutex;
|
|
|
|
struct delayed_work delayed_work;
|
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
struct ceph_auth_client *auth;
|
2010-05-22 05:57:25 +08:00
|
|
|
struct ceph_msg *m_auth, *m_auth_reply, *m_subscribe, *m_subscribe_ack;
|
2010-02-03 08:21:06 +08:00
|
|
|
int pending_auth;
|
2009-11-19 08:19:57 +08:00
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
bool hunting;
|
|
|
|
int cur_mon; /* last monitor i contacted */
|
2016-01-19 23:19:06 +08:00
|
|
|
unsigned long sub_renew_after;
|
|
|
|
unsigned long sub_renew_sent;
|
2012-05-27 12:26:43 +08:00
|
|
|
struct ceph_connection con;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2016-01-21 23:33:19 +08:00
|
|
|
bool had_a_connection;
|
|
|
|
int hunt_mult; /* [1..CEPH_MONC_HUNT_MAX_MULT] */
|
|
|
|
|
2010-04-23 06:40:37 +08:00
|
|
|
/* pending generic requests */
|
|
|
|
struct rb_root generic_request_tree;
|
2009-10-07 02:31:11 +08:00
|
|
|
u64 last_tid;
|
|
|
|
|
2016-01-19 23:19:06 +08:00
|
|
|
/* subs, indexed with CEPH_SUB_* */
|
|
|
|
struct {
|
|
|
|
struct ceph_mon_subscribe_item item;
|
|
|
|
bool want;
|
|
|
|
u32 have; /* epoch */
|
2016-04-07 11:34:43 +08:00
|
|
|
} subs[4];
|
2016-05-26 06:05:01 +08:00
|
|
|
int fs_cluster_id; /* "mdsmap.<id>" sub */
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2009-11-13 07:05:52 +08:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
2009-10-07 02:31:11 +08:00
|
|
|
struct dentry *debugfs_file;
|
2009-11-13 07:05:52 +08:00
|
|
|
#endif
|
2009-10-07 02:31:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end);
|
|
|
|
extern int ceph_monmap_contains(struct ceph_monmap *m,
|
|
|
|
struct ceph_entity_addr *addr);
|
|
|
|
|
|
|
|
extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
|
|
|
|
extern void ceph_monc_stop(struct ceph_mon_client *monc);
|
|
|
|
|
2016-01-19 23:19:06 +08:00
|
|
|
enum {
|
2016-04-07 11:34:43 +08:00
|
|
|
CEPH_SUB_MONMAP = 0,
|
2016-01-19 23:19:06 +08:00
|
|
|
CEPH_SUB_OSDMAP,
|
2016-04-07 11:34:43 +08:00
|
|
|
CEPH_SUB_FSMAP,
|
|
|
|
CEPH_SUB_MDSMAP,
|
2016-01-19 23:19:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const char *ceph_sub_str[];
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
/*
|
|
|
|
* The model here is to indicate that we need a new map of at least
|
2016-01-19 23:19:06 +08:00
|
|
|
* epoch @epoch, and also call in when we receive a map. We will
|
2009-10-07 02:31:11 +08:00
|
|
|
* periodically rerequest the map from the monitor cluster until we
|
|
|
|
* get what we want.
|
|
|
|
*/
|
2016-01-19 23:19:06 +08:00
|
|
|
bool ceph_monc_want_map(struct ceph_mon_client *monc, int sub, u32 epoch,
|
|
|
|
bool continuous);
|
|
|
|
void ceph_monc_got_map(struct ceph_mon_client *monc, int sub, u32 epoch);
|
2016-04-28 22:07:25 +08:00
|
|
|
void ceph_monc_renew_subs(struct ceph_mon_client *monc);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2014-05-13 15:19:27 +08:00
|
|
|
extern int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch,
|
|
|
|
unsigned long timeout);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_statfs *buf);
|
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
|
|
|
|
u64 *newest);
|
|
|
|
int ceph_monc_get_version_async(struct ceph_mon_client *monc, const char *what,
|
|
|
|
ceph_monc_callback_t cb, u64 private_data);
|
2014-05-13 15:19:26 +08:00
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
extern int ceph_monc_open_session(struct ceph_mon_client *monc);
|
|
|
|
|
2010-02-03 08:21:06 +08:00
|
|
|
extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
#endif
|