2009-10-06 22:31:11 +04:00
|
|
|
#ifndef _FS_CEPH_MON_CLIENT_H
|
|
|
|
#define _FS_CEPH_MON_CLIENT_H
|
|
|
|
|
|
|
|
#include <linux/completion.h>
|
2010-03-25 07:43:33 +03:00
|
|
|
#include <linux/kref.h>
|
2010-02-16 01:47:28 +03:00
|
|
|
#include <linux/rbtree.h>
|
2009-10-06 22:31:11 +04:00
|
|
|
|
|
|
|
#include "messenger.h"
|
|
|
|
|
|
|
|
struct ceph_client;
|
|
|
|
struct ceph_mount_args;
|
2009-11-19 03:19:57 +03:00
|
|
|
struct ceph_auth_client;
|
2009-10-06 22:31:11 +04: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 02:40:37 +04:00
|
|
|
struct ceph_mon_generic_request;
|
2009-10-06 22:31:11 +04: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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2010-04-23 02:40:37 +04:00
|
|
|
* ceph_mon_generic_request is being used for the statfs and poolop requests
|
|
|
|
* which are bening done a bit differently because we need to get data back
|
2009-10-06 22:31:11 +04:00
|
|
|
* to the caller
|
|
|
|
*/
|
2010-04-23 02:40:37 +04:00
|
|
|
struct ceph_mon_generic_request {
|
2010-03-25 07:43:33 +03:00
|
|
|
struct kref kref;
|
2009-10-06 22:31:11 +04:00
|
|
|
u64 tid;
|
2010-02-16 01:47:28 +03:00
|
|
|
struct rb_node node;
|
2009-10-06 22:31:11 +04:00
|
|
|
int result;
|
2010-04-23 02:40:37 +04:00
|
|
|
void *buf;
|
2009-10-06 22:31:11 +04:00
|
|
|
struct completion completion;
|
|
|
|
struct ceph_msg *request; /* original request */
|
2010-03-25 07:43:33 +03:00
|
|
|
struct ceph_msg *reply; /* and reply */
|
2009-10-06 22:31:11 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ceph_mon_client {
|
|
|
|
struct ceph_client *client;
|
|
|
|
struct ceph_monmap *monmap;
|
|
|
|
|
|
|
|
struct mutex mutex;
|
|
|
|
struct delayed_work delayed_work;
|
|
|
|
|
2009-11-19 03:19:57 +03:00
|
|
|
struct ceph_auth_client *auth;
|
2010-05-22 01:57:25 +04:00
|
|
|
struct ceph_msg *m_auth, *m_auth_reply, *m_subscribe, *m_subscribe_ack;
|
2010-02-03 03:21:06 +03:00
|
|
|
int pending_auth;
|
2009-11-19 03:19:57 +03:00
|
|
|
|
2009-10-06 22:31:11 +04:00
|
|
|
bool hunting;
|
|
|
|
int cur_mon; /* last monitor i contacted */
|
|
|
|
unsigned long sub_sent, sub_renew_after;
|
|
|
|
struct ceph_connection *con;
|
2009-11-19 03:19:57 +03:00
|
|
|
bool have_fsid;
|
2009-10-06 22:31:11 +04:00
|
|
|
|
2010-04-23 02:40:37 +04:00
|
|
|
/* pending generic requests */
|
|
|
|
struct rb_root generic_request_tree;
|
|
|
|
int num_generic_requests;
|
2009-10-06 22:31:11 +04:00
|
|
|
u64 last_tid;
|
|
|
|
|
2009-11-19 03:19:57 +03:00
|
|
|
/* mds/osd map */
|
2009-10-06 22:31:11 +04:00
|
|
|
int want_next_osdmap; /* 1 = want, 2 = want+asked */
|
|
|
|
u32 have_osdmap, have_mdsmap;
|
|
|
|
|
2009-11-13 02:05:52 +03:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
2009-10-06 22:31:11 +04:00
|
|
|
struct dentry *debugfs_file;
|
2009-11-13 02:05:52 +03:00
|
|
|
#endif
|
2009-10-06 22:31:11 +04: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);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The model here is to indicate that we need a new map of at least
|
|
|
|
* epoch @want, and also call in when we receive a map. We will
|
|
|
|
* periodically rerequest the map from the monitor cluster until we
|
|
|
|
* get what we want.
|
|
|
|
*/
|
|
|
|
extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have);
|
|
|
|
extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have);
|
|
|
|
|
|
|
|
extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc);
|
|
|
|
|
|
|
|
extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_statfs *buf);
|
|
|
|
|
2009-11-19 03:19:57 +03:00
|
|
|
extern int ceph_monc_open_session(struct ceph_mon_client *monc);
|
|
|
|
|
2010-02-03 03:21:06 +03:00
|
|
|
extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);
|
|
|
|
|
2009-10-06 22:31:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|