Blame view

include/linux/ceph/mon_client.h 3.08 KB
ba75bb98c   Sage Weil   ceph: monitor client
1
2
3
4
  #ifndef _FS_CEPH_MON_CLIENT_H
  #define _FS_CEPH_MON_CLIENT_H
  
  #include <linux/completion.h>
3143edd3a   Sage Weil   ceph: clean up st...
5
  #include <linux/kref.h>
85ff03f6b   Sage Weil   ceph: use rbtree ...
6
  #include <linux/rbtree.h>
ba75bb98c   Sage Weil   ceph: monitor client
7
8
  
  #include "messenger.h"
ba75bb98c   Sage Weil   ceph: monitor client
9
10
11
  
  struct ceph_client;
  struct ceph_mount_args;
4e7a5dcd1   Sage Weil   ceph: negotiate a...
12
  struct ceph_auth_client;
ba75bb98c   Sage Weil   ceph: monitor client
13
14
15
16
17
18
19
20
21
22
23
24
  
  /*
   * 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;
f8c76f6f2   Yehuda Sadeh   ceph: make mon cl...
25
  struct ceph_mon_generic_request;
ba75bb98c   Sage Weil   ceph: monitor client
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  
  
  /*
   * 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;
  };
  
  /*
f8c76f6f2   Yehuda Sadeh   ceph: make mon cl...
43
44
   * 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
ba75bb98c   Sage Weil   ceph: monitor client
45
46
   * to the caller
   */
f8c76f6f2   Yehuda Sadeh   ceph: make mon cl...
47
  struct ceph_mon_generic_request {
3143edd3a   Sage Weil   ceph: clean up st...
48
  	struct kref kref;
ba75bb98c   Sage Weil   ceph: monitor client
49
  	u64 tid;
85ff03f6b   Sage Weil   ceph: use rbtree ...
50
  	struct rb_node node;
ba75bb98c   Sage Weil   ceph: monitor client
51
  	int result;
f8c76f6f2   Yehuda Sadeh   ceph: make mon cl...
52
  	void *buf;
e56fa10e9   Yehuda Sadeh   ceph: generalize ...
53
  	int buf_len;
ba75bb98c   Sage Weil   ceph: monitor client
54
  	struct completion completion;
ba75bb98c   Sage Weil   ceph: monitor client
55
  	struct ceph_msg *request;  /* original request */
3143edd3a   Sage Weil   ceph: clean up st...
56
  	struct ceph_msg *reply;    /* and reply */
ba75bb98c   Sage Weil   ceph: monitor client
57
58
59
60
61
62
63
64
  };
  
  struct ceph_mon_client {
  	struct ceph_client *client;
  	struct ceph_monmap *monmap;
  
  	struct mutex mutex;
  	struct delayed_work delayed_work;
4e7a5dcd1   Sage Weil   ceph: negotiate a...
65
  	struct ceph_auth_client *auth;
240ed68eb   Sage Weil   ceph: reuse mon s...
66
  	struct ceph_msg *m_auth, *m_auth_reply, *m_subscribe, *m_subscribe_ack;
9bd2e6f8b   Sage Weil   ceph: allow renew...
67
  	int pending_auth;
4e7a5dcd1   Sage Weil   ceph: negotiate a...
68

ba75bb98c   Sage Weil   ceph: monitor client
69
70
71
72
  	bool hunting;
  	int cur_mon;                       /* last monitor i contacted */
  	unsigned long sub_sent, sub_renew_after;
  	struct ceph_connection *con;
4e7a5dcd1   Sage Weil   ceph: negotiate a...
73
  	bool have_fsid;
ba75bb98c   Sage Weil   ceph: monitor client
74

f8c76f6f2   Yehuda Sadeh   ceph: make mon cl...
75
76
77
  	/* pending generic requests */
  	struct rb_root generic_request_tree;
  	int num_generic_requests;
ba75bb98c   Sage Weil   ceph: monitor client
78
  	u64 last_tid;
4e7a5dcd1   Sage Weil   ceph: negotiate a...
79
  	/* mds/osd map */
3d14c5d2b   Yehuda Sadeh   ceph: factor out ...
80
  	int want_mdsmap;
ba75bb98c   Sage Weil   ceph: monitor client
81
82
  	int want_next_osdmap; /* 1 = want, 2 = want+asked */
  	u32 have_osdmap, have_mdsmap;
039934b89   Sage Weil   ceph: build clean...
83
  #ifdef CONFIG_DEBUG_FS
ba75bb98c   Sage Weil   ceph: monitor client
84
  	struct dentry *debugfs_file;
039934b89   Sage Weil   ceph: build clean...
85
  #endif
ba75bb98c   Sage Weil   ceph: monitor client
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  };
  
  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);
ba75bb98c   Sage Weil   ceph: monitor client
105
106
  extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
  			       struct ceph_statfs *buf);
4e7a5dcd1   Sage Weil   ceph: negotiate a...
107
  extern int ceph_monc_open_session(struct ceph_mon_client *monc);
9bd2e6f8b   Sage Weil   ceph: allow renew...
108
  extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);
e56fa10e9   Yehuda Sadeh   ceph: generalize ...
109
110
  extern int ceph_monc_create_snapid(struct ceph_mon_client *monc,
  				   u32 pool, u64 *snapid);
ba75bb98c   Sage Weil   ceph: monitor client
111

e56fa10e9   Yehuda Sadeh   ceph: generalize ...
112
113
  extern int ceph_monc_delete_snapid(struct ceph_mon_client *monc,
  				   u32 pool, u64 snapid);
ba75bb98c   Sage Weil   ceph: monitor client
114
115
  
  #endif