From 38b3fb23b001ca2a3192eca3d78c0bd9de917587 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 11 Apr 2008 11:55:34 -0700 Subject: [PATCH] kclient: use wait queue instead of completion on mount --- src/kernel/client.c | 21 +++++++++++++-------- src/kernel/messenger.c | 5 ++--- src/kernel/super.h | 19 ++++++++++++------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/kernel/client.c b/src/kernel/client.c index 45d53573c1c04..06a6945113b66 100644 --- a/src/kernel/client.c +++ b/src/kernel/client.c @@ -103,11 +103,16 @@ int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args, struct /* wait */ dout(10, "mount sent mount request, waiting for maps\n"); - err = wait_for_completion_timeout(&client->mount_completion, - 6*HZ); + //err = wait_for_completion_timeout(&client->mount_completion, + //6*HZ); + err = wait_event_interruptible_timeout( + client->mount_wq, + ceph_have_all_maps(client), + 6*HZ); + dout(10, "mount wait got %d\n", err); if (err == -EINTR) return err; - if (client->mounting == 7) + if (ceph_have_all_maps(client)) break; /* success */ dout(10, "mount still waiting for mount, attempts=%d\n", attempts); @@ -160,11 +165,11 @@ static void handle_monmap(struct ceph_client *client, struct ceph_msg *msg) void got_first_map(struct ceph_client *client, int num) { set_bit(num, &client->mounting); - dout(10, "got_first_map num %d mounting now %lu bits %d\n", - num, client->mounting, (int)find_first_zero_bit(&client->mounting, 4)); - if (find_first_zero_bit(&client->mounting, 4) == 3) { + dout(10, "got_first_map num %d mounting now %lu done=%d\n", + num, client->mounting, ceph_have_all_maps(client)); + if (ceph_have_all_maps(client)) { dout(10, "got_first_map kicking mount\n"); - complete(&client->mount_completion); + wake_up(&client->mount_wq); } } @@ -183,7 +188,7 @@ struct ceph_client *ceph_create_client(struct ceph_mount_args *args, struct supe if (cl == NULL) return ERR_PTR(-ENOMEM); - init_completion(&cl->mount_completion); + init_waitqueue_head(&cl->mount_wq); spin_lock_init(&cl->sb_lock); get_client_counter(); diff --git a/src/kernel/messenger.c b/src/kernel/messenger.c index 8c5b98aef8068..bf1b0c77a8107 100644 --- a/src/kernel/messenger.c +++ b/src/kernel/messenger.c @@ -1192,9 +1192,8 @@ struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr) if (myaddr) msgr->inst.addr.ipaddr.sin_addr = myaddr->ipaddr.sin_addr; - dout(1, "create %p listening on %x:%d\n", msgr, - ntohl(msgr->inst.addr.ipaddr.sin_addr.s_addr), - ntohs(msgr->inst.addr.ipaddr.sin_port)); + dout(1, "create %p listening on %u.%u.%u.%u:%u\n", msgr, + IPQUADPORT(msgr->inst.addr.ipaddr)); return msgr; } diff --git a/src/kernel/super.h b/src/kernel/super.h index d8cbaad372c56..74e93a4814a7f 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -45,11 +45,11 @@ extern int ceph_debug_addr; #define CEPH_BLOCK (1 << CEPH_BLOCK_SHIFT) #define IPQUADPORT(n) \ - (unsigned int)((n.sin_addr.s_addr)) & 0xFF, \ - (unsigned int)((n.sin_addr.s_addr)>>8) & 0xFF, \ - (unsigned int)((n.sin_addr.s_addr)>>16) & 0xFF, \ - (unsigned int)((n.sin_addr.s_addr)>>24) & 0xFF, \ - (unsigned int)(ntohs(n.sin_port)) + (unsigned int)(((n).sin_addr.s_addr)) & 0xFF, \ + (unsigned int)(((n).sin_addr.s_addr)>>8) & 0xFF, \ + (unsigned int)(((n).sin_addr.s_addr)>>16) & 0xFF, \ + (unsigned int)(((n).sin_addr.s_addr)>>24) & 0xFF, \ + (unsigned int)(ntohs((n).sin_port)) /* * mount options @@ -84,8 +84,8 @@ struct ceph_client { struct super_block *sb; unsigned long mounting; /* map bitset; 4=mon, 2=mds, 1=osd map */ - struct completion mount_completion; - + wait_queue_head_t mount_wq; + struct ceph_messenger *msgr; /* messenger instance */ struct ceph_mon_client monc; struct ceph_mds_client mdsc; @@ -100,6 +100,11 @@ struct ceph_client { struct list_head sb_list; }; +static inline int ceph_have_all_maps(struct ceph_client *client) +{ + return find_first_zero_bit(&client->mounting, 4) == 3; +} + /* * CEPH per-mount superblock info */ -- 2.39.5