blob: c75b53302ecce568c08bcd4c70af5faae483f8c7 [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>
5#include <linux/radix-tree.h>
6
7#include "messenger.h"
8#include "msgpool.h"
9
10struct ceph_client;
11struct ceph_mount_args;
Sage Weil4e7a5dc2009-11-18 16:19:57 -080012struct ceph_auth_client;
Sage Weilba75bb92009-10-06 11:31:11 -070013
14/*
15 * The monitor map enumerates the set of all monitors.
16 */
17struct ceph_monmap {
18 struct ceph_fsid fsid;
19 u32 epoch;
20 u32 num_mon;
21 struct ceph_entity_inst mon_inst[0];
22};
23
24struct ceph_mon_client;
25struct ceph_mon_statfs_request;
26
27
28/*
29 * Generic mechanism for resending monitor requests.
30 */
31typedef void (*ceph_monc_request_func_t)(struct ceph_mon_client *monc,
32 int newmon);
33
34/* a pending monitor request */
35struct ceph_mon_request {
36 struct ceph_mon_client *monc;
37 struct delayed_work delayed_work;
38 unsigned long delay;
39 ceph_monc_request_func_t do_request;
40};
41
42/*
43 * statfs() is done a bit differently because we need to get data back
44 * to the caller
45 */
46struct ceph_mon_statfs_request {
47 u64 tid;
48 int result;
49 struct ceph_statfs *buf;
50 struct completion completion;
51 unsigned long last_attempt, delay; /* jiffies */
52 struct ceph_msg *request; /* original request */
53};
54
55struct ceph_mon_client {
56 struct ceph_client *client;
57 struct ceph_monmap *monmap;
58
59 struct mutex mutex;
60 struct delayed_work delayed_work;
61
Sage Weil4e7a5dc2009-11-18 16:19:57 -080062 struct ceph_auth_client *auth;
63 struct ceph_msg *m_auth;
64
Sage Weilba75bb92009-10-06 11:31:11 -070065 bool hunting;
66 int cur_mon; /* last monitor i contacted */
67 unsigned long sub_sent, sub_renew_after;
68 struct ceph_connection *con;
Sage Weil4e7a5dc2009-11-18 16:19:57 -080069 bool have_fsid;
Sage Weilba75bb92009-10-06 11:31:11 -070070
71 /* msg pools */
Sage Weilba75bb92009-10-06 11:31:11 -070072 struct ceph_msgpool msgpool_subscribe_ack;
73 struct ceph_msgpool msgpool_statfs_reply;
Sage Weil4e7a5dc2009-11-18 16:19:57 -080074 struct ceph_msgpool msgpool_auth_reply;
Sage Weilba75bb92009-10-06 11:31:11 -070075
76 /* pending statfs requests */
77 struct radix_tree_root statfs_request_tree;
78 int num_statfs_requests;
79 u64 last_tid;
80
Sage Weil4e7a5dc2009-11-18 16:19:57 -080081 /* mds/osd map */
Sage Weilba75bb92009-10-06 11:31:11 -070082 int want_next_osdmap; /* 1 = want, 2 = want+asked */
83 u32 have_osdmap, have_mdsmap;
84
Sage Weil039934b2009-11-12 15:05:52 -080085#ifdef CONFIG_DEBUG_FS
Sage Weilba75bb92009-10-06 11:31:11 -070086 struct dentry *debugfs_file;
Sage Weil039934b2009-11-12 15:05:52 -080087#endif
Sage Weilba75bb92009-10-06 11:31:11 -070088};
89
90extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end);
91extern int ceph_monmap_contains(struct ceph_monmap *m,
92 struct ceph_entity_addr *addr);
93
94extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
95extern void ceph_monc_stop(struct ceph_mon_client *monc);
96
97/*
98 * The model here is to indicate that we need a new map of at least
99 * epoch @want, and also call in when we receive a map. We will
100 * periodically rerequest the map from the monitor cluster until we
101 * get what we want.
102 */
103extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have);
104extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have);
105
106extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc);
107
Sage Weilba75bb92009-10-06 11:31:11 -0700108extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
109 struct ceph_statfs *buf);
110
Sage Weil4e7a5dc2009-11-18 16:19:57 -0800111extern int ceph_monc_open_session(struct ceph_mon_client *monc);
112
Sage Weilba75bb92009-10-06 11:31:11 -0700113
114
115#endif