blob: 1deb29af82fd2b10a2b578c4a11c362fa83d4ecf [file] [log] [blame]
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -07001
2#include <linux/ceph/ceph_debug.h>
3#include <linux/backing-dev.h>
4#include <linux/ctype.h>
5#include <linux/fs.h>
6#include <linux/inet.h>
7#include <linux/in6.h>
Tommi Virtanene2c3d292011-03-25 16:40:48 -07008#include <linux/key.h>
Tommi Virtanen4b2a58a2011-03-28 14:59:38 -07009#include <keys/ceph-type.h>
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -070010#include <linux/module.h>
11#include <linux/mount.h>
12#include <linux/parser.h>
13#include <linux/sched.h>
14#include <linux/seq_file.h>
15#include <linux/slab.h>
16#include <linux/statfs.h>
17#include <linux/string.h>
Eric W. Biedermaneea553c2013-01-31 02:09:50 -080018#include <linux/nsproxy.h>
19#include <net/net_namespace.h>
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -070020
21
Sage Weil1fe60e52012-07-30 16:23:22 -070022#include <linux/ceph/ceph_features.h>
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -070023#include <linux/ceph/libceph.h>
24#include <linux/ceph/debugfs.h>
25#include <linux/ceph/decode.h>
26#include <linux/ceph/mon_client.h>
27#include <linux/ceph/auth.h>
Tommi Virtanen8323c3a2011-03-25 16:32:57 -070028#include "crypto.h"
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -070029
30
31
32/*
33 * find filename portion of a path (/foo/bar/baz -> baz)
34 */
35const char *ceph_file_part(const char *s, int len)
36{
37 const char *e = s + len;
38
39 while (e != s && *(e-1) != '/')
40 e--;
41 return e;
42}
43EXPORT_SYMBOL(ceph_file_part);
44
45const char *ceph_msg_type_name(int type)
46{
47 switch (type) {
48 case CEPH_MSG_SHUTDOWN: return "shutdown";
49 case CEPH_MSG_PING: return "ping";
50 case CEPH_MSG_AUTH: return "auth";
51 case CEPH_MSG_AUTH_REPLY: return "auth_reply";
52 case CEPH_MSG_MON_MAP: return "mon_map";
53 case CEPH_MSG_MON_GET_MAP: return "mon_get_map";
54 case CEPH_MSG_MON_SUBSCRIBE: return "mon_subscribe";
55 case CEPH_MSG_MON_SUBSCRIBE_ACK: return "mon_subscribe_ack";
56 case CEPH_MSG_STATFS: return "statfs";
57 case CEPH_MSG_STATFS_REPLY: return "statfs_reply";
58 case CEPH_MSG_MDS_MAP: return "mds_map";
59 case CEPH_MSG_CLIENT_SESSION: return "client_session";
60 case CEPH_MSG_CLIENT_RECONNECT: return "client_reconnect";
61 case CEPH_MSG_CLIENT_REQUEST: return "client_request";
62 case CEPH_MSG_CLIENT_REQUEST_FORWARD: return "client_request_forward";
63 case CEPH_MSG_CLIENT_REPLY: return "client_reply";
64 case CEPH_MSG_CLIENT_CAPS: return "client_caps";
65 case CEPH_MSG_CLIENT_CAPRELEASE: return "client_cap_release";
66 case CEPH_MSG_CLIENT_SNAP: return "client_snap";
67 case CEPH_MSG_CLIENT_LEASE: return "client_lease";
68 case CEPH_MSG_OSD_MAP: return "osd_map";
69 case CEPH_MSG_OSD_OP: return "osd_op";
70 case CEPH_MSG_OSD_OPREPLY: return "osd_opreply";
Yehuda Sadeha40c4f12011-03-21 15:07:16 -070071 case CEPH_MSG_WATCH_NOTIFY: return "watch_notify";
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -070072 default: return "unknown";
73 }
74}
75EXPORT_SYMBOL(ceph_msg_type_name);
76
77/*
78 * Initially learn our fsid, or verify an fsid matches.
79 */
80int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid)
81{
82 if (client->have_fsid) {
83 if (ceph_fsid_compare(&client->fsid, fsid)) {
84 pr_err("bad fsid, had %pU got %pU",
85 &client->fsid, fsid);
86 return -1;
87 }
88 } else {
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -070089 memcpy(&client->fsid, fsid, sizeof(*fsid));
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -070090 }
91 return 0;
92}
93EXPORT_SYMBOL(ceph_check_fsid);
94
95static int strcmp_null(const char *s1, const char *s2)
96{
97 if (!s1 && !s2)
98 return 0;
99 if (s1 && !s2)
100 return -1;
101 if (!s1 && s2)
102 return 1;
103 return strcmp(s1, s2);
104}
105
106int ceph_compare_options(struct ceph_options *new_opt,
107 struct ceph_client *client)
108{
109 struct ceph_options *opt1 = new_opt;
110 struct ceph_options *opt2 = client->options;
111 int ofs = offsetof(struct ceph_options, mon_addr);
112 int i;
113 int ret;
114
115 ret = memcmp(opt1, opt2, ofs);
116 if (ret)
117 return ret;
118
119 ret = strcmp_null(opt1->name, opt2->name);
120 if (ret)
121 return ret;
122
Tommi Virtanen8323c3a2011-03-25 16:32:57 -0700123 if (opt1->key && !opt2->key)
124 return -1;
125 if (!opt1->key && opt2->key)
126 return 1;
127 if (opt1->key && opt2->key) {
128 if (opt1->key->type != opt2->key->type)
129 return -1;
130 if (opt1->key->created.tv_sec != opt2->key->created.tv_sec)
131 return -1;
132 if (opt1->key->created.tv_nsec != opt2->key->created.tv_nsec)
133 return -1;
134 if (opt1->key->len != opt2->key->len)
135 return -1;
136 if (opt1->key->key && !opt2->key->key)
137 return -1;
138 if (!opt1->key->key && opt2->key->key)
139 return 1;
140 if (opt1->key->key && opt2->key->key) {
141 ret = memcmp(opt1->key->key, opt2->key->key, opt1->key->len);
142 if (ret)
143 return ret;
144 }
145 }
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700146
147 /* any matching mon ip implies a match */
148 for (i = 0; i < opt1->num_mon; i++) {
149 if (ceph_monmap_contains(client->monc.monmap,
150 &opt1->mon_addr[i]))
151 return 0;
152 }
153 return -1;
154}
155EXPORT_SYMBOL(ceph_compare_options);
156
157
158static int parse_fsid(const char *str, struct ceph_fsid *fsid)
159{
160 int i = 0;
161 char tmp[3];
162 int err = -EINVAL;
163 int d;
164
165 dout("parse_fsid '%s'\n", str);
166 tmp[2] = 0;
167 while (*str && i < 16) {
168 if (ispunct(*str)) {
169 str++;
170 continue;
171 }
172 if (!isxdigit(str[0]) || !isxdigit(str[1]))
173 break;
174 tmp[0] = str[0];
175 tmp[1] = str[1];
176 if (sscanf(tmp, "%x", &d) < 1)
177 break;
178 fsid->fsid[i] = d & 0xff;
179 i++;
180 str += 2;
181 }
182
183 if (i == 16)
184 err = 0;
185 dout("parse_fsid ret %d got fsid %pU", err, fsid);
186 return err;
187}
188
189/*
190 * ceph options
191 */
192enum {
193 Opt_osdtimeout,
194 Opt_osdkeepalivetimeout,
195 Opt_mount_timeout,
196 Opt_osd_idle_ttl,
197 Opt_last_int,
198 /* int args above */
199 Opt_fsid,
200 Opt_name,
201 Opt_secret,
Tommi Virtanene2c3d292011-03-25 16:40:48 -0700202 Opt_key,
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700203 Opt_ip,
204 Opt_last_string,
205 /* string args above */
Alex Eldercffaba12012-02-15 07:43:54 -0600206 Opt_share,
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700207 Opt_noshare,
Alex Eldercffaba12012-02-15 07:43:54 -0600208 Opt_crc,
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700209 Opt_nocrc,
210};
211
212static match_table_t opt_tokens = {
213 {Opt_osdtimeout, "osdtimeout=%d"},
214 {Opt_osdkeepalivetimeout, "osdkeepalive=%d"},
215 {Opt_mount_timeout, "mount_timeout=%d"},
216 {Opt_osd_idle_ttl, "osd_idle_ttl=%d"},
217 /* int args above */
218 {Opt_fsid, "fsid=%s"},
219 {Opt_name, "name=%s"},
220 {Opt_secret, "secret=%s"},
Tommi Virtanene2c3d292011-03-25 16:40:48 -0700221 {Opt_key, "key=%s"},
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700222 {Opt_ip, "ip=%s"},
223 /* string args above */
Alex Eldercffaba12012-02-15 07:43:54 -0600224 {Opt_share, "share"},
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700225 {Opt_noshare, "noshare"},
Alex Eldercffaba12012-02-15 07:43:54 -0600226 {Opt_crc, "crc"},
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700227 {Opt_nocrc, "nocrc"},
228 {-1, NULL}
229};
230
231void ceph_destroy_options(struct ceph_options *opt)
232{
233 dout("destroy_options %p\n", opt);
234 kfree(opt->name);
Tommi Virtanen8323c3a2011-03-25 16:32:57 -0700235 if (opt->key) {
236 ceph_crypto_key_destroy(opt->key);
237 kfree(opt->key);
238 }
Noah Watkins1cad7892011-09-12 14:51:53 -0700239 kfree(opt->mon_addr);
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700240 kfree(opt);
241}
242EXPORT_SYMBOL(ceph_destroy_options);
243
Tommi Virtanene2c3d292011-03-25 16:40:48 -0700244/* get secret from key store */
245static int get_secret(struct ceph_crypto_key *dst, const char *name) {
246 struct key *ukey;
247 int key_err;
248 int err = 0;
Tommi Virtanen4b2a58a2011-03-28 14:59:38 -0700249 struct ceph_crypto_key *ckey;
Tommi Virtanene2c3d292011-03-25 16:40:48 -0700250
Tommi Virtanen4b2a58a2011-03-28 14:59:38 -0700251 ukey = request_key(&key_type_ceph, name, NULL);
Tommi Virtanene2c3d292011-03-25 16:40:48 -0700252 if (!ukey || IS_ERR(ukey)) {
253 /* request_key errors don't map nicely to mount(2)
254 errors; don't even try, but still printk */
255 key_err = PTR_ERR(ukey);
256 switch (key_err) {
257 case -ENOKEY:
258 pr_warning("ceph: Mount failed due to key not found: %s\n", name);
259 break;
260 case -EKEYEXPIRED:
261 pr_warning("ceph: Mount failed due to expired key: %s\n", name);
262 break;
263 case -EKEYREVOKED:
264 pr_warning("ceph: Mount failed due to revoked key: %s\n", name);
265 break;
266 default:
267 pr_warning("ceph: Mount failed due to unknown key error"
268 " %d: %s\n", key_err, name);
269 }
270 err = -EPERM;
271 goto out;
272 }
273
Tommi Virtanen4b2a58a2011-03-28 14:59:38 -0700274 ckey = ukey->payload.data;
275 err = ceph_crypto_key_clone(dst, ckey);
Tommi Virtanene2c3d292011-03-25 16:40:48 -0700276 if (err)
277 goto out_key;
278 /* pass through, err is 0 */
279
280out_key:
281 key_put(ukey);
282out:
283 return err;
284}
285
Alex Elderee577412012-01-24 10:08:36 -0600286struct ceph_options *
287ceph_parse_options(char *options, const char *dev_name,
288 const char *dev_name_end,
289 int (*parse_extra_token)(char *c, void *private),
290 void *private)
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700291{
292 struct ceph_options *opt;
293 const char *c;
294 int err = -ENOMEM;
295 substring_t argstr[MAX_OPT_ARGS];
296
Eric W. Biedermaneea553c2013-01-31 02:09:50 -0800297 if (current->nsproxy->net_ns != &init_net)
298 return ERR_PTR(-EINVAL);
299
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700300 opt = kzalloc(sizeof(*opt), GFP_KERNEL);
301 if (!opt)
Alex Elderee577412012-01-24 10:08:36 -0600302 return ERR_PTR(-ENOMEM);
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700303 opt->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*opt->mon_addr),
304 GFP_KERNEL);
305 if (!opt->mon_addr)
306 goto out;
307
308 dout("parse_options %p options '%s' dev_name '%s'\n", opt, options,
309 dev_name);
310
311 /* start with defaults */
312 opt->flags = CEPH_OPT_DEFAULT;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700313 opt->osd_keepalive_timeout = CEPH_OSD_KEEPALIVE_DEFAULT;
314 opt->mount_timeout = CEPH_MOUNT_TIMEOUT_DEFAULT; /* seconds */
315 opt->osd_idle_ttl = CEPH_OSD_IDLE_TTL_DEFAULT; /* seconds */
316
317 /* get mon ip(s) */
318 /* ip1[:port1][,ip2[:port2]...] */
319 err = ceph_parse_ips(dev_name, dev_name_end, opt->mon_addr,
320 CEPH_MAX_MON, &opt->num_mon);
321 if (err < 0)
322 goto out;
323
324 /* parse mount options */
325 while ((c = strsep(&options, ",")) != NULL) {
326 int token, intval, ret;
327 if (!*c)
328 continue;
329 err = -EINVAL;
330 token = match_token((char *)c, opt_tokens, argstr);
Yehuda Sadeh010e3b42010-09-30 11:58:31 -0700331 if (token < 0 && parse_extra_token) {
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700332 /* extra? */
333 err = parse_extra_token((char *)c, private);
334 if (err < 0) {
335 pr_err("bad option at '%s'\n", c);
336 goto out;
337 }
338 continue;
339 }
340 if (token < Opt_last_int) {
341 ret = match_int(&argstr[0], &intval);
342 if (ret < 0) {
343 pr_err("bad mount option arg (not int) "
344 "at '%s'\n", c);
345 continue;
346 }
347 dout("got int token %d val %d\n", token, intval);
348 } else if (token > Opt_last_int && token < Opt_last_string) {
349 dout("got string token %d val %s\n", token,
350 argstr[0].from);
351 } else {
352 dout("got token %d\n", token);
353 }
354 switch (token) {
355 case Opt_ip:
356 err = ceph_parse_ips(argstr[0].from,
357 argstr[0].to,
358 &opt->my_addr,
359 1, NULL);
360 if (err < 0)
361 goto out;
362 opt->flags |= CEPH_OPT_MYIP;
363 break;
364
365 case Opt_fsid:
366 err = parse_fsid(argstr[0].from, &opt->fsid);
367 if (err == 0)
368 opt->flags |= CEPH_OPT_FSID;
369 break;
370 case Opt_name:
371 opt->name = kstrndup(argstr[0].from,
372 argstr[0].to-argstr[0].from,
373 GFP_KERNEL);
374 break;
375 case Opt_secret:
Tommi Virtanen8323c3a2011-03-25 16:32:57 -0700376 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
377 if (!opt->key) {
378 err = -ENOMEM;
379 goto out;
380 }
381 err = ceph_crypto_key_unarmor(opt->key, argstr[0].from);
382 if (err < 0)
383 goto out;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700384 break;
Tommi Virtanene2c3d292011-03-25 16:40:48 -0700385 case Opt_key:
386 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
387 if (!opt->key) {
388 err = -ENOMEM;
389 goto out;
390 }
391 err = get_secret(opt->key, argstr[0].from);
392 if (err < 0)
393 goto out;
394 break;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700395
396 /* misc */
397 case Opt_osdtimeout:
Sage Weil83aff952012-11-28 12:28:24 -0800398 pr_warning("ignoring deprecated osdtimeout option\n");
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700399 break;
400 case Opt_osdkeepalivetimeout:
401 opt->osd_keepalive_timeout = intval;
402 break;
403 case Opt_osd_idle_ttl:
404 opt->osd_idle_ttl = intval;
405 break;
406 case Opt_mount_timeout:
407 opt->mount_timeout = intval;
408 break;
409
Alex Eldercffaba12012-02-15 07:43:54 -0600410 case Opt_share:
411 opt->flags &= ~CEPH_OPT_NOSHARE;
412 break;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700413 case Opt_noshare:
414 opt->flags |= CEPH_OPT_NOSHARE;
415 break;
416
Alex Eldercffaba12012-02-15 07:43:54 -0600417 case Opt_crc:
418 opt->flags &= ~CEPH_OPT_NOCRC;
419 break;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700420 case Opt_nocrc:
421 opt->flags |= CEPH_OPT_NOCRC;
422 break;
423
424 default:
425 BUG_ON(token);
426 }
427 }
428
429 /* success */
Alex Elderee577412012-01-24 10:08:36 -0600430 return opt;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700431
432out:
433 ceph_destroy_options(opt);
Alex Elderee577412012-01-24 10:08:36 -0600434 return ERR_PTR(err);
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700435}
436EXPORT_SYMBOL(ceph_parse_options);
437
438u64 ceph_client_id(struct ceph_client *client)
439{
440 return client->monc.auth->global_id;
441}
442EXPORT_SYMBOL(ceph_client_id);
443
444/*
445 * create a fresh client instance
446 */
Sage Weil6ab00d42011-08-09 09:41:59 -0700447struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private,
Eric Dumazet95c96172012-04-15 05:58:06 +0000448 unsigned int supported_features,
449 unsigned int required_features)
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700450{
451 struct ceph_client *client;
Sage Weil6ab00d42011-08-09 09:41:59 -0700452 struct ceph_entity_addr *myaddr = NULL;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700453 int err = -ENOMEM;
454
455 client = kzalloc(sizeof(*client), GFP_KERNEL);
456 if (client == NULL)
457 return ERR_PTR(-ENOMEM);
458
459 client->private = private;
460 client->options = opt;
461
462 mutex_init(&client->mount_mutex);
463 init_waitqueue_head(&client->auth_wq);
464 client->auth_err = 0;
465
466 client->extra_mon_dispatch = NULL;
Sage Weil1fe60e52012-07-30 16:23:22 -0700467 client->supported_features = CEPH_FEATURES_SUPPORTED_DEFAULT |
Sage Weil6ab00d42011-08-09 09:41:59 -0700468 supported_features;
Sage Weil1fe60e52012-07-30 16:23:22 -0700469 client->required_features = CEPH_FEATURES_REQUIRED_DEFAULT |
Sage Weil6ab00d42011-08-09 09:41:59 -0700470 required_features;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700471
Sage Weil6ab00d42011-08-09 09:41:59 -0700472 /* msgr */
473 if (ceph_test_opt(client, MYIP))
474 myaddr = &client->options->my_addr;
Alex Elder15d98822012-05-26 23:26:43 -0500475 ceph_messenger_init(&client->msgr, myaddr,
476 client->supported_features,
477 client->required_features,
478 ceph_test_opt(client, NOCRC));
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700479
480 /* subsystems */
481 err = ceph_monc_init(&client->monc, client);
482 if (err < 0)
Alex Elder15d98822012-05-26 23:26:43 -0500483 goto fail;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700484 err = ceph_osdc_init(&client->osdc, client);
485 if (err < 0)
486 goto fail_monc;
487
488 return client;
489
490fail_monc:
491 ceph_monc_stop(&client->monc);
492fail:
493 kfree(client);
494 return ERR_PTR(err);
495}
496EXPORT_SYMBOL(ceph_create_client);
497
498void ceph_destroy_client(struct ceph_client *client)
499{
500 dout("destroy_client %p\n", client);
501
Guanjun Hea2a32582012-07-08 19:50:33 -0700502 atomic_set(&client->msgr.stopping, 1);
503
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700504 /* unmount */
505 ceph_osdc_stop(&client->osdc);
506
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700507 ceph_monc_stop(&client->monc);
508
509 ceph_debugfs_client_cleanup(client);
510
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700511 ceph_destroy_options(client->options);
512
513 kfree(client);
514 dout("destroy_client %p done\n", client);
515}
516EXPORT_SYMBOL(ceph_destroy_client);
517
518/*
519 * true if we have the mon map (and have thus joined the cluster)
520 */
521static int have_mon_and_osd_map(struct ceph_client *client)
522{
523 return client->monc.monmap && client->monc.monmap->epoch &&
524 client->osdc.osdmap && client->osdc.osdmap->epoch;
525}
526
527/*
528 * mount: join the ceph cluster, and open root directory.
529 */
530int __ceph_open_session(struct ceph_client *client, unsigned long started)
531{
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700532 int err;
533 unsigned long timeout = client->options->mount_timeout * HZ;
534
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700535 /* open session, and wait for mon and osd maps */
536 err = ceph_monc_open_session(&client->monc);
537 if (err < 0)
538 return err;
539
540 while (!have_mon_and_osd_map(client)) {
541 err = -EIO;
542 if (timeout && time_after_eq(jiffies, started + timeout))
543 return err;
544
545 /* wait */
546 dout("mount waiting for mon_map\n");
547 err = wait_event_interruptible_timeout(client->auth_wq,
548 have_mon_and_osd_map(client) || (client->auth_err < 0),
549 timeout);
550 if (err == -EINTR || err == -ERESTARTSYS)
551 return err;
552 if (client->auth_err < 0)
553 return client->auth_err;
554 }
555
556 return 0;
557}
558EXPORT_SYMBOL(__ceph_open_session);
559
560
561int ceph_open_session(struct ceph_client *client)
562{
563 int ret;
564 unsigned long started = jiffies; /* note the start time */
565
566 dout("open_session start\n");
567 mutex_lock(&client->mount_mutex);
568
569 ret = __ceph_open_session(client, started);
570
571 mutex_unlock(&client->mount_mutex);
572 return ret;
573}
574EXPORT_SYMBOL(ceph_open_session);
575
576
577static int __init init_ceph_lib(void)
578{
579 int ret = 0;
580
581 ret = ceph_debugfs_init();
582 if (ret < 0)
583 goto out;
584
Tommi Virtanen4b2a58a2011-03-28 14:59:38 -0700585 ret = ceph_crypto_init();
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700586 if (ret < 0)
587 goto out_debugfs;
588
Tommi Virtanen4b2a58a2011-03-28 14:59:38 -0700589 ret = ceph_msgr_init();
590 if (ret < 0)
591 goto out_crypto;
592
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700593 pr_info("loaded (mon/osd proto %d/%d, osdmap %d/%d %d/%d)\n",
594 CEPH_MONC_PROTOCOL, CEPH_OSDC_PROTOCOL,
595 CEPH_OSDMAP_VERSION, CEPH_OSDMAP_VERSION_EXT,
596 CEPH_OSDMAP_INC_VERSION, CEPH_OSDMAP_INC_VERSION_EXT);
597
598 return 0;
599
Tommi Virtanen4b2a58a2011-03-28 14:59:38 -0700600out_crypto:
601 ceph_crypto_shutdown();
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700602out_debugfs:
603 ceph_debugfs_cleanup();
604out:
605 return ret;
606}
607
608static void __exit exit_ceph_lib(void)
609{
610 dout("exit_ceph_lib\n");
611 ceph_msgr_exit();
Tommi Virtanen4b2a58a2011-03-28 14:59:38 -0700612 ceph_crypto_shutdown();
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700613 ceph_debugfs_cleanup();
614}
615
616module_init(init_ceph_lib);
617module_exit(exit_ceph_lib);
618
619MODULE_AUTHOR("Sage Weil <sage@newdream.net>");
620MODULE_AUTHOR("Yehuda Sadeh <yehuda@hq.newdream.net>");
621MODULE_AUTHOR("Patience Warnick <patience@newdream.net>");
622MODULE_DESCRIPTION("Ceph filesystem for Linux");
623MODULE_LICENSE("GPL");