mon_client.h 2.9 KB
Newer Older
S
Sage Weil 已提交
1 2 3 4
#ifndef _FS_CEPH_MON_CLIENT_H
#define _FS_CEPH_MON_CLIENT_H

#include <linux/completion.h>
5
#include <linux/rbtree.h>
S
Sage Weil 已提交
6 7 8 9 10 11

#include "messenger.h"
#include "msgpool.h"

struct ceph_client;
struct ceph_mount_args;
12
struct ceph_auth_client;
S
Sage Weil 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

/*
 * 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;
struct ceph_mon_statfs_request;


/*
 * 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;
};

/*
 * statfs() is done a bit differently because we need to get data back
 * to the caller
 */
struct ceph_mon_statfs_request {
	u64 tid;
48
	struct rb_node node;
S
Sage Weil 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62
	int result;
	struct ceph_statfs *buf;
	struct completion completion;
	unsigned long last_attempt, delay; /* jiffies */
	struct ceph_msg *request;  /* original request */
};

struct ceph_mon_client {
	struct ceph_client *client;
	struct ceph_monmap *monmap;

	struct mutex mutex;
	struct delayed_work delayed_work;

63 64
	struct ceph_auth_client *auth;
	struct ceph_msg *m_auth;
65
	int pending_auth;
66

S
Sage Weil 已提交
67 68 69 70
	bool hunting;
	int cur_mon;                       /* last monitor i contacted */
	unsigned long sub_sent, sub_renew_after;
	struct ceph_connection *con;
71
	bool have_fsid;
S
Sage Weil 已提交
72 73 74 75

	/* msg pools */
	struct ceph_msgpool msgpool_subscribe_ack;
	struct ceph_msgpool msgpool_statfs_reply;
76
	struct ceph_msgpool msgpool_auth_reply;
S
Sage Weil 已提交
77 78

	/* pending statfs requests */
79
	struct rb_root statfs_request_tree;
S
Sage Weil 已提交
80 81 82
	int num_statfs_requests;
	u64 last_tid;

83
	/* mds/osd map */
S
Sage Weil 已提交
84 85 86
	int want_next_osdmap; /* 1 = want, 2 = want+asked */
	u32 have_osdmap, have_mdsmap;

87
#ifdef CONFIG_DEBUG_FS
S
Sage Weil 已提交
88
	struct dentry *debugfs_file;
89
#endif
S
Sage Weil 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
};

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);

113 114
extern int ceph_monc_open_session(struct ceph_mon_client *monc);

115 116
extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);

S
Sage Weil 已提交
117 118 119


#endif