diff options
-rw-r--r-- | fs/ceph/debugfs.c | 4 | ||||
-rw-r--r-- | fs/ceph/mds_client.c | 12 | ||||
-rw-r--r-- | fs/ceph/mon_client.c | 113 | ||||
-rw-r--r-- | fs/ceph/osd_client.c | 12 | ||||
-rw-r--r-- | fs/ceph/super.c | 32 | ||||
-rw-r--r-- | fs/ceph/super.h | 18 |
6 files changed, 51 insertions, 140 deletions
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 9b2020696680..b90fc3e1ff70 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c | |||
@@ -7,6 +7,8 @@ | |||
7 | 7 | ||
8 | #include "super.h" | 8 | #include "super.h" |
9 | #include "mds_client.h" | 9 | #include "mds_client.h" |
10 | #include "mon_client.h" | ||
11 | #include "auth.h" | ||
10 | 12 | ||
11 | #ifdef CONFIG_DEBUG_FS | 13 | #ifdef CONFIG_DEBUG_FS |
12 | 14 | ||
@@ -335,7 +337,7 @@ int ceph_debugfs_client_init(struct ceph_client *client) | |||
335 | char name[80]; | 337 | char name[80]; |
336 | 338 | ||
337 | snprintf(name, sizeof(name), FSID_FORMAT ".client%lld", | 339 | snprintf(name, sizeof(name), FSID_FORMAT ".client%lld", |
338 | PR_FSID(&client->monc.monmap->fsid), client->whoami); | 340 | PR_FSID(&client->fsid), client->monc.auth->global_id); |
339 | 341 | ||
340 | client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir); | 342 | client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir); |
341 | if (!client->debugfs_dir) | 343 | if (!client->debugfs_dir) |
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 8a285158aecc..8d95b0f051e4 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -2782,16 +2782,8 @@ void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg) | |||
2782 | 2782 | ||
2783 | ceph_decode_need(&p, end, sizeof(fsid)+2*sizeof(u32), bad); | 2783 | ceph_decode_need(&p, end, sizeof(fsid)+2*sizeof(u32), bad); |
2784 | ceph_decode_copy(&p, &fsid, sizeof(fsid)); | 2784 | ceph_decode_copy(&p, &fsid, sizeof(fsid)); |
2785 | if (mdsc->client->monc.have_fsid) { | 2785 | if (ceph_check_fsid(mdsc->client, &fsid) < 0) |
2786 | if (ceph_fsid_compare(&fsid, | 2786 | return; |
2787 | &mdsc->client->monc.monmap->fsid)) { | ||
2788 | pr_err("got mdsmap with wrong fsid\n"); | ||
2789 | return; | ||
2790 | } | ||
2791 | } else { | ||
2792 | ceph_fsid_set(&mdsc->client->monc.monmap->fsid, &fsid); | ||
2793 | mdsc->client->monc.have_fsid = true; | ||
2794 | } | ||
2795 | epoch = ceph_decode_32(&p); | 2787 | epoch = ceph_decode_32(&p); |
2796 | maplen = ceph_decode_32(&p); | 2788 | maplen = ceph_decode_32(&p); |
2797 | dout("handle_map epoch %u len %d\n", epoch, (int)maplen); | 2789 | dout("handle_map epoch %u len %d\n", epoch, (int)maplen); |
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c index 017d5aef8834..b742b3b3e0f3 100644 --- a/fs/ceph/mon_client.c +++ b/fs/ceph/mon_client.c | |||
@@ -320,89 +320,12 @@ int ceph_monc_open_session(struct ceph_mon_client *monc) | |||
320 | return 0; | 320 | return 0; |
321 | } | 321 | } |
322 | 322 | ||
323 | #if 0 | ||
324 | |||
325 | /* | ||
326 | * The monitor responds with mount ack indicate mount success. The | ||
327 | * included client ticket allows the client to talk to MDSs and OSDs. | ||
328 | */ | ||
329 | static void handle_mount_ack(struct ceph_mon_client *monc, struct ceph_msg *msg) | ||
330 | { | ||
331 | struct ceph_client *client = monc->client; | ||
332 | struct ceph_monmap *monmap = NULL, *old = monc->monmap; | ||
333 | void *p, *end; | ||
334 | s32 result; | ||
335 | u32 len; | ||
336 | s64 cnum; | ||
337 | int err = -EINVAL; | ||
338 | |||
339 | if (client->whoami >= 0) { | ||
340 | dout("handle_mount_ack - already mounted\n"); | ||
341 | return; | ||
342 | } | ||
343 | |||
344 | mutex_lock(&monc->mutex); | ||
345 | |||
346 | dout("handle_mount_ack\n"); | ||
347 | p = msg->front.iov_base; | ||
348 | end = p + msg->front.iov_len; | ||
349 | |||
350 | ceph_decode_64_safe(&p, end, cnum, bad); | ||
351 | ceph_decode_32_safe(&p, end, result, bad); | ||
352 | ceph_decode_32_safe(&p, end, len, bad); | ||
353 | if (result) { | ||
354 | pr_err("mount denied: %.*s (%d)\n", len, (char *)p, | ||
355 | result); | ||
356 | err = result; | ||
357 | goto out; | ||
358 | } | ||
359 | p += len; | ||
360 | |||
361 | ceph_decode_32_safe(&p, end, len, bad); | ||
362 | ceph_decode_need(&p, end, len, bad); | ||
363 | monmap = ceph_monmap_decode(p, p + len); | ||
364 | if (IS_ERR(monmap)) { | ||
365 | pr_err("problem decoding monmap, %d\n", | ||
366 | (int)PTR_ERR(monmap)); | ||
367 | err = -EINVAL; | ||
368 | goto out; | ||
369 | } | ||
370 | p += len; | ||
371 | |||
372 | client->monc.monmap = monmap; | ||
373 | kfree(old); | ||
374 | |||
375 | client->signed_ticket = NULL; | ||
376 | client->signed_ticket_len = 0; | ||
377 | |||
378 | monc->want_mount = false; | ||
379 | |||
380 | client->whoami = cnum; | ||
381 | client->msgr->inst.name.type = CEPH_ENTITY_TYPE_CLIENT; | ||
382 | client->msgr->inst.name.num = cpu_to_le64(cnum); | ||
383 | pr_info("client%lld fsid " FSID_FORMAT "\n", | ||
384 | client->whoami, PR_FSID(&client->monc.monmap->fsid)); | ||
385 | |||
386 | ceph_debugfs_client_init(client); | ||
387 | __send_subscribe(monc); | ||
388 | |||
389 | err = 0; | ||
390 | goto out; | ||
391 | |||
392 | bad: | ||
393 | pr_err("error decoding mount_ack message\n"); | ||
394 | out: | ||
395 | client->mount_err = err; | ||
396 | mutex_unlock(&monc->mutex); | ||
397 | wake_up(&client->mount_wq); | ||
398 | } | ||
399 | #endif | ||
400 | |||
401 | /* | 323 | /* |
402 | * The monitor responds with mount ack indicate mount success. The | 324 | * The monitor responds with mount ack indicate mount success. The |
403 | * included client ticket allows the client to talk to MDSs and OSDs. | 325 | * included client ticket allows the client to talk to MDSs and OSDs. |
404 | */ | 326 | */ |
405 | static void ceph_monc_handle_map(struct ceph_mon_client *monc, struct ceph_msg *msg) | 327 | static void ceph_monc_handle_map(struct ceph_mon_client *monc, |
328 | struct ceph_msg *msg) | ||
406 | { | 329 | { |
407 | struct ceph_client *client = monc->client; | 330 | struct ceph_client *client = monc->client; |
408 | struct ceph_monmap *monmap = NULL, *old = monc->monmap; | 331 | struct ceph_monmap *monmap = NULL, *old = monc->monmap; |
@@ -420,42 +343,19 @@ static void ceph_monc_handle_map(struct ceph_mon_client *monc, struct ceph_msg * | |||
420 | (int)PTR_ERR(monmap)); | 343 | (int)PTR_ERR(monmap)); |
421 | return; | 344 | return; |
422 | } | 345 | } |
423 | if (monc->have_fsid && | 346 | |
424 | ceph_fsid_compare(&monmap->fsid, &monc->monmap->fsid)) { | 347 | if (ceph_check_fsid(monc->client, &monmap->fsid) < 0) { |
425 | print_hex_dump(KERN_ERR, "monmap->fsid: ", DUMP_PREFIX_NONE, 16, 1, | ||
426 | (void *)&monmap->fsid, 16, 0); | ||
427 | print_hex_dump(KERN_ERR, "monc->monmap->fsid: ", DUMP_PREFIX_NONE, 16, 1, | ||
428 | (void *)&monc->monmap->fsid, 16, 0); | ||
429 | |||
430 | pr_err("fsid mismatch, got a previous map with different fsid"); | ||
431 | kfree(monmap); | 348 | kfree(monmap); |
432 | return; | 349 | return; |
433 | } | 350 | } |
434 | 351 | ||
435 | client->monc.monmap = monmap; | 352 | client->monc.monmap = monmap; |
436 | client->monc.have_fsid = true; | ||
437 | kfree(old); | 353 | kfree(old); |
438 | 354 | ||
439 | mutex_unlock(&monc->mutex); | 355 | mutex_unlock(&monc->mutex); |
440 | wake_up(&client->mount_wq); | 356 | wake_up(&client->mount_wq); |
441 | } | 357 | } |
442 | 358 | ||
443 | |||
444 | /* | ||
445 | * init client info after authentication | ||
446 | */ | ||
447 | static void __init_authenticated_client(struct ceph_mon_client *monc) | ||
448 | { | ||
449 | struct ceph_client *client = monc->client; | ||
450 | |||
451 | client->signed_ticket = NULL; | ||
452 | client->signed_ticket_len = 0; | ||
453 | client->msgr->inst.name.type = CEPH_ENTITY_TYPE_CLIENT; | ||
454 | client->msgr->inst.name.num = monc->auth->global_id; | ||
455 | |||
456 | ceph_debugfs_client_init(client); | ||
457 | } | ||
458 | |||
459 | /* | 359 | /* |
460 | * statfs | 360 | * statfs |
461 | */ | 361 | */ |
@@ -754,7 +654,10 @@ static void handle_auth_reply(struct ceph_mon_client *monc, | |||
754 | ceph_con_send(monc->con, monc->m_auth); | 654 | ceph_con_send(monc->con, monc->m_auth); |
755 | } else if (monc->auth->ops->is_authenticated(monc->auth)) { | 655 | } else if (monc->auth->ops->is_authenticated(monc->auth)) { |
756 | dout("authenticated, starting session\n"); | 656 | dout("authenticated, starting session\n"); |
757 | __init_authenticated_client(monc); | 657 | |
658 | monc->client->msgr->inst.name.type = CEPH_ENTITY_TYPE_CLIENT; | ||
659 | monc->client->msgr->inst.name.num = monc->auth->global_id; | ||
660 | |||
758 | __send_subscribe(monc); | 661 | __send_subscribe(monc); |
759 | __resend_statfs(monc); | 662 | __resend_statfs(monc); |
760 | } | 663 | } |
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c index ca0ee68c322a..d63f192999ee 100644 --- a/fs/ceph/osd_client.c +++ b/fs/ceph/osd_client.c | |||
@@ -882,16 +882,8 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) | |||
882 | /* verify fsid */ | 882 | /* verify fsid */ |
883 | ceph_decode_need(&p, end, sizeof(fsid), bad); | 883 | ceph_decode_need(&p, end, sizeof(fsid), bad); |
884 | ceph_decode_copy(&p, &fsid, sizeof(fsid)); | 884 | ceph_decode_copy(&p, &fsid, sizeof(fsid)); |
885 | if (osdc->client->monc.have_fsid) { | 885 | if (ceph_check_fsid(osdc->client, &fsid) < 0) |
886 | if (ceph_fsid_compare(&fsid, | 886 | return; |
887 | &osdc->client->monc.monmap->fsid)) { | ||
888 | pr_err("got osdmap with wrong fsid, ignoring\n"); | ||
889 | return; | ||
890 | } | ||
891 | } else { | ||
892 | ceph_fsid_set(&osdc->client->monc.monmap->fsid, &fsid); | ||
893 | osdc->client->monc.have_fsid = true; | ||
894 | } | ||
895 | 887 | ||
896 | down_write(&osdc->map_sem); | 888 | down_write(&osdc->map_sem); |
897 | 889 | ||
diff --git a/fs/ceph/super.c b/fs/ceph/super.c index df05617aca86..3df6d4ab236c 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "decode.h" | 19 | #include "decode.h" |
20 | #include "super.h" | 20 | #include "super.h" |
21 | #include "mon_client.h" | 21 | #include "mon_client.h" |
22 | #include "auth.h" | ||
22 | 23 | ||
23 | /* | 24 | /* |
24 | * Ceph superblock operations | 25 | * Ceph superblock operations |
@@ -510,14 +511,11 @@ static struct ceph_client *ceph_create_client(struct ceph_mount_args *args) | |||
510 | 511 | ||
511 | client->sb = NULL; | 512 | client->sb = NULL; |
512 | client->mount_state = CEPH_MOUNT_MOUNTING; | 513 | client->mount_state = CEPH_MOUNT_MOUNTING; |
513 | client->whoami = -1; | ||
514 | client->mount_args = args; | 514 | client->mount_args = args; |
515 | 515 | ||
516 | client->msgr = NULL; | 516 | client->msgr = NULL; |
517 | 517 | ||
518 | client->mount_err = 0; | 518 | client->mount_err = 0; |
519 | client->signed_ticket = NULL; | ||
520 | client->signed_ticket_len = 0; | ||
521 | 519 | ||
522 | err = bdi_init(&client->backing_dev_info); | 520 | err = bdi_init(&client->backing_dev_info); |
523 | if (err < 0) | 521 | if (err < 0) |
@@ -582,8 +580,6 @@ static void ceph_destroy_client(struct ceph_client *client) | |||
582 | ceph_monc_stop(&client->monc); | 580 | ceph_monc_stop(&client->monc); |
583 | ceph_osdc_stop(&client->osdc); | 581 | ceph_osdc_stop(&client->osdc); |
584 | 582 | ||
585 | kfree(client->signed_ticket); | ||
586 | |||
587 | ceph_debugfs_client_cleanup(client); | 583 | ceph_debugfs_client_cleanup(client); |
588 | destroy_workqueue(client->wb_wq); | 584 | destroy_workqueue(client->wb_wq); |
589 | destroy_workqueue(client->pg_inv_wq); | 585 | destroy_workqueue(client->pg_inv_wq); |
@@ -600,6 +596,32 @@ static void ceph_destroy_client(struct ceph_client *client) | |||
600 | } | 596 | } |
601 | 597 | ||
602 | /* | 598 | /* |
599 | * Initially learn our fsid, or verify an fsid matches. | ||
600 | */ | ||
601 | int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid) | ||
602 | { | ||
603 | if (client->have_fsid) { | ||
604 | if (ceph_fsid_compare(&client->fsid, fsid)) { | ||
605 | print_hex_dump(KERN_ERR, "this fsid: ", | ||
606 | DUMP_PREFIX_NONE, 16, 1, | ||
607 | (void *)fsid, 16, 0); | ||
608 | print_hex_dump(KERN_ERR, " old fsid: ", | ||
609 | DUMP_PREFIX_NONE, 16, 1, | ||
610 | (void *)&client->fsid, 16, 0); | ||
611 | pr_err("fsid mismatch\n"); | ||
612 | return -1; | ||
613 | } | ||
614 | } else { | ||
615 | pr_info("client%lld fsid " FSID_FORMAT "\n", | ||
616 | client->monc.auth->global_id, PR_FSID(fsid)); | ||
617 | memcpy(&client->fsid, fsid, sizeof(*fsid)); | ||
618 | ceph_debugfs_client_init(client); | ||
619 | client->have_fsid = true; | ||
620 | } | ||
621 | return 0; | ||
622 | } | ||
623 | |||
624 | /* | ||
603 | * true if we have the mon map (and have thus joined the cluster) | 625 | * true if we have the mon map (and have thus joined the cluster) |
604 | */ | 626 | */ |
605 | static int have_mon_map(struct ceph_client *client) | 627 | static int have_mon_map(struct ceph_client *client) |
diff --git a/fs/ceph/super.h b/fs/ceph/super.h index e0e8130959b6..de5e32414978 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h | |||
@@ -113,16 +113,11 @@ static inline unsigned long time_sub(unsigned long a, unsigned long b) | |||
113 | * mounting the same ceph filesystem/cluster. | 113 | * mounting the same ceph filesystem/cluster. |
114 | */ | 114 | */ |
115 | struct ceph_client { | 115 | struct ceph_client { |
116 | __s64 whoami; /* my client number */ | 116 | struct ceph_fsid fsid; |
117 | #ifdef CONFIG_DEBUG_FS | 117 | bool have_fsid; |
118 | struct dentry *debugfs_monmap; | ||
119 | struct dentry *debugfs_mdsmap, *debugfs_osdmap; | ||
120 | struct dentry *debugfs_dir, *debugfs_dentry_lru, *debugfs_caps; | ||
121 | #endif | ||
122 | 118 | ||
123 | struct mutex mount_mutex; /* serialize mount attempts */ | 119 | struct mutex mount_mutex; /* serialize mount attempts */ |
124 | struct ceph_mount_args *mount_args; | 120 | struct ceph_mount_args *mount_args; |
125 | struct ceph_fsid fsid; | ||
126 | 121 | ||
127 | struct super_block *sb; | 122 | struct super_block *sb; |
128 | 123 | ||
@@ -130,8 +125,6 @@ struct ceph_client { | |||
130 | wait_queue_head_t mount_wq; | 125 | wait_queue_head_t mount_wq; |
131 | 126 | ||
132 | int mount_err; | 127 | int mount_err; |
133 | void *signed_ticket; /* our keys to the kingdom */ | ||
134 | int signed_ticket_len; | ||
135 | 128 | ||
136 | struct ceph_messenger *msgr; /* messenger instance */ | 129 | struct ceph_messenger *msgr; /* messenger instance */ |
137 | struct ceph_mon_client monc; | 130 | struct ceph_mon_client monc; |
@@ -145,6 +138,12 @@ struct ceph_client { | |||
145 | struct workqueue_struct *trunc_wq; | 138 | struct workqueue_struct *trunc_wq; |
146 | 139 | ||
147 | struct backing_dev_info backing_dev_info; | 140 | struct backing_dev_info backing_dev_info; |
141 | |||
142 | #ifdef CONFIG_DEBUG_FS | ||
143 | struct dentry *debugfs_monmap; | ||
144 | struct dentry *debugfs_mdsmap, *debugfs_osdmap; | ||
145 | struct dentry *debugfs_dir, *debugfs_dentry_lru, *debugfs_caps; | ||
146 | #endif | ||
148 | }; | 147 | }; |
149 | 148 | ||
150 | static inline struct ceph_client *ceph_client(struct super_block *sb) | 149 | static inline struct ceph_client *ceph_client(struct super_block *sb) |
@@ -735,6 +734,7 @@ extern struct kmem_cache *ceph_dentry_cachep; | |||
735 | extern struct kmem_cache *ceph_file_cachep; | 734 | extern struct kmem_cache *ceph_file_cachep; |
736 | 735 | ||
737 | extern const char *ceph_msg_type_name(int type); | 736 | extern const char *ceph_msg_type_name(int type); |
737 | extern int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid); | ||
738 | 738 | ||
739 | #define FSID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \ | 739 | #define FSID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \ |
740 | "%02x%02x%02x%02x%02x%02x" | 740 | "%02x%02x%02x%02x%02x%02x" |