diff options
author | Alex Elder <elder@inktank.com> | 2012-05-27 00:26:43 -0400 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-06-01 09:37:56 -0400 |
commit | 15d9882c336db2db73ccf9871ae2398e452f694c (patch) | |
tree | cfa0c726a69b68f51b344d50114a2961019c1231 /net | |
parent | e22004235a900213625acd6583ac913d5a30c155 (diff) |
libceph: embed ceph messenger structure in ceph_client
A ceph client has a pointer to a ceph messenger structure in it.
There is always exactly one ceph messenger for a ceph client, so
there is no need to allocate it separate from the ceph client
structure.
Switch the ceph_client structure to embed its ceph_messenger
structure.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/ceph_common.c | 18 | ||||
-rw-r--r-- | net/ceph/messenger.c | 30 | ||||
-rw-r--r-- | net/ceph/mon_client.c | 6 | ||||
-rw-r--r-- | net/ceph/osd_client.c | 4 |
4 files changed, 19 insertions, 39 deletions
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index cc913193d992..2de3ea1bbd64 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c | |||
@@ -468,19 +468,15 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private, | |||
468 | /* msgr */ | 468 | /* msgr */ |
469 | if (ceph_test_opt(client, MYIP)) | 469 | if (ceph_test_opt(client, MYIP)) |
470 | myaddr = &client->options->my_addr; | 470 | myaddr = &client->options->my_addr; |
471 | client->msgr = ceph_messenger_create(myaddr, | 471 | ceph_messenger_init(&client->msgr, myaddr, |
472 | client->supported_features, | 472 | client->supported_features, |
473 | client->required_features); | 473 | client->required_features, |
474 | if (IS_ERR(client->msgr)) { | 474 | ceph_test_opt(client, NOCRC)); |
475 | err = PTR_ERR(client->msgr); | ||
476 | goto fail; | ||
477 | } | ||
478 | client->msgr->nocrc = ceph_test_opt(client, NOCRC); | ||
479 | 475 | ||
480 | /* subsystems */ | 476 | /* subsystems */ |
481 | err = ceph_monc_init(&client->monc, client); | 477 | err = ceph_monc_init(&client->monc, client); |
482 | if (err < 0) | 478 | if (err < 0) |
483 | goto fail_msgr; | 479 | goto fail; |
484 | err = ceph_osdc_init(&client->osdc, client); | 480 | err = ceph_osdc_init(&client->osdc, client); |
485 | if (err < 0) | 481 | if (err < 0) |
486 | goto fail_monc; | 482 | goto fail_monc; |
@@ -489,8 +485,6 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private, | |||
489 | 485 | ||
490 | fail_monc: | 486 | fail_monc: |
491 | ceph_monc_stop(&client->monc); | 487 | ceph_monc_stop(&client->monc); |
492 | fail_msgr: | ||
493 | ceph_messenger_destroy(client->msgr); | ||
494 | fail: | 488 | fail: |
495 | kfree(client); | 489 | kfree(client); |
496 | return ERR_PTR(err); | 490 | return ERR_PTR(err); |
@@ -515,8 +509,6 @@ void ceph_destroy_client(struct ceph_client *client) | |||
515 | 509 | ||
516 | ceph_debugfs_client_cleanup(client); | 510 | ceph_debugfs_client_cleanup(client); |
517 | 511 | ||
518 | ceph_messenger_destroy(client->msgr); | ||
519 | |||
520 | ceph_destroy_options(client->options); | 512 | ceph_destroy_options(client->options); |
521 | 513 | ||
522 | kfree(client); | 514 | kfree(client); |
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 2ca491fc50e2..d8423a3f6698 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -2245,18 +2245,14 @@ out: | |||
2245 | 2245 | ||
2246 | 2246 | ||
2247 | /* | 2247 | /* |
2248 | * create a new messenger instance | 2248 | * initialize a new messenger instance |
2249 | */ | 2249 | */ |
2250 | struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr, | 2250 | void ceph_messenger_init(struct ceph_messenger *msgr, |
2251 | u32 supported_features, | 2251 | struct ceph_entity_addr *myaddr, |
2252 | u32 required_features) | 2252 | u32 supported_features, |
2253 | u32 required_features, | ||
2254 | bool nocrc) | ||
2253 | { | 2255 | { |
2254 | struct ceph_messenger *msgr; | ||
2255 | |||
2256 | msgr = kzalloc(sizeof(*msgr), GFP_KERNEL); | ||
2257 | if (msgr == NULL) | ||
2258 | return ERR_PTR(-ENOMEM); | ||
2259 | |||
2260 | msgr->supported_features = supported_features; | 2256 | msgr->supported_features = supported_features; |
2261 | msgr->required_features = required_features; | 2257 | msgr->required_features = required_features; |
2262 | 2258 | ||
@@ -2269,19 +2265,11 @@ struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr, | |||
2269 | msgr->inst.addr.type = 0; | 2265 | msgr->inst.addr.type = 0; |
2270 | get_random_bytes(&msgr->inst.addr.nonce, sizeof(msgr->inst.addr.nonce)); | 2266 | get_random_bytes(&msgr->inst.addr.nonce, sizeof(msgr->inst.addr.nonce)); |
2271 | encode_my_addr(msgr); | 2267 | encode_my_addr(msgr); |
2268 | msgr->nocrc = nocrc; | ||
2272 | 2269 | ||
2273 | dout("messenger_create %p\n", msgr); | 2270 | dout("%s %p\n", __func__, msgr); |
2274 | return msgr; | ||
2275 | } | ||
2276 | EXPORT_SYMBOL(ceph_messenger_create); | ||
2277 | |||
2278 | void ceph_messenger_destroy(struct ceph_messenger *msgr) | ||
2279 | { | ||
2280 | dout("destroy %p\n", msgr); | ||
2281 | kfree(msgr); | ||
2282 | dout("destroyed messenger %p\n", msgr); | ||
2283 | } | 2271 | } |
2284 | EXPORT_SYMBOL(ceph_messenger_destroy); | 2272 | EXPORT_SYMBOL(ceph_messenger_init); |
2285 | 2273 | ||
2286 | static void clear_standby(struct ceph_connection *con) | 2274 | static void clear_standby(struct ceph_connection *con) |
2287 | { | 2275 | { |
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c index 1845cde26227..704dc95dc620 100644 --- a/net/ceph/mon_client.c +++ b/net/ceph/mon_client.c | |||
@@ -763,7 +763,7 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) | |||
763 | monc->con = kmalloc(sizeof(*monc->con), GFP_KERNEL); | 763 | monc->con = kmalloc(sizeof(*monc->con), GFP_KERNEL); |
764 | if (!monc->con) | 764 | if (!monc->con) |
765 | goto out_monmap; | 765 | goto out_monmap; |
766 | ceph_con_init(monc->client->msgr, monc->con); | 766 | ceph_con_init(&monc->client->msgr, monc->con); |
767 | monc->con->private = monc; | 767 | monc->con->private = monc; |
768 | monc->con->ops = &mon_con_ops; | 768 | monc->con->ops = &mon_con_ops; |
769 | 769 | ||
@@ -880,8 +880,8 @@ static void handle_auth_reply(struct ceph_mon_client *monc, | |||
880 | } else if (!was_auth && monc->auth->ops->is_authenticated(monc->auth)) { | 880 | } else if (!was_auth && monc->auth->ops->is_authenticated(monc->auth)) { |
881 | dout("authenticated, starting session\n"); | 881 | dout("authenticated, starting session\n"); |
882 | 882 | ||
883 | monc->client->msgr->inst.name.type = CEPH_ENTITY_TYPE_CLIENT; | 883 | monc->client->msgr.inst.name.type = CEPH_ENTITY_TYPE_CLIENT; |
884 | monc->client->msgr->inst.name.num = | 884 | monc->client->msgr.inst.name.num = |
885 | cpu_to_le64(monc->auth->global_id); | 885 | cpu_to_le64(monc->auth->global_id); |
886 | 886 | ||
887 | __send_subscribe(monc); | 887 | __send_subscribe(monc); |
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index b098e7b591f0..cca4c7f1c780 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -639,7 +639,7 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc) | |||
639 | INIT_LIST_HEAD(&osd->o_osd_lru); | 639 | INIT_LIST_HEAD(&osd->o_osd_lru); |
640 | osd->o_incarnation = 1; | 640 | osd->o_incarnation = 1; |
641 | 641 | ||
642 | ceph_con_init(osdc->client->msgr, &osd->o_con); | 642 | ceph_con_init(&osdc->client->msgr, &osd->o_con); |
643 | osd->o_con.private = osd; | 643 | osd->o_con.private = osd; |
644 | osd->o_con.ops = &osd_con_ops; | 644 | osd->o_con.ops = &osd_con_ops; |
645 | osd->o_con.peer_name.type = CEPH_ENTITY_TYPE_OSD; | 645 | osd->o_con.peer_name.type = CEPH_ENTITY_TYPE_OSD; |
@@ -1391,7 +1391,7 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) | |||
1391 | epoch, maplen); | 1391 | epoch, maplen); |
1392 | newmap = osdmap_apply_incremental(&p, next, | 1392 | newmap = osdmap_apply_incremental(&p, next, |
1393 | osdc->osdmap, | 1393 | osdc->osdmap, |
1394 | osdc->client->msgr); | 1394 | &osdc->client->msgr); |
1395 | if (IS_ERR(newmap)) { | 1395 | if (IS_ERR(newmap)) { |
1396 | err = PTR_ERR(newmap); | 1396 | err = PTR_ERR(newmap); |
1397 | goto bad; | 1397 | goto bad; |