diff options
Diffstat (limited to 'fs/ceph/mon_client.c')
-rw-r--r-- | fs/ceph/mon_client.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c index e6e954cac6b9..61263c99c6a8 100644 --- a/fs/ceph/mon_client.c +++ b/fs/ceph/mon_client.c | |||
@@ -527,6 +527,40 @@ static void delayed_work(struct work_struct *work) | |||
527 | mutex_unlock(&monc->mutex); | 527 | mutex_unlock(&monc->mutex); |
528 | } | 528 | } |
529 | 529 | ||
530 | /* | ||
531 | * On startup, we build a temporary monmap populated with the IPs | ||
532 | * provided by mount(2). | ||
533 | */ | ||
534 | static int build_initial_monmap(struct ceph_mon_client *monc) | ||
535 | { | ||
536 | struct ceph_mount_args *args = monc->client->mount_args; | ||
537 | struct ceph_entity_addr *mon_addr = args->mon_addr; | ||
538 | int num_mon = args->num_mon; | ||
539 | int i; | ||
540 | |||
541 | /* build initial monmap */ | ||
542 | monc->monmap = kzalloc(sizeof(*monc->monmap) + | ||
543 | num_mon*sizeof(monc->monmap->mon_inst[0]), | ||
544 | GFP_KERNEL); | ||
545 | if (!monc->monmap) | ||
546 | return -ENOMEM; | ||
547 | for (i = 0; i < num_mon; i++) { | ||
548 | monc->monmap->mon_inst[i].addr = mon_addr[i]; | ||
549 | monc->monmap->mon_inst[i].addr.erank = 0; | ||
550 | monc->monmap->mon_inst[i].addr.nonce = 0; | ||
551 | monc->monmap->mon_inst[i].name.type = | ||
552 | CEPH_ENTITY_TYPE_MON; | ||
553 | monc->monmap->mon_inst[i].name.num = cpu_to_le64(i); | ||
554 | } | ||
555 | monc->monmap->num_mon = num_mon; | ||
556 | |||
557 | /* release addr memory */ | ||
558 | kfree(args->mon_addr); | ||
559 | args->mon_addr = NULL; | ||
560 | args->num_mon = 0; | ||
561 | return 0; | ||
562 | } | ||
563 | |||
530 | int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) | 564 | int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) |
531 | { | 565 | { |
532 | int err = 0; | 566 | int err = 0; |
@@ -537,6 +571,10 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) | |||
537 | monc->monmap = NULL; | 571 | monc->monmap = NULL; |
538 | mutex_init(&monc->mutex); | 572 | mutex_init(&monc->mutex); |
539 | 573 | ||
574 | err = build_initial_monmap(monc); | ||
575 | if (err) | ||
576 | goto out; | ||
577 | |||
540 | monc->con = NULL; | 578 | monc->con = NULL; |
541 | 579 | ||
542 | /* msg pools */ | 580 | /* msg pools */ |