aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/ceph/ceph_features.h27
-rw-r--r--include/linux/ceph/ceph_fs.h14
-rw-r--r--include/linux/ceph/decode.h49
-rw-r--r--include/linux/ceph/libceph.h10
-rw-r--r--include/linux/ceph/messenger.h60
-rw-r--r--include/linux/ceph/mon_client.h2
-rw-r--r--include/linux/ceph/msgpool.h3
-rw-r--r--include/linux/crush/crush.h8
8 files changed, 113 insertions, 60 deletions
diff --git a/include/linux/ceph/ceph_features.h b/include/linux/ceph/ceph_features.h
new file mode 100644
index 000000000000..dad579b0c0e6
--- /dev/null
+++ b/include/linux/ceph/ceph_features.h
@@ -0,0 +1,27 @@
1#ifndef __CEPH_FEATURES
2#define __CEPH_FEATURES
3
4/*
5 * feature bits
6 */
7#define CEPH_FEATURE_UID (1<<0)
8#define CEPH_FEATURE_NOSRCADDR (1<<1)
9#define CEPH_FEATURE_MONCLOCKCHECK (1<<2)
10#define CEPH_FEATURE_FLOCK (1<<3)
11#define CEPH_FEATURE_SUBSCRIBE2 (1<<4)
12#define CEPH_FEATURE_MONNAMES (1<<5)
13#define CEPH_FEATURE_RECONNECT_SEQ (1<<6)
14#define CEPH_FEATURE_DIRLAYOUTHASH (1<<7)
15/* bits 8-17 defined by user-space; not supported yet here */
16#define CEPH_FEATURE_CRUSH_TUNABLES (1<<18)
17
18/*
19 * Features supported.
20 */
21#define CEPH_FEATURES_SUPPORTED_DEFAULT \
22 (CEPH_FEATURE_NOSRCADDR | \
23 CEPH_FEATURE_CRUSH_TUNABLES)
24
25#define CEPH_FEATURES_REQUIRED_DEFAULT \
26 (CEPH_FEATURE_NOSRCADDR)
27#endif
diff --git a/include/linux/ceph/ceph_fs.h b/include/linux/ceph/ceph_fs.h
index e81ab30d4896..d021610efd65 100644
--- a/include/linux/ceph/ceph_fs.h
+++ b/include/linux/ceph/ceph_fs.h
@@ -35,20 +35,6 @@
35/* arbitrary limit on max # of monitors (cluster of 3 is typical) */ 35/* arbitrary limit on max # of monitors (cluster of 3 is typical) */
36#define CEPH_MAX_MON 31 36#define CEPH_MAX_MON 31
37 37
38
39/*
40 * feature bits
41 */
42#define CEPH_FEATURE_UID (1<<0)
43#define CEPH_FEATURE_NOSRCADDR (1<<1)
44#define CEPH_FEATURE_MONCLOCKCHECK (1<<2)
45#define CEPH_FEATURE_FLOCK (1<<3)
46#define CEPH_FEATURE_SUBSCRIBE2 (1<<4)
47#define CEPH_FEATURE_MONNAMES (1<<5)
48#define CEPH_FEATURE_RECONNECT_SEQ (1<<6)
49#define CEPH_FEATURE_DIRLAYOUTHASH (1<<7)
50
51
52/* 38/*
53 * ceph_file_layout - describe data layout for a file/inode 39 * ceph_file_layout - describe data layout for a file/inode
54 */ 40 */
diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h
index d8615dee5808..4bbf2db45f46 100644
--- a/include/linux/ceph/decode.h
+++ b/include/linux/ceph/decode.h
@@ -1,6 +1,7 @@
1#ifndef __CEPH_DECODE_H 1#ifndef __CEPH_DECODE_H
2#define __CEPH_DECODE_H 2#define __CEPH_DECODE_H
3 3
4#include <linux/err.h>
4#include <linux/bug.h> 5#include <linux/bug.h>
5#include <linux/time.h> 6#include <linux/time.h>
6#include <asm/unaligned.h> 7#include <asm/unaligned.h>
@@ -85,6 +86,52 @@ static inline int ceph_has_room(void **p, void *end, size_t n)
85 } while (0) 86 } while (0)
86 87
87/* 88/*
89 * Allocate a buffer big enough to hold the wire-encoded string, and
90 * decode the string into it. The resulting string will always be
91 * terminated with '\0'. If successful, *p will be advanced
92 * past the decoded data. Also, if lenp is not a null pointer, the
93 * length (not including the terminating '\0') will be recorded in
94 * *lenp. Note that a zero-length string is a valid return value.
95 *
96 * Returns a pointer to the newly-allocated string buffer, or a
97 * pointer-coded errno if an error occurs. Neither *p nor *lenp
98 * will have been updated if an error is returned.
99 *
100 * There are two possible failures:
101 * - converting the string would require accessing memory at or
102 * beyond the "end" pointer provided (-E
103 * - memory could not be allocated for the result
104 */
105static inline char *ceph_extract_encoded_string(void **p, void *end,
106 size_t *lenp, gfp_t gfp)
107{
108 u32 len;
109 void *sp = *p;
110 char *buf;
111
112 ceph_decode_32_safe(&sp, end, len, bad);
113 if (!ceph_has_room(&sp, end, len))
114 goto bad;
115
116 buf = kmalloc(len + 1, gfp);
117 if (!buf)
118 return ERR_PTR(-ENOMEM);
119
120 if (len)
121 memcpy(buf, sp, len);
122 buf[len] = '\0';
123
124 *p = (char *) *p + sizeof (u32) + len;
125 if (lenp)
126 *lenp = (size_t) len;
127
128 return buf;
129
130bad:
131 return ERR_PTR(-ERANGE);
132}
133
134/*
88 * struct ceph_timespec <-> struct timespec 135 * struct ceph_timespec <-> struct timespec
89 */ 136 */
90static inline void ceph_decode_timespec(struct timespec *ts, 137static inline void ceph_decode_timespec(struct timespec *ts,
@@ -151,7 +198,7 @@ static inline void ceph_encode_filepath(void **p, void *end,
151 u64 ino, const char *path) 198 u64 ino, const char *path)
152{ 199{
153 u32 len = path ? strlen(path) : 0; 200 u32 len = path ? strlen(path) : 0;
154 BUG_ON(*p + sizeof(ino) + sizeof(len) + len > end); 201 BUG_ON(*p + 1 + sizeof(ino) + sizeof(len) + len > end);
155 ceph_encode_8(p, 1); 202 ceph_encode_8(p, 1);
156 ceph_encode_64(p, ino); 203 ceph_encode_64(p, ino);
157 ceph_encode_32(p, len); 204 ceph_encode_32(p, len);
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
index e71d683982a6..42624789b06f 100644
--- a/include/linux/ceph/libceph.h
+++ b/include/linux/ceph/libceph.h
@@ -23,12 +23,6 @@
23#include "ceph_fs.h" 23#include "ceph_fs.h"
24 24
25/* 25/*
26 * Supported features
27 */
28#define CEPH_FEATURE_SUPPORTED_DEFAULT CEPH_FEATURE_NOSRCADDR
29#define CEPH_FEATURE_REQUIRED_DEFAULT CEPH_FEATURE_NOSRCADDR
30
31/*
32 * mount options 26 * mount options
33 */ 27 */
34#define CEPH_OPT_FSID (1<<0) 28#define CEPH_OPT_FSID (1<<0)
@@ -132,7 +126,7 @@ struct ceph_client {
132 u32 supported_features; 126 u32 supported_features;
133 u32 required_features; 127 u32 required_features;
134 128
135 struct ceph_messenger *msgr; /* messenger instance */ 129 struct ceph_messenger msgr; /* messenger instance */
136 struct ceph_mon_client monc; 130 struct ceph_mon_client monc;
137 struct ceph_osd_client osdc; 131 struct ceph_osd_client osdc;
138 132
@@ -160,7 +154,7 @@ struct ceph_client {
160struct ceph_snap_context { 154struct ceph_snap_context {
161 atomic_t nref; 155 atomic_t nref;
162 u64 seq; 156 u64 seq;
163 int num_snaps; 157 u32 num_snaps;
164 u64 snaps[]; 158 u64 snaps[];
165}; 159};
166 160
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index 44c87e731e9d..189ae0637634 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -31,9 +31,6 @@ struct ceph_connection_operations {
31 int (*verify_authorizer_reply) (struct ceph_connection *con, int len); 31 int (*verify_authorizer_reply) (struct ceph_connection *con, int len);
32 int (*invalidate_authorizer)(struct ceph_connection *con); 32 int (*invalidate_authorizer)(struct ceph_connection *con);
33 33
34 /* protocol version mismatch */
35 void (*bad_proto) (struct ceph_connection *con);
36
37 /* there was some error on the socket (disconnect, whatever) */ 34 /* there was some error on the socket (disconnect, whatever) */
38 void (*fault) (struct ceph_connection *con); 35 void (*fault) (struct ceph_connection *con);
39 36
@@ -53,6 +50,7 @@ struct ceph_messenger {
53 struct ceph_entity_inst inst; /* my name+address */ 50 struct ceph_entity_inst inst; /* my name+address */
54 struct ceph_entity_addr my_enc_addr; 51 struct ceph_entity_addr my_enc_addr;
55 52
53 atomic_t stopping;
56 bool nocrc; 54 bool nocrc;
57 55
58 /* 56 /*
@@ -80,7 +78,10 @@ struct ceph_msg {
80 unsigned nr_pages; /* size of page array */ 78 unsigned nr_pages; /* size of page array */
81 unsigned page_alignment; /* io offset in first page */ 79 unsigned page_alignment; /* io offset in first page */
82 struct ceph_pagelist *pagelist; /* instead of pages */ 80 struct ceph_pagelist *pagelist; /* instead of pages */
81
82 struct ceph_connection *con;
83 struct list_head list_head; 83 struct list_head list_head;
84
84 struct kref kref; 85 struct kref kref;
85 struct bio *bio; /* instead of pages/pagelist */ 86 struct bio *bio; /* instead of pages/pagelist */
86 struct bio *bio_iter; /* bio iterator */ 87 struct bio *bio_iter; /* bio iterator */
@@ -106,23 +107,6 @@ struct ceph_msg_pos {
106#define MAX_DELAY_INTERVAL (5 * 60 * HZ) 107#define MAX_DELAY_INTERVAL (5 * 60 * HZ)
107 108
108/* 109/*
109 * ceph_connection state bit flags
110 */
111#define LOSSYTX 0 /* we can close channel or drop messages on errors */
112#define CONNECTING 1
113#define NEGOTIATING 2
114#define KEEPALIVE_PENDING 3
115#define WRITE_PENDING 4 /* we have data ready to send */
116#define STANDBY 8 /* no outgoing messages, socket closed. we keep
117 * the ceph_connection around to maintain shared
118 * state with the peer. */
119#define CLOSED 10 /* we've closed the connection */
120#define SOCK_CLOSED 11 /* socket state changed to closed */
121#define OPENING 13 /* open connection w/ (possibly new) peer */
122#define DEAD 14 /* dead, about to kfree */
123#define BACKOFF 15
124
125/*
126 * A single connection with another host. 110 * A single connection with another host.
127 * 111 *
128 * We maintain a queue of outgoing messages, and some session state to 112 * We maintain a queue of outgoing messages, and some session state to
@@ -131,18 +115,22 @@ struct ceph_msg_pos {
131 */ 115 */
132struct ceph_connection { 116struct ceph_connection {
133 void *private; 117 void *private;
134 atomic_t nref;
135 118
136 const struct ceph_connection_operations *ops; 119 const struct ceph_connection_operations *ops;
137 120
138 struct ceph_messenger *msgr; 121 struct ceph_messenger *msgr;
122
123 atomic_t sock_state;
139 struct socket *sock; 124 struct socket *sock;
140 unsigned long state; /* connection state (see flags above) */ 125 struct ceph_entity_addr peer_addr; /* peer address */
126 struct ceph_entity_addr peer_addr_for_me;
127
128 unsigned long flags;
129 unsigned long state;
141 const char *error_msg; /* error message, if any */ 130 const char *error_msg; /* error message, if any */
142 131
143 struct ceph_entity_addr peer_addr; /* peer address */
144 struct ceph_entity_name peer_name; /* peer name */ 132 struct ceph_entity_name peer_name; /* peer name */
145 struct ceph_entity_addr peer_addr_for_me; 133
146 unsigned peer_features; 134 unsigned peer_features;
147 u32 connect_seq; /* identify the most recent connection 135 u32 connect_seq; /* identify the most recent connection
148 attempt for this connection, client */ 136 attempt for this connection, client */
@@ -207,24 +195,26 @@ extern int ceph_msgr_init(void);
207extern void ceph_msgr_exit(void); 195extern void ceph_msgr_exit(void);
208extern void ceph_msgr_flush(void); 196extern void ceph_msgr_flush(void);
209 197
210extern struct ceph_messenger *ceph_messenger_create( 198extern void ceph_messenger_init(struct ceph_messenger *msgr,
211 struct ceph_entity_addr *myaddr, 199 struct ceph_entity_addr *myaddr,
212 u32 features, u32 required); 200 u32 supported_features,
213extern void ceph_messenger_destroy(struct ceph_messenger *); 201 u32 required_features,
202 bool nocrc);
214 203
215extern void ceph_con_init(struct ceph_messenger *msgr, 204extern void ceph_con_init(struct ceph_connection *con, void *private,
216 struct ceph_connection *con); 205 const struct ceph_connection_operations *ops,
206 struct ceph_messenger *msgr);
217extern void ceph_con_open(struct ceph_connection *con, 207extern void ceph_con_open(struct ceph_connection *con,
208 __u8 entity_type, __u64 entity_num,
218 struct ceph_entity_addr *addr); 209 struct ceph_entity_addr *addr);
219extern bool ceph_con_opened(struct ceph_connection *con); 210extern bool ceph_con_opened(struct ceph_connection *con);
220extern void ceph_con_close(struct ceph_connection *con); 211extern void ceph_con_close(struct ceph_connection *con);
221extern void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg); 212extern void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg);
222extern void ceph_con_revoke(struct ceph_connection *con, struct ceph_msg *msg); 213
223extern void ceph_con_revoke_message(struct ceph_connection *con, 214extern void ceph_msg_revoke(struct ceph_msg *msg);
224 struct ceph_msg *msg); 215extern void ceph_msg_revoke_incoming(struct ceph_msg *msg);
216
225extern void ceph_con_keepalive(struct ceph_connection *con); 217extern void ceph_con_keepalive(struct ceph_connection *con);
226extern struct ceph_connection *ceph_con_get(struct ceph_connection *con);
227extern void ceph_con_put(struct ceph_connection *con);
228 218
229extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags, 219extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
230 bool can_fail); 220 bool can_fail);
diff --git a/include/linux/ceph/mon_client.h b/include/linux/ceph/mon_client.h
index 545f85917780..2113e3850a4e 100644
--- a/include/linux/ceph/mon_client.h
+++ b/include/linux/ceph/mon_client.h
@@ -70,7 +70,7 @@ struct ceph_mon_client {
70 bool hunting; 70 bool hunting;
71 int cur_mon; /* last monitor i contacted */ 71 int cur_mon; /* last monitor i contacted */
72 unsigned long sub_sent, sub_renew_after; 72 unsigned long sub_sent, sub_renew_after;
73 struct ceph_connection *con; 73 struct ceph_connection con;
74 bool have_fsid; 74 bool have_fsid;
75 75
76 /* pending generic requests */ 76 /* pending generic requests */
diff --git a/include/linux/ceph/msgpool.h b/include/linux/ceph/msgpool.h
index a362605f9368..09fa96b43436 100644
--- a/include/linux/ceph/msgpool.h
+++ b/include/linux/ceph/msgpool.h
@@ -11,10 +11,11 @@
11struct ceph_msgpool { 11struct ceph_msgpool {
12 const char *name; 12 const char *name;
13 mempool_t *pool; 13 mempool_t *pool;
14 int type; /* preallocated message type */
14 int front_len; /* preallocated payload size */ 15 int front_len; /* preallocated payload size */
15}; 16};
16 17
17extern int ceph_msgpool_init(struct ceph_msgpool *pool, 18extern int ceph_msgpool_init(struct ceph_msgpool *pool, int type,
18 int front_len, int size, bool blocking, 19 int front_len, int size, bool blocking,
19 const char *name); 20 const char *name);
20extern void ceph_msgpool_destroy(struct ceph_msgpool *pool); 21extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
diff --git a/include/linux/crush/crush.h b/include/linux/crush/crush.h
index 7c4750811b96..25baa287cff7 100644
--- a/include/linux/crush/crush.h
+++ b/include/linux/crush/crush.h
@@ -154,6 +154,14 @@ struct crush_map {
154 __s32 max_buckets; 154 __s32 max_buckets;
155 __u32 max_rules; 155 __u32 max_rules;
156 __s32 max_devices; 156 __s32 max_devices;
157
158 /* choose local retries before re-descent */
159 __u32 choose_local_tries;
160 /* choose local attempts using a fallback permutation before
161 * re-descent */
162 __u32 choose_local_fallback_tries;
163 /* choose attempts before giving up */
164 __u32 choose_total_tries;
157}; 165};
158 166
159 167