diff options
author | Sage Weil <sage@newdream.net> | 2011-08-09 12:41:59 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2011-10-25 19:10:15 -0400 |
commit | 6ab00d465a1c8c02c2216f8220727282f3aa50b5 (patch) | |
tree | b4cc08e1be5ffe0a60d9090d86f7f0d05b1f6e36 /net/ceph | |
parent | 6a8ea4706adb4b4d8f77a8da5f9778b65fbf6f48 (diff) |
libceph: create messenger with client
This simplifies the init/shutdown paths, and makes client->msgr available
during the rest of the setup process.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/ceph_common.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 2883ea01e680..97f70e50ad3b 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c | |||
@@ -432,9 +432,12 @@ EXPORT_SYMBOL(ceph_client_id); | |||
432 | /* | 432 | /* |
433 | * create a fresh client instance | 433 | * create a fresh client instance |
434 | */ | 434 | */ |
435 | struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private) | 435 | struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private, |
436 | unsigned supported_features, | ||
437 | unsigned required_features) | ||
436 | { | 438 | { |
437 | struct ceph_client *client; | 439 | struct ceph_client *client; |
440 | struct ceph_entity_addr *myaddr = NULL; | ||
438 | int err = -ENOMEM; | 441 | int err = -ENOMEM; |
439 | 442 | ||
440 | client = kzalloc(sizeof(*client), GFP_KERNEL); | 443 | client = kzalloc(sizeof(*client), GFP_KERNEL); |
@@ -449,15 +452,27 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private) | |||
449 | client->auth_err = 0; | 452 | client->auth_err = 0; |
450 | 453 | ||
451 | client->extra_mon_dispatch = NULL; | 454 | client->extra_mon_dispatch = NULL; |
452 | client->supported_features = CEPH_FEATURE_SUPPORTED_DEFAULT; | 455 | client->supported_features = CEPH_FEATURE_SUPPORTED_DEFAULT | |
453 | client->required_features = CEPH_FEATURE_REQUIRED_DEFAULT; | 456 | supported_features; |
454 | 457 | client->required_features = CEPH_FEATURE_REQUIRED_DEFAULT | | |
455 | client->msgr = NULL; | 458 | required_features; |
459 | |||
460 | /* msgr */ | ||
461 | if (ceph_test_opt(client, MYIP)) | ||
462 | myaddr = &client->options->my_addr; | ||
463 | client->msgr = ceph_messenger_create(myaddr, | ||
464 | client->supported_features, | ||
465 | client->required_features); | ||
466 | if (IS_ERR(client->msgr)) { | ||
467 | err = PTR_ERR(client->msgr); | ||
468 | goto fail; | ||
469 | } | ||
470 | client->msgr->nocrc = ceph_test_opt(client, NOCRC); | ||
456 | 471 | ||
457 | /* subsystems */ | 472 | /* subsystems */ |
458 | err = ceph_monc_init(&client->monc, client); | 473 | err = ceph_monc_init(&client->monc, client); |
459 | if (err < 0) | 474 | if (err < 0) |
460 | goto fail; | 475 | goto fail_msgr; |
461 | err = ceph_osdc_init(&client->osdc, client); | 476 | err = ceph_osdc_init(&client->osdc, client); |
462 | if (err < 0) | 477 | if (err < 0) |
463 | goto fail_monc; | 478 | goto fail_monc; |
@@ -466,6 +481,8 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private) | |||
466 | 481 | ||
467 | fail_monc: | 482 | fail_monc: |
468 | ceph_monc_stop(&client->monc); | 483 | ceph_monc_stop(&client->monc); |
484 | fail_msgr: | ||
485 | ceph_messenger_destroy(client->msgr); | ||
469 | fail: | 486 | fail: |
470 | kfree(client); | 487 | kfree(client); |
471 | return ERR_PTR(err); | 488 | return ERR_PTR(err); |
@@ -490,8 +507,7 @@ void ceph_destroy_client(struct ceph_client *client) | |||
490 | 507 | ||
491 | ceph_debugfs_client_cleanup(client); | 508 | ceph_debugfs_client_cleanup(client); |
492 | 509 | ||
493 | if (client->msgr) | 510 | ceph_messenger_destroy(client->msgr); |
494 | ceph_messenger_destroy(client->msgr); | ||
495 | 511 | ||
496 | ceph_destroy_options(client->options); | 512 | ceph_destroy_options(client->options); |
497 | 513 | ||
@@ -514,24 +530,9 @@ static int have_mon_and_osd_map(struct ceph_client *client) | |||
514 | */ | 530 | */ |
515 | int __ceph_open_session(struct ceph_client *client, unsigned long started) | 531 | int __ceph_open_session(struct ceph_client *client, unsigned long started) |
516 | { | 532 | { |
517 | struct ceph_entity_addr *myaddr = NULL; | ||
518 | int err; | 533 | int err; |
519 | unsigned long timeout = client->options->mount_timeout * HZ; | 534 | unsigned long timeout = client->options->mount_timeout * HZ; |
520 | 535 | ||
521 | /* initialize the messenger */ | ||
522 | if (client->msgr == NULL) { | ||
523 | if (ceph_test_opt(client, MYIP)) | ||
524 | myaddr = &client->options->my_addr; | ||
525 | client->msgr = ceph_messenger_create(myaddr, | ||
526 | client->supported_features, | ||
527 | client->required_features); | ||
528 | if (IS_ERR(client->msgr)) { | ||
529 | client->msgr = NULL; | ||
530 | return PTR_ERR(client->msgr); | ||
531 | } | ||
532 | client->msgr->nocrc = ceph_test_opt(client, NOCRC); | ||
533 | } | ||
534 | |||
535 | /* open session, and wait for mon and osd maps */ | 536 | /* open session, and wait for mon and osd maps */ |
536 | err = ceph_monc_open_session(&client->monc); | 537 | err = ceph_monc_open_session(&client->monc); |
537 | if (err < 0) | 538 | if (err < 0) |