blob: cc89a86c8589c135bb043b6acea00a94ee17b096 [file] [log] [blame]
Sage Weilba75bb92009-10-06 11:31:11 -07001#ifndef _FS_CEPH_MON_CLIENT_H
2#define _FS_CEPH_MON_CLIENT_H
3
4#include <linux/completion.h>
Sage Weil3143edd2010-03-24 21:43:33 -07005#include <linux/kref.h>
Sage Weil85ff03f2010-02-15 14:47:28 -08006#include <linux/rbtree.h>
Sage Weilba75bb92009-10-06 11:31:11 -07007
8#include "messenger.h"
9#include "msgpool.h"
10
11struct ceph_client;
12struct ceph_mount_args;
Sage Weil4e7a5dc2009-11-18 16:19:57 -080013struct ceph_auth_client;
Sage Weilba75bb92009-10-06 11:31:11 -070014
15/*
16 * The monitor map enumerates the set of all monitors.
17 */
18struct ceph_monmap {
19 struct ceph_fsid fsid;
20 u32 epoch;
21 u32 num_mon;
22 struct ceph_entity_inst mon_inst[0];
23};
24
25struct ceph_mon_client;
26struct ceph_mon_statfs_request;
27
28
29/*
30 * Generic mechanism for resending monitor requests.
31 */
32typedef void (*ceph_monc_request_func_t)(struct ceph_mon_client *monc,
33 int newmon);
34
35/* a pending monitor request */
36struct ceph_mon_request {
37 struct ceph_mon_client *monc;
38 struct delayed_work delayed_work;
39 unsigned long delay;
40 ceph_monc_request_func_t do_request;
41};
42
43/*
44 * statfs() is done a bit differently because we need to get data back
45 * to the caller
46 */
47struct ceph_mon_statfs_request {
Sage Weil3143edd2010-03-24 21:43:33 -070048 struct kref kref;
Sage Weilba75bb92009-10-06 11:31:11 -070049 u64 tid;
Sage Weil85ff03f2010-02-15 14:47:28 -080050 struct rb_node node;
Sage Weilba75bb92009-10-06 11:31:11 -070051 int result;
52 struct ceph_statfs *buf;
53 struct completion completion;
Sage Weilba75bb92009-10-06 11:31:11 -070054 struct ceph_msg *request; /* original request */
Sage Weil3143edd2010-03-24 21:43:33 -070055 struct ceph_msg *reply; /* and reply */
Sage Weilba75bb92009-10-06 11:31:11 -070056};
57
58struct ceph_mon_client {
59 struct ceph_client *client;
60 struct ceph_monmap *monmap;
61
62 struct mutex mutex;
63 struct delayed_work delayed_work;
64
Sage Weil4e7a5dc2009-11-18 16:19:57 -080065 struct ceph_auth_client *auth;
66 struct ceph_msg *m_auth;
Sage Weil9bd2e6f2010-02-02 16:21:06 -080067 int pending_auth;
Sage Weil4e7a5dc2009-11-18 16:19:57 -080068
Sage Weilba75bb92009-10-06 11:31:11 -070069 bool hunting;
70 int cur_mon; /* last monitor i contacted */
71 unsigned long sub_sent, sub_renew_after;
72 struct ceph_connection *con;
Sage Weil4e7a5dc2009-11-18 16:19:57 -080073 bool have_fsid;
Sage Weilba75bb92009-10-06 11:31:11 -070074
75 /* msg pools */
Sage Weilba75bb92009-10-06 11:31:11 -070076 struct ceph_msgpool msgpool_subscribe_ack;
Sage Weil4e7a5dc2009-11-18 16:19:57 -080077 struct ceph_msgpool msgpool_auth_reply;
Sage Weilba75bb92009-10-06 11:31:11 -070078
79 /* pending statfs requests */
Sage Weil85ff03f2010-02-15 14:47:28 -080080 struct rb_root statfs_request_tree;
Sage Weilba75bb92009-10-06 11:31:11 -070081 int num_statfs_requests;
82 u64 last_tid;
83
Sage Weil4e7a5dc2009-11-18 16:19:57 -080084 /* mds/osd map */
Sage Weilba75bb92009-10-06 11:31:11 -070085 int want_next_osdmap; /* 1 = want, 2 = want+asked */
86 u32 have_osdmap, have_mdsmap;
87
Sage Weil039934b2009-11-12 15:05:52 -080088#ifdef CONFIG_DEBUG_FS
Sage Weilba75bb92009-10-06 11:31:11 -070089 struct dentry *debugfs_file;
Sage Weil039934b2009-11-12 15:05:52 -080090#endif
Sage Weilba75bb92009-10-06 11:31:11 -070091};
92
93extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end);
94extern int ceph_monmap_contains(struct ceph_monmap *m,
95 struct ceph_entity_addr *addr);
96
97extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
98extern void ceph_monc_stop(struct ceph_mon_client *monc);
99
100/*
101 * The model here is to indicate that we need a new map of at least
102 * epoch @want, and also call in when we receive a map. We will
103 * periodically rerequest the map from the monitor cluster until we
104 * get what we want.
105 */
106extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have);
107extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have);
108
109extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc);
110
Sage Weilba75bb92009-10-06 11:31:11 -0700111extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
112 struct ceph_statfs *buf);
113
Sage Weil4e7a5dc2009-11-18 16:19:57 -0800114extern int ceph_monc_open_session(struct ceph_mon_client *monc);
115
Sage Weil9bd2e6f2010-02-02 16:21:06 -0800116extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);
117
Sage Weilba75bb92009-10-06 11:31:11 -0700118
119
120#endif