aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/mon_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph/mon_client.c')
-rw-r--r--fs/ceph/mon_client.c113
1 files changed, 8 insertions, 105 deletions
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c
index 017d5aef883..b742b3b3e0f 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 */
329static 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
392bad:
393 pr_err("error decoding mount_ack message\n");
394out:
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 */
405static void ceph_monc_handle_map(struct ceph_mon_client *monc, struct ceph_msg *msg) 327static 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 */
447static 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 }